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

Fix ICE with feature self_struct_ctor #56205

Closed
wants to merge 2 commits into from
Closed
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
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`
Centril marked this conversation as resolved.
Show resolved Hide resolved

error: aborting due to previous error

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