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

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9 #93705

Closed
rik-bosch opened this issue Feb 6, 2022 · 1 comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@rik-bosch
Copy link

Code

enum Direction {
    Up,
    Down,
    Left,
    Right,
}

struct Vector2 {
    x: i32,
    y: i32,
}

impl Vector2 {
    fn move_in_dir(&self, dir: Direction, length: i32) -> Vector2 {
        match dir {
            Direction::Up => {
                Vector2 { x: self.x, y: self.y - length }
            }
            Direction::Down => {
                Vector2 { x: self.x, y: self.y + length }
            }
            Direction::Left => {
                Vector2 { x: self.x - length, y: self.y }
            }
            Direction::Right => {
                Vector2 { x: self.x + length, y: self.y }
            }
        }
    }
}

struct Model {
    block_pos: Vector2,
    running: bool,
}

enum Msg {
    MoveBlock(Direction),
    Quit
}

impl Model {
    fn update(&self, msg: Msg) -> Model {
        match msg {
            Msg::MoveBlock(dir) => {
                Model { block_pos: self.block_pos.move_in_dir(dir, 1), ..self.clone() }
            }
            Msg::Quit => {
                Model { running: false, ..self.clone() }
            }
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.58.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-apple-darwin
release: 1.58.1
LLVM version: 13.0.0

Error output

error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs:319:25: while adjusting Expr { hir_id: HirId { owner: DefId(0:47 ~ tetrust[1848]::{impl#1}::update), local_id: 14 }, kind: Path(Resolved(None, Path { span: src/main.rs:62:74: 62:78 (#0), res: Local(HirId { owner: DefId(0:47 ~ tetrust[1848]::{impl#1}::update), local_id: 2 }), segments: [PathSegment { ident: self#0, hir_id: Some(HirId { owner: DefId(0:47 ~ tetrust[1848]::{impl#1}::update), local_id: 13 }), res: Some(Local(HirId { owner: DefId(0:47 ~ tetrust[1848]::{impl#1}::update), local_id: 2 })), args: None, infer_args: true }] })), span: src/main.rs:62:74: 62:78 (#0) }, can't compose [Borrow(Ref('_#2r, Not)) -> &&Model] and [Borrow(Ref('_#6r, Not)) -> &&Model]

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.58.1 running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `<impl at src/main.rs:58:1: 69:2>::update`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: could not compile `tetrust`
Backtrace

<backtrace>

@rik-bosch rik-bosch added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2022
@ehuss
Copy link
Contributor

ehuss commented Feb 6, 2022

Thanks for the report! This has been fixed by #92112, and the fix should be in the 1.59 release (currently in beta).

Closing as a duplicate of #92010.

@ehuss ehuss closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants