Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Trying to match a refutable Slice pattern in a for loop #18032

Closed
Florob opened this issue Oct 14, 2014 · 1 comment
Closed

ICE: Trying to match a refutable Slice pattern in a for loop #18032

Florob opened this issue Oct 14, 2014 · 1 comment

Comments

@Florob
Copy link
Contributor

Florob commented Oct 14, 2014

The following code currently produces an ICE:

fn main() {
    let bytes = [1u8, 2, 3, 4, 5, 6, 7, 8];

    for [a, b, c, d] in bytes.chunks(4) {
        println!("{} {} {} {}", a, b, c, d);
    }
}
<anon>:4:9: 4:21 error: internal compiler error: Explicit index of non-index type `core::slice::Chunks<'_,u8>`
<anon>:4     for [a, b, c, d] in bytes.chunks(4) {
                 ^~~~~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:113

This should clearly produce a compile time error of course, but not an ICE.

@Florob
Copy link
Contributor Author

Florob commented Oct 14, 2014

Duplicate of #15381. Only saw this now, sorry.

@Florob Florob closed this as completed Oct 14, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Sep 25, 2024
…rsky

internal: Add preliminary `SyntaxEditor` functionality

Related to rust-lang#15710

Implements a `SyntaxEditor` interface to abstract over the details of modifying syntax trees, to both simplify creating new code fixes and code actions, as well as start on the path of getting rid of mutable syntax nodes.

`SyntaxEditor` relies on `SyntaxMappingBuilder`s to feed in the correct information to map AST nodes created by `make` constructors, as `make` constructors do not guarantee that node identity is preserved. This is to paper over the fact that `make` constructors simply re-parse text input instead of building AST nodes from the ground up and re-using the provided syntax nodes.

`SyntaxAnnotation`s are used to find where syntax elements have ended up after edits are applied. This is primarily useful for the `add_{placeholder,tabstop}` set of methods on `SourceChangeBuilder`, as that currently relies on the nodes provided being in the final syntax tree.

Eventually, the goal should be to move this into the `rowan` crate when we move away from mutable syntax nodes, but for now it'll stay in the `syntax` crate.

---

Closes rust-lang#14921 as `SyntaxEditor` ensures that all replace changes are disjoint
Closes rust-lang#9649 by implementing `SyntaxAnnotation`s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant