-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone
Description
When a method returns an &self/mut Foo, and the caller doesn't store the returned value somewhere, there's an internal compiler error. See the following code. Note how when storing the result of x.stuff() in a variable makes it work.
struct Foo { x: int }
impl Foo {
fn stuff(&mut self) -> &self/mut Foo {
return self;
}
}
fn main() {
let mut x = @mut Foo { x: 3 };
x.stuff(); // error: internal compiler error: no enclosing scope with id 49
// storing the result removes the error, so replacing the above
// with the following, works:
// let _y = x.stuff()
// also making 'stuff()' not return anything fixes it
// I guess the "dangling &ptr" cuases issues?
}Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️