rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.54k stars 12.74k forks source link

ICE when generic type `T` is not bound to a `Trait`, but used as `<T as Trait>` in union declaration #87388

Closed zakarumych closed 3 years ago

zakarumych commented 3 years ago

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=dfd08aa6ef697ef5e4edd159a9bbaa37

Code

trait Foo {
    type Bar;
}
union Type<T> {
    bar: <T as Foo>::Bar,
}

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)

On nightly as well

Error output

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<T as Foo>::Bar`

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.55.0-nightly (32c9b7b09 2021-07-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<T as Foo>::Bar`
#1 [check_mod_unstable_api_usage] checking for unstable API usage in top-level module
end of query stack
error: could not compile `playground`
Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\library\std\src\panic.rs:59:5 stack backtrace: 0: 0x7ffd884c574e - ::fmt::h6cc98e249320f302 1: 0x7ffd884ee88c - core::fmt::write::h85dfbe120b6ddd44 2: 0x7ffd884b9748 - ::fmt::h5e54761071278f40 3: 0x7ffd884c97e2 - std::panicking::take_hook::h88bf14ecfdf59a5b 4: 0x7ffd884c92c3 - std::panicking::take_hook::h88bf14ecfdf59a5b 5: 0x7ffd7973de37 - rustc_driver::report_ice::hbc044b9faaa778a2 6: 0x7ffd884ca035 - std::panicking::rust_panic_with_hook::hbf8551f03adac8c7 7: 0x7ffd7d93bd00 - ::fmt::h5794a9d6c3f40738 8: 0x7ffd7d93bc79 - ::fmt::h5794a9d6c3f40738 9: 0x7ffd7dbe2ef1 - rustc_query_system::query::job::report_cycle::h60c3d77428bb768a 10: 0x7ffd7d92b210 - ::fmt::h2399f20a95b85633 11: 0x7ffd7d931c05 - rustc_errors::HandlerInner::err_count::h272524b264342f84 12: 0x7ffd7d92f722 - rustc_errors::Handler::bug::h0fd8fb5edc26b7ac 13: 0x7ffd7d7ccf78 - as rustc_middle::ty::ToPredicate>::to_predicate::hadca7a7419d51212 14: 0x7ffd7d7c0c60 - rustc_middle::ty::query::on_disk_cache:: for &[rustc_middle::mir::abstract_const::Node]>::decode::h43357b0f29f6c9b5 15: 0x7ffd7d7c0ba9 - rustc_middle::ty::query::on_disk_cache:: for &[rustc_middle::mir::abstract_const::Node]>::decode::h43357b0f29f6c9b5 16: 0x7ffd7d7ccea9 - as rustc_middle::ty::ToPredicate>::to_predicate::hadca7a7419d51212 17: 0x7ffd7dbdd3c7 - rustc_middle::util::bug::bug_fmt::h1510b6de2a300666 18: 0x7ffd7ba61376 - rustc_traits::provide::h629c641245e02a6c 19: 0x7ffd7bb2c913 - >>>::lower_into::h3c101f253dec82a5 20: 0x7ffd7c4a663d - ::try_print_query_stack::h1a0e7e2e28ec4054 21: 0x7ffd7c54bb1c - ::store_diagnostics_for_anon_node::hb1a9250ea723ec7f 22: 0x7ffd7c2accd5 - ::visit_foreign_item::hda79da453640ae1e 23: 0x7ffd7c20de75 - ::visit_foreign_item::hda79da453640ae1e 24: 0x7ffd7c457cde - ::try_print_query_stack::h1a0e7e2e28ec4054 25: 0x7ffd7d74fb60 - ::fold_ty::h103dd803e86bb445 26: 0x7ffd7c66a4f4 - ::visit_item::hc2110ee2188ef1be 27: 0x7ffd7c64c206 - ::visit_param::hb405ad205c81be46 28: 0x7ffd7c669527 - ::visit_macro_def::h0ee140f0eb7bd392 29: 0x7ffd7c4940f8 - ::try_print_query_stack::h1a0e7e2e28ec4054 30: 0x7ffd7c53edba - ::store_diagnostics_for_anon_node::hb1a9250ea723ec7f 31: 0x7ffd7c2e836b - ::visit_foreign_item::hda79da453640ae1e 32: 0x7ffd7c1d1bbc - ::visit_foreign_item::hda79da453640ae1e 33: 0x7ffd7c450652 - ::try_print_query_stack::h1a0e7e2e28ec4054 34: 0x7ffd7989efae - rustc_interface::queries::Linker::link::h2e8de7c6ea96ab52 35: 0x7ffd7987ee55 - rustc_interface::passes::BoxedResolver::to_resolver_outputs::h41c44f992ccd4377 36: 0x7ffd7c495311 - ::try_print_query_stack::h1a0e7e2e28ec4054 37: 0x7ffd7c53c767 - ::store_diagnostics_for_anon_node::hb1a9250ea723ec7f 38: 0x7ffd7c2a8c9a - ::visit_foreign_item::hda79da453640ae1e 39: 0x7ffd7c1bd40a - ::visit_foreign_item::hda79da453640ae1e 40: 0x7ffd7c44ce92 - ::try_print_query_stack::h1a0e7e2e28ec4054 41: 0x7ffd797781a9 - ::fmt::h934311db2359d134 42: 0x7ffd797489b1 - rustc_driver::pretty::print_after_hir_lowering::hc5364ea0ee4ca08c 43: 0x7ffd79740b3c - ::fmt::h84f69d4761638945 44: 0x7ffd79749cd2 - rustc_driver::pretty::print_after_hir_lowering::hc5364ea0ee4ca08c 45: 0x7ffd797721c4 - ::fmt::h934311db2359d134 46: 0x7ffd797744ef - ::fmt::h934311db2359d134 47: 0x7ffd7977ec4d - ::fmt::h934311db2359d134 48: 0x7ffd884d817a - std::sys::windows::thread::Thread::new::h8dd2182e95caa21a 49: 0x7ffe04e87034 - BaseThreadInitThunk 50: 0x7ffe05042651 - RtlUserThreadStart ```

hellow554 commented 3 years ago

Regression in nightly-2020-10-17 dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea...e3051d8c24467b54c81da9d9ad70a3e82e106ec1

Somewhere in e3051d8c24467b54c81da9d9ad70a3e82e106ec1

I think this should be prioritized, I'm sorry if not.

@rustbot modify labels: I-prioritize

jackh726 commented 3 years ago

Playground link isn't right (doesn't link to the code) and the backtrace looks wrong (I see Chalk lowering code?).

But this might be from https://github.com/rust-lang/rust/pull/77547

zakarumych commented 3 years ago

Playground link isn't right (doesn't link to the code) and the backtrace looks wrong (I see Chalk lowering code?).

Sorry, fixed the link

camelid commented 3 years ago

Appears to be a duplicate of #81199 (cc #87327 as well).