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

save-analysis: Fix ICE when processing associated constant #60649

Merged
merged 3 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
}

// walk type and init value
self.visit_ty(typ);
if let Some(expr) = expr {
self.visit_expr(expr);
}
self.nest_tables(id, |v| {
oli-obk marked this conversation as resolved.
Show resolved Hide resolved
v.visit_ty(typ);
if let Some(expr) = expr {
v.visit_expr(expr);
}
});
}

// FIXME tuple structs should generate tuple-specific data.
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/save-analysis/issue-59134-0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags: -Zsave-analysis

// Check that this doesn't ICE when processing associated const (field expr).

pub fn f() {
trait Trait {}
impl Trait {
const FLAG: u32 = bogus.field; //~ ERROR cannot find value `bogus`
}
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/save-analysis/issue-59134-0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0425]: cannot find value `bogus` in this scope
--> $DIR/issue-59134-0.rs:8:27
|
LL | const FLAG: u32 = bogus.field;
| ^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
12 changes: 12 additions & 0 deletions src/test/ui/save-analysis/issue-59134-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags: -Zsave-analysis

// Check that this doesn't ICE when processing associated const (type).

fn func() {
trait Trait {
type MyType;
const CONST: Self::MyType = bogus.field; //~ ERROR cannot find value `bogus`
}
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/save-analysis/issue-59134-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0425]: cannot find value `bogus` in this scope
--> $DIR/issue-59134-1.rs:8:37
|
LL | const CONST: Self::MyType = bogus.field;
| ^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.