Skip to content

Commit

Permalink
Fix ICE with feature self_struct_ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Nov 25, 2018
1 parent 4632cf2 commit 5c99ae6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
Some(Def::Local(node_id)) | Some(Def::Upvar(node_id, ..)) => {
self.reachable_symbols.insert(node_id);
}
Some(Def::Err) => {} // #56202: calling `def.def_id()` would be an error
Some(def) => {
let def_id = def.def_id();
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-56202.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(self_struct_ctor)]

trait FooTrait {}

trait BarTrait {
fn foo<T: FooTrait>(_: T) -> Self;
}

struct FooStruct(u32);

impl BarTrait for FooStruct {
fn foo<T: FooTrait>(_: T) -> Self {
Self(u32::default())
}
}
7 changes: 7 additions & 0 deletions src/test/ui/issues/issue-56202.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error[E0601]: `main` function not found in crate `issue_56202`
|
= note: consider adding a `main` function to `$DIR/issue-56202.rs`

error: aborting due to previous error

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

0 comments on commit 5c99ae6

Please sign in to comment.