Skip to content

Commit

Permalink
Rollup merge of rust-lang#56205 - estebank:ice-ice-baby, r=nikomatsakis
Browse files Browse the repository at this point in the history
Fix ICE with feature self_struct_ctor

Fix rust-lang#56202.
  • Loading branch information
pietroalbini committed Nov 28, 2018
2 parents b2ad3e2 + 8d76f54 commit 9642325
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
self.reachable_symbols.insert(node_id);
}
Some(def) => {
let def_id = def.def_id();
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| {
self.tcx.hir.as_local_node_id(def_id).map(|node_id| (node_id, def_id))
}) {
if self.def_id_represents_local_inlined_item(def_id) {
self.worklist.push(node_id);
} else {
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 9642325

Please sign in to comment.