Skip to content

ICE: ForeignItem(ForeignItem ... is not a valid scope for an opaque type item #119295

Closed

Description

auto-reduced (treereduce-rust):

extern "C" {
    pub fn lint_me(
        x: Bar<
            S<
                {
                    type B<b> = impl ;
                },
            >,
        >,
    );
}

original:

pub trait Foo {
    type Assoc;
}

impl Foo for () {
    type Assoc = u32;
}

extern "C" {
    pub fn lint_me(x: Bar<S<{
    type B<b> =impl;
    fn a() -> Self::B<'a>;
}>>);
}

#[repr(transparent)]
pub struct Bar<T: Foo> {
    value: <T as Foo>::Assoc,
}

fn main() {}

Version information

rustc 1.77.0-nightly (f2348fb29 2023-12-25)
binary: rustc
commit-hash: f2348fb29a49d1bd4b62531a36c685f1961a8f46
commit-date: 2023-12-25
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: at least one trait must be specified
 --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:6:33
  |
6 |                     type B<b> = impl ;
  |                                 ^^^^

error[E0412]: cannot find type `Bar` in this scope
 --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:3:12
  |
3 |         x: Bar<
  |            ^^^ not found in this scope

error[E0412]: cannot find type `S` in this scope
 --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:4:13
  |
4 |             S<
  |             ^ not found in this scope

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:6:33
  |
6 |                     type B<b> = impl ;
  |                                 ^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

warning: type parameter `b` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:6:28
  |
6 |                     type B<b> = impl ;
  |                            ^ help: convert the identifier to upper camel case: `B`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:11:2
   |
11 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs`

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs:72:22: ForeignItem(ForeignItem { ident: lint_me#0, kind: Fn(FnDecl { inputs: [Ty { hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).1), kind: Path(Resolved(None, Path { span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:3:12: 9:10 (#0), res: Err, segments: [PathSegment { ident: Bar#0, hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).8), res: Err, args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).2), kind: Path(Resolved(None, Path { span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:4:13: 8:14 (#0), res: Err, segments: [PathSegment { ident: S#0, hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).7), res: Err, args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).3), def_id: DefId(0:5 ~ mvce[5bf6]::{extern#0}::lint_me::{constant#0}), body: BodyId { hir_id: HirId(DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me).4) } }, span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:5:17: 7:18 (#0), is_desugared_from_effects: false })], bindings: [], parenthesized: No, span_ext: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:4:14: 8:14 (#0) }), infer_args: false }] })), span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:4:13: 8:14 (#0) })], bindings: [], parenthesized: No, span_ext: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:3:15: 9:10 (#0) }), infer_args: false }] })), span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:3:12: 9:10 (#0) }], output: DefaultReturn(/tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:10:6: 10:6 (#0)), c_variadic: false, implicit_self: None, lifetime_elision_allowed: false }, [x#0], Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:10:6: 10:6 (#0), span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:2:19: 2:19 (#0) }), owner_id: DefId(0:4 ~ mvce[5bf6]::{extern#0}::lint_me), span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:2:5: 10:7 (#0), vis_span: /tmp/icemaker_global_tempdir.RvQb0MksmZrk/rustc_testrunner_tmpdir_reporting.nx8R9wVCZIzr/mvce.rs:2:5: 2:8 (#0) }) is not a valid scope for an opaque type item

thread 'rustc' panicked at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/compiler/rustc_errors/src/lib.rs:1056:30:
Box<dyn Any>
stack backtrace:
   0:     0x7ff3e058b6f6 - std::backtrace_rs::backtrace::libunwind::trace::h965388740e0ca348
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ff3e058b6f6 - std::backtrace_rs::backtrace::trace_unsynchronized::hcadd2cc8f09e5067
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff3e058b6f6 - std::sys_common::backtrace::_print_fmt::hbc5647219024340e
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ff3e058b6f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha915c7358479dca0
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff3e05ddf40 - core::fmt::rt::Argument::fmt::h7a45007b7d2a7cb7
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/core/src/fmt/rt.rs:142:9
   5:     0x7ff3e05ddf40 - core::fmt::write::h3fb07fd5b04d1770
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/core/src/fmt/mod.rs:1120:17
   6:     0x7ff3e057f4af - std::io::Write::write_fmt::h3a59635087f54341
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/io/mod.rs:1810:15
   7:     0x7ff3e058b4d4 - std::sys_common::backtrace::_print::h57332f16a149c9c0
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff3e058b4d4 - std::sys_common::backtrace::print::hf815173824ed1378
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff3e058e267 - std::panicking::default_hook::{{closure}}::heed12c613120b9ea
  10:     0x7ff3e058dfc9 - std::panicking::default_hook::hbc9b893dd66a8f8f
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/panicking.rs:292:9
  11:     0x7ff3e3359c4c - std[ff143c18df46cc5c]::panicking::update_hook::<alloc[b7464cfaa17c0636]::boxed::Box<rustc_driver_impl[8953212d64818705]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ff3e058e9b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h05d0415acefb04a2
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/alloc/src/boxed.rs:2029:9
  13:     0x7ff3e058e9b6 - std::panicking::rust_panic_with_hook::h20d4163f08882ea3
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/panicking.rs:783:13
  14:     0x7ff3e33928f4 - std[ff143c18df46cc5c]::panicking::begin_panic::<rustc_errors[898a69bdb4e1fba6]::ExplicitBug>::{closure#0}
  15:     0x7ff3e338f036 - std[ff143c18df46cc5c]::sys_common::backtrace::__rust_end_short_backtrace::<std[ff143c18df46cc5c]::panicking::begin_panic<rustc_errors[898a69bdb4e1fba6]::ExplicitBug>::{closure#0}, !>
  16:     0x7ff3e338eca6 - std[ff143c18df46cc5c]::panicking::begin_panic::<rustc_errors[898a69bdb4e1fba6]::ExplicitBug>
  17:     0x7ff3e339d921 - <rustc_errors[898a69bdb4e1fba6]::diagnostic_builder::BugAbort as rustc_errors[898a69bdb4e1fba6]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7ff3e376f65e - <rustc_errors[898a69bdb4e1fba6]::DiagCtxt>::bug::<alloc[b7464cfaa17c0636]::string::String>
  19:     0x7ff3e380ac2b - rustc_middle[25856fc61bc393b2]::util::bug::opt_span_bug_fmt::<rustc_span[b8071cd1de6205fc]::span_encoding::Span>::{closure#0}
  20:     0x7ff3e37f467a - rustc_middle[25856fc61bc393b2]::ty::context::tls::with_opt::<rustc_middle[25856fc61bc393b2]::util::bug::opt_span_bug_fmt<rustc_span[b8071cd1de6205fc]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff3e37f4518 - rustc_middle[25856fc61bc393b2]::ty::context::tls::with_context_opt::<rustc_middle[25856fc61bc393b2]::ty::context::tls::with_opt<rustc_middle[25856fc61bc393b2]::util::bug::opt_span_bug_fmt<rustc_span[b8071cd1de6205fc]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff3e1798630 - rustc_middle[25856fc61bc393b2]::util::bug::bug_fmt
  23:     0x7ff3e55ea5f5 - rustc_hir_analysis[634d98571242aa52]::collect::type_of::type_of_opaque
  24:     0x7ff3e55e9a39 - rustc_query_impl[1cbbd336272c107f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1cbbd336272c107f]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7ff3e468c2d4 - rustc_query_system[81c735e867317fc8]::query::plumbing::try_execute_query::<rustc_query_impl[1cbbd336272c107f]::DynamicConfig<rustc_query_system[81c735e867317fc8]::query::caches::DefaultCache<rustc_span[b8071cd1de6205fc]::def_id::DefId, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1cbbd336272c107f]::plumbing::QueryCtxt, false>
  26:     0x7ff3e564cb5e - rustc_query_impl[1cbbd336272c107f]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7ff3e47bb9b8 - rustc_middle[25856fc61bc393b2]::query::plumbing::query_get_at::<rustc_query_system[81c735e867317fc8]::query::caches::DefaultCache<rustc_span[b8071cd1de6205fc]::def_id::DefId, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>>
  28:     0x7ff3e2a2d7f5 - rustc_hir_analysis[634d98571242aa52]::collect::type_of::type_of
  29:     0x7ff3e468d3fe - rustc_query_impl[1cbbd336272c107f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1cbbd336272c107f]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7ff3e468c2d4 - rustc_query_system[81c735e867317fc8]::query::plumbing::try_execute_query::<rustc_query_impl[1cbbd336272c107f]::DynamicConfig<rustc_query_system[81c735e867317fc8]::query::caches::DefaultCache<rustc_span[b8071cd1de6205fc]::def_id::DefId, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1cbbd336272c107f]::plumbing::QueryCtxt, false>
  31:     0x7ff3e468be9d - rustc_query_impl[1cbbd336272c107f]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7ff3e47bb9b8 - rustc_middle[25856fc61bc393b2]::query::plumbing::query_get_at::<rustc_query_system[81c735e867317fc8]::query::caches::DefaultCache<rustc_span[b8071cd1de6205fc]::def_id::DefId, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 8usize]>>>
  33:     0x7ff3e52aeec0 - rustc_hir_analysis[634d98571242aa52]::check::check::check_item_type
  34:     0x7ff3e52a8ce1 - rustc_hir_analysis[634d98571242aa52]::check::check::check_mod_item_types
  35:     0x7ff3e52a8c93 - rustc_query_impl[1cbbd336272c107f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1cbbd336272c107f]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 0usize]>>
  36:     0x7ff3e524313b - rustc_query_system[81c735e867317fc8]::query::plumbing::try_execute_query::<rustc_query_impl[1cbbd336272c107f]::DynamicConfig<rustc_query_system[81c735e867317fc8]::query::caches::DefaultCache<rustc_span[b8071cd1de6205fc]::def_id::LocalModDefId, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1cbbd336272c107f]::plumbing::QueryCtxt, false>
  37:     0x7ff3e5242b17 - rustc_query_impl[1cbbd336272c107f]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7ff3e4c30928 - rustc_hir_analysis[634d98571242aa52]::check_crate
  39:     0x7ff3e4fba569 - rustc_interface[7ef781d392f3a409]::passes::analysis
  40:     0x7ff3e4fba19d - rustc_query_impl[1cbbd336272c107f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1cbbd336272c107f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7ff3e55c3d64 - rustc_query_system[81c735e867317fc8]::query::plumbing::try_execute_query::<rustc_query_impl[1cbbd336272c107f]::DynamicConfig<rustc_query_system[81c735e867317fc8]::query::caches::SingleCache<rustc_middle[25856fc61bc393b2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1cbbd336272c107f]::plumbing::QueryCtxt, false>
  42:     0x7ff3e55c3b55 - rustc_query_impl[1cbbd336272c107f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7ff3e5344492 - rustc_interface[7ef781d392f3a409]::interface::run_compiler::<core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>, rustc_driver_impl[8953212d64818705]::run_compiler::{closure#0}>::{closure#0}
  44:     0x7ff3e55d2586 - std[ff143c18df46cc5c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7ef781d392f3a409]::util::run_in_thread_with_globals<rustc_interface[7ef781d392f3a409]::util::run_in_thread_pool_with_globals<rustc_interface[7ef781d392f3a409]::interface::run_compiler<core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>, rustc_driver_impl[8953212d64818705]::run_compiler::{closure#0}>::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>
  45:     0x7ff3e55d23b3 - <<std[ff143c18df46cc5c]::thread::Builder>::spawn_unchecked_<rustc_interface[7ef781d392f3a409]::util::run_in_thread_with_globals<rustc_interface[7ef781d392f3a409]::util::run_in_thread_pool_with_globals<rustc_interface[7ef781d392f3a409]::interface::run_compiler<core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>, rustc_driver_impl[8953212d64818705]::run_compiler::{closure#0}>::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[884665c43e30f28c]::result::Result<(), rustc_span[b8071cd1de6205fc]::ErrorGuaranteed>>::{closure#1} as core[884665c43e30f28c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7ff3e05988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdc922615531e23f3
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/alloc/src/boxed.rs:2015:9
  47:     0x7ff3e05988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5b4ebdbf4c9af862
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/alloc/src/boxed.rs:2015:9
  48:     0x7ff3e05988e5 - std::sys::unix::thread::Thread::new::thread_start::h667367404b5bfe17
                               at /rustc/f2348fb29a49d1bd4b62531a36c685f1961a8f46/library/std/src/sys/unix/thread.rs:108:17
  49:     0x7ff3e03849eb - <unknown>
  50:     0x7ff3e04087cc - <unknown>
  51:                0x0 - <unknown>

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.77.0-nightly (f2348fb29 2023-12-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [type_of_opaque] computing type of opaque `lint_me::{constant#0}::B::{opaque#0}`
#1 [type_of] computing type of `lint_me::{constant#0}::B::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0412, E0601, E0658.
For more information about an error, try `rustc --explain E0412`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions