Closed
Description
Found with a modified fuzz-rustc
Code
struct S;
fn f() {
let _: S<impl Oops> = S;
}
fn main() {}
Error output
error[E0405]: cannot find trait `Oops` in this scope
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
error: internal compiler error: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:537:17: no type for node HirId { owner: OwnerId { def_id: DefId(0:5 ~ ntfn[dbda]::f) }, local_id: 3 }: type impl Oops (hir_id=HirId { owner: OwnerId { def_id: DefId(0:5 ~ ntfn[dbda]::f) }, local_id: 3 }) in fcx 0x7000069e82f0
Full output including backtrace
error[E0405]: cannot find trait `Oops` in this scope
--> ntfn.rs:3:19
|
2 | fn f() {
| - help: you might be missing a type parameter: `<Oops>`
3 | let _: S<impl Oops> = S;
| ^^^^ not found in this scope
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> ntfn.rs:3:14
|
3 | let _: S<impl Oops> = S;
| ^^^^^^^^^
error: internal compiler error: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:537:17: no type for node HirId { owner: OwnerId { def_id: DefId(0:5 ~ ntfn[dbda]::f) }, local_id: 3 }: type impl Oops (hir_id=HirId { owner: OwnerId { def_id: DefId(0:5 ~ ntfn[dbda]::f) }, local_id: 3 }) in fcx 0x7000069e82f0
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/compiler/rustc_errors/src/lib.rs:1555:9
stack backtrace:
0: 0x10dfb9f22 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc8a49f87ce17062a
1: 0x10e01885a - core::fmt::write::h8a1a7abc727fe6d0
2: 0x10dfac2ec - std::io::Write::write_fmt::h784a2d3ee2ee8639
3: 0x10dfb9cea - std::sys_common::backtrace::print::hb4003780820818b1
4: 0x10dfbd016 - std::panicking::default_hook::{{closure}}::ha4bb64ed2ba8f281
5: 0x10dfbcd67 - std::panicking::default_hook::haa41a49d8ba42d3b
6: 0x118dea9bd - rustc_driver[3dbfeae94bbb450c]::DEFAULT_HOOK::{closure#0}::{closure#0}
7: 0x10dfbd7fd - std::panicking::rust_panic_with_hook::h0ec6182f72894cd1
8: 0x11d59fd77 - std[b7fc25f664aa2c42]::panicking::begin_panic::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>::{closure#0}
9: 0x11d59f5f9 - std[b7fc25f664aa2c42]::sys_common::backtrace::__rust_end_short_backtrace::<std[b7fc25f664aa2c42]::panicking::begin_panic<rustc_errors[3e76822466e0ccc2]::ExplicitBug>::{closure#0}, !>
10: 0x11dba4ff9 - std[b7fc25f664aa2c42]::panicking::begin_panic::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>
11: 0x11d59f589 - std[b7fc25f664aa2c42]::panic::panic_any::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>
12: 0x11d59cecd - <rustc_errors[3e76822466e0ccc2]::HandlerInner>::bug::<&alloc[f3b087a993ab1fcd]::string::String>
13: 0x11d59c997 - <rustc_errors[3e76822466e0ccc2]::Handler>::bug::<&alloc[f3b087a993ab1fcd]::string::String>
14: 0x11d64be52 - rustc_middle[e2305deeabdd0cca]::ty::context::tls::with_context_opt::<rustc_middle[e2305deeabdd0cca]::ty::context::tls::with_opt<rustc_middle[e2305deeabdd0cca]::util::bug::opt_span_bug_fmt<rustc_span[663101514bc5927d]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
15: 0x11d64c251 - rustc_middle[e2305deeabdd0cca]::util::bug::opt_span_bug_fmt::<rustc_span[663101514bc5927d]::span_encoding::Span>
16: 0x11dba69ae - rustc_middle[e2305deeabdd0cca]::util::bug::bug_fmt
17: 0x11b5abbb1 - <rustc_hir_typeck[bfe26f40d5efb549]::fn_ctxt::FnCtxt>::node_ty
18: 0x11b624c06 - <rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx as rustc_hir[45ffbd509c54e574]::intravisit::Visitor>::visit_ty
19: 0x11b64f1dd - rustc_hir[45ffbd509c54e574]::intravisit::walk_ty::<rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx>
20: 0x11b624bf8 - <rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx as rustc_hir[45ffbd509c54e574]::intravisit::Visitor>::visit_ty
21: 0x11b624b4e - <rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx as rustc_hir[45ffbd509c54e574]::intravisit::Visitor>::visit_local
22: 0x11b624547 - <rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx as rustc_hir[45ffbd509c54e574]::intravisit::Visitor>::visit_block
23: 0x11b62429d - <rustc_hir_typeck[bfe26f40d5efb549]::writeback::WritebackCx as rustc_hir[45ffbd509c54e574]::intravisit::Visitor>::visit_expr
24: 0x11b5f2ae5 - <rustc_hir_typeck[bfe26f40d5efb549]::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
25: 0x11b6e5907 - <rustc_hir_typeck[bfe26f40d5efb549]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[bfe26f40d5efb549]::typeck_with_fallback<rustc_hir_typeck[bfe26f40d5efb549]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[e2305deeabdd0cca]::ty::context::TypeckResults>
26: 0x11b67ce8a - rustc_hir_typeck[bfe26f40d5efb549]::typeck
27: 0x11c5cd9f9 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<rustc_span[663101514bc5927d]::def_id::LocalDefId, &rustc_middle[e2305deeabdd0cca]::ty::context::TypeckResults>>
28: 0x11c6c9eec - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::typeck, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
29: 0x11b62ccbb - rustc_data_structures[2727043258b5d620]::sync::par_for_each_in::<&[rustc_span[663101514bc5927d]::def_id::LocalDefId], <rustc_middle[e2305deeabdd0cca]::hir::map::Map>::par_body_owners<rustc_hir_typeck[bfe26f40d5efb549]::typeck_item_bodies::{closure#0}>::{closure#0}>
30: 0x11b67c60d - rustc_hir_typeck[bfe26f40d5efb549]::typeck_item_bodies
31: 0x11c65e239 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<(), ()>>
32: 0x11c6be7b9 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::typeck_item_bodies, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
33: 0x11b7f3384 - <rustc_session[e61d3bba1e132503]::session::Session>::time::<(), rustc_hir_analysis[34bd11cda90a81cf]::check_crate::{closure#7}>
34: 0x11b8c5eef - rustc_hir_analysis[34bd11cda90a81cf]::check_crate
35: 0x118ead81a - rustc_interface[57c9fce0e0c2ba2]::passes::analysis
36: 0x11c64fffc - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<(), core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>>
37: 0x11c6ca299 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::analysis, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
38: 0x118d79dd6 - <rustc_interface[57c9fce0e0c2ba2]::passes::QueryContext>::enter::<rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
39: 0x118dbdecd - rustc_span[663101514bc5927d]::with_source_map::<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
40: 0x118dadf2c - <scoped_tls[6bbd84b04dbf1568]::ScopedKey<rustc_span[663101514bc5927d]::SessionGlobals>>::set::<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
41: 0x118d7d31a - std[b7fc25f664aa2c42]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[57c9fce0e0c2ba2]::util::run_in_thread_pool_with_globals<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
42: 0x118d633ab - <<std[b7fc25f664aa2c42]::thread::Builder>::spawn_unchecked_<rustc_interface[57c9fce0e0c2ba2]::util::run_in_thread_pool_with_globals<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#1} as core[67cd3202410ff936]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
43: 0x10dfc6bb7 - std::sys::unix::thread::Thread::new::thread_start::h0a480c6421a176eb
44: 0x7ff80d84d4e1 - __pthread_start
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.67.0-nightly (a00f8ba7f 2022-11-15) running on x86_64-apple-darwin
query stack during panic:
#0 [typeck] type-checking `f`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0405, E0562.
For more information about an error, try `rustc --explain E0405`.
Regression
Regression in nightly-2021-10-02 (commits)
Version
rustc 1.67.0-nightly (a00f8ba7f 2022-11-15)
binary: rustc
commit-hash: a00f8ba7fcac1b27341679c51bf5a3271fa82df3
commit-date: 2022-11-15
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4