Skip to content

Commit 48276a7

Browse files
authored
Rollup merge of rust-lang#56205 - estebank:ice-ice-baby, r=nikomatsakis
Fix ICE with feature self_struct_ctor Fix rust-lang#56202.
2 parents bb35aad + 8d76f54 commit 48276a7

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/librustc/middle/reachable.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
117117
self.reachable_symbols.insert(node_id);
118118
}
119119
Some(def) => {
120-
let def_id = def.def_id();
121-
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
120+
if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| {
121+
self.tcx.hir.as_local_node_id(def_id).map(|node_id| (node_id, def_id))
122+
}) {
122123
if self.def_id_represents_local_inlined_item(def_id) {
123124
self.worklist.push(node_id);
124125
} else {

src/test/ui/issues/issue-56202.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(self_struct_ctor)]
2+
3+
trait FooTrait {}
4+
5+
trait BarTrait {
6+
fn foo<T: FooTrait>(_: T) -> Self;
7+
}
8+
9+
struct FooStruct(u32);
10+
11+
impl BarTrait for FooStruct {
12+
fn foo<T: FooTrait>(_: T) -> Self {
13+
Self(u32::default())
14+
}
15+
}

src/test/ui/issues/issue-56202.stderr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error[E0601]: `main` function not found in crate `issue_56202`
2+
|
3+
= note: consider adding a `main` function to `$DIR/issue-56202.rs`
4+
5+
error: aborting due to previous error
6+
7+
For more information about this error, try `rustc --explain E0601`.

0 commit comments

Comments
 (0)