rust-lang / rust

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

ICE: `Failed to normalize Alias(Weak, AliasTy {` with `feature(lazy_type_alias)` #127351

Open Naserume opened 1 week ago

Naserume commented 1 week ago

Code

#![feature(lazy_type_alias)]
#![allow(incomplete_features)]

struct Outer0<'a, T>(ExplicitTypeOutlives<'a, T>);
type ExplicitTypeOutlives<'a, T: 'a> = (&'a (), T);

pub struct Warns {
    _significant_drop: ExplicitTypeOutlives,
    field: String,
}

pub fn test(w: Warns) {
    _ = || drop(w.field);
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (cc8da78a0 2024-07-04)
binary: rustc
commit-hash: cc8da78a036dc3c15c35a97651b02af9a6d30c1e
commit-date: 2024-07-04
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

error[E0106]: missing lifetime specifier
 --> ./E9199.rs:8:24
  |
8 |     _significant_drop: ExplicitTypeOutlives,
  |                        ^^^^^^^^^^^^^^^^^^^^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
7 ~ pub struct Warns<'a> {
8 ~     _significant_drop: ExplicitTypeOutlives<'a>,
  |

error[E0107]: missing generics for type alias `ExplicitTypeOutlives`
 --> ./E9199.rs:8:24
  |
8 |     _significant_drop: ExplicitTypeOutlives,
  |                        ^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
  |
note: type alias defined here, with 1 generic parameter: `T`
 --> ./E9199.rs:5:6
  |
5 | type ExplicitTypeOutlives<'a, T: 'a> = (&'a (), T);
  |      ^^^^^^^^^^^^^^^^^^^^     -
help: add missing generic argument
  |
8 |     _significant_drop: ExplicitTypeOutlives<T>,
  |                                            +++
Backtrace

``` error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90: Failed to normalize Alias(Weak, AliasTy { args: ['{erased}, {type error}], def_id: DefId(0:8 ~ E9199[ca39]::ExplicitTypeOutlives) }), maybe try to call `try_normalize_erasing_regions` instead thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90: Box stack backtrace: 0: 0x1094f2d93 - ::fmt::hfeb614152c5fc770 1: 0x10953e17b - core::fmt::write::h19d9b55d1716a641 2: 0x1094e8b7e - std::io::Write::write_fmt::h65bfd6c063c93506 3: 0x1094f2b81 - std::sys::backtrace::print::h6f13abc1d63a7b7a 4: 0x1094f5959 - std::panicking::default_hook::{{closure}}::h53504a5e8286ae49 5: 0x1094f56da - std::panicking::default_hook::h46ce4737ada06aa6 6: 0x1127eb07c - std[96ba86566161595a]::panicking::update_hook::>::{closure#0} 7: 0x1094f6699 - std::panicking::rust_panic_with_hook::h3ebbbfeff58c5313 8: 0x11285f177 - std[96ba86566161595a]::panicking::begin_panic::::{closure#0} 9: 0x11284afb9 - std[96ba86566161595a]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x117284fc9 - std[96ba86566161595a]::panicking::begin_panic:: 11: 0x1128712b6 - ::emit_producing_guarantee 12: 0x113516315 - rustc_middle[3507220e01ce78dc]::util::bug::opt_span_bug_fmt::::{closure#0} 13: 0x1134cbf57 - rustc_middle[3507220e01ce78dc]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 14: 0x1134cba95 - rustc_middle[3507220e01ce78dc]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 15: 0x11734862b - rustc_middle[3507220e01ce78dc]::util::bug::bug_fmt 16: 0x11379fd3b - >::move_paths_for_fields 17: 0x11379fe7a - >::open_drop_for_adt_contents 18: 0x11379e2cb - >::elaborate_drop 19: 0x1137ef038 - as alloc[d7368e4144f22d76]::vec::spec_from_iter_nested::SpecFromIterNested, core[677ae2db44f68e98]::iter::adapters::map::Map)>>, core[677ae2db44f68e98]::slice::iter::Iter>, >::drop_halfladder::{closure#0}>>>>::from_iter 20: 0x11379d340 - >::drop_ladder 21: 0x11379f180 - >::open_drop_for_tuple 22: 0x11379e239 - >::elaborate_drop 23: 0x1138b86c0 - ::run_pass 24: 0x1137fd2ba - rustc_mir_transform[7f80daa91ef18b2a]::pass_manager::run_passes_inner 25: 0x1138ae364 - rustc_mir_transform[7f80daa91ef18b2a]::run_analysis_to_runtime_passes 26: 0x1138adeb7 - rustc_mir_transform[7f80daa91ef18b2a]::mir_drops_elaborated_and_const_checked 27: 0x113eab7ac - rustc_query_impl[e04fdc29b284e1d7]::plumbing::__rust_begin_short_backtrace::> 28: 0x113d2265e - rustc_query_system[31cd079b68d87400]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e04fdc29b284e1d7]::plumbing::QueryCtxt, false> 29: 0x113ebca2b - rustc_query_impl[e04fdc29b284e1d7]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 30: 0x113162a98 - rustc_interface[dea1eaaf15b0b7c8]::passes::run_required_analyses 31: 0x1131647f0 - rustc_interface[dea1eaaf15b0b7c8]::passes::analysis 32: 0x113eabeac - rustc_query_impl[e04fdc29b284e1d7]::plumbing::__rust_begin_short_backtrace::> 33: 0x113c8ac1e - rustc_query_system[31cd079b68d87400]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e04fdc29b284e1d7]::plumbing::QueryCtxt, false> 34: 0x113eb6407 - rustc_query_impl[e04fdc29b284e1d7]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 35: 0x112794bb7 - >::enter::, rustc_driver_impl[d6cc6074f4ffa8bf]::run_compiler::{closure#0}::{closure#1}::{closure#5}> 36: 0x1127f23cb - rustc_interface[dea1eaaf15b0b7c8]::interface::run_compiler::, rustc_driver_impl[d6cc6074f4ffa8bf]::run_compiler::{closure#0}>::{closure#1} 37: 0x1127dc9f1 - std[96ba86566161595a]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[d6cc6074f4ffa8bf]::run_compiler::{closure#0}>::{closure#1}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>>::{closure#0}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>> 38: 0x1127f8d96 - <::spawn_unchecked_, rustc_driver_impl[d6cc6074f4ffa8bf]::run_compiler::{closure#0}>::{closure#1}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>>::{closure#0}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[677ae2db44f68e98]::result::Result<(), rustc_span[9a6059d5c98a4f34]::ErrorGuaranteed>>::{closure#2} as core[677ae2db44f68e98]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 39: 0x1094ff83b - std::sys::pal::unix::thread::Thread::new::thread_start::he8797374daece752 40: 0x7ff801f5318b - __pthread_start 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: please make sure that you have updated to the latest nightly note: please attach the file at `/Users/240703-nightly/rustc-ice-2024-07-05T01_57_08-90724.txt` to your bug report query stack during panic: #0 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}` #1 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors Some errors have detailed explanations: E0106, E0107. For more information about an error, try `rustc --explain E0106`. ```

Note

Ice location: https://github.com/rust-lang/rust/blob/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs#L161-L173

@rustbot label +F-lazy_type_alias +requires-incomplete-features

GrigorenkoPV commented 1 week ago

Bisects to #125667