Closed
Description
auto-reduced (treereduce-rust):
type S2Vec<T> = T5<T>;
trait Bound {
type Assoc;
}
type T5<U: Bound> = <_ as Bound>::Assoc;
fn main() {}
original code
original:
// Test `ignored_generic_bounds` lint warning about bounds in type aliases.
// check-pass
#![allow(dead_code)]
use std::rc::Rc;
type SVec<T: Send + Send> = Vec<T>;
//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds]
type S2Vec<T> where T: Send = T5<T>;
//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds]
type VVec<'b, 'a: 'b + 'b> = (&'b u32, Vec<&'a i32>);
//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds]
type WVec<'b, T: 'b + 'b> = (&'b u32, Vec<T>);
//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds]
type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec<T>);
//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds]
static STATIC: u32 = 0;
fn foo<'a>(y: &'a i32) {
// If any of the bounds above would matter, the code below would be rejected.
// This can be seen when replacing the type aliases above by newtype structs.
// (The type aliases have no unused parameters to make that a valid transformation.)
let mut x: SVec<_> = Vec::new();
x.push(Rc::new(42)); // is not send
let mut x: S2Vec<_> = Vec::new();
x.push(Rc::new(42)); // `'a: 'static` does not hold
let mut x: VVec<'static, 'a> = (&STATIC, Vec::new());
x.1.push(y); // `'a: 'static` does not hold
let mut x: WVec<'static, &'a i32> = (&STATIC, Vec::new());
x.1.push(y); // `&'a i32: 'static` does not hold
let mut x: W2Vec<'static, &'a i32> = (&STATIC, Vec::new());
x.1.push(y); // `&'a i32: 'static` does not hold
}
// Bounds are not checked either; i.e., the definition is not necessarily well-formed.
struct Sendable<T: Send>(T);
type MySendable<T> = Sendable<T>; // no error here!
// However, bounds *are* taken into account when accessing associated types
trait Bound { type Assoc; }
type T1<U: Bound> = U::Assoc; //~ WARN not enforced in type aliases
type T2<U> where U: Bound = U::Assoc; //~ WARN not enforced in type aliases
// This errors:
// `type T3<U> = U::Assoc;`
// Do this instead:
type T4<U> = <U as Bound>::Assoc;
// Make sure the help about associated types is not shown incorrectly
type T5<U: Bound> = <_ as Bound>::Assoc; //~ WARN not enforced in type aliases
type T6<U: Bound> = ::std::vec::Vec<U>; //~ WARN not enforced in type aliases
fn main() {}
Version information
rustc 1.86.0-nightly (252b07bba 2025-01-10)
binary: rustc
commit-hash: 252b07bba419a075acfa1fa85d66683e9623c281
commit-date: 2025-01-10
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6
Possibly related line of code:
rust/compiler/rustc_hir_analysis/src/check/check.rs
Lines 1634 to 1646 in 252b07b
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/check/check.rs:1640:9:
assertion failed: tcx.dcx().has_errors().is_some()
stack backtrace:
0: 0x7157708edb3a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h10d416a954da7cd8
1: 0x715771012de6 - core::fmt::write::hc83d463fcf24ab30
2: 0x715771f41b91 - std::io::Write::write_fmt::h0e4f7a78a5fb36bb
3: 0x7157708ed992 - std::sys::backtrace::BacktraceLock::print::hfec0abce2f365eab
4: 0x7157708eff37 - std::panicking::default_hook::{{closure}}::h11b572a3fd936c7d
5: 0x7157708efd20 - std::panicking::default_hook::h04ad59a902f700af
6: 0x71576fa53bc8 - std[502aa70c49e1fa42]::panicking::update_hook::<alloc[4e3dba80cfae5710]::boxed::Box<rustc_driver_impl[df7680cc67222e37]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7157708f07c3 - std::panicking::rust_panic_with_hook::he6e31c792e366ac1
8: 0x7157708f0486 - std::panicking::begin_panic_handler::{{closure}}::ha7b4c6b48d75b15b
9: 0x7157708ee019 - std::sys::backtrace::__rust_end_short_backtrace::h2e10bdd077ad9bf8
10: 0x7157708f017d - rust_begin_unwind
11: 0x71576d5a1c60 - core::panicking::panic_fmt::heb22169cb84960bf
12: 0x71576e03a86c - core::panicking::panic::ha8beb6a6485bc14d
13: 0x7157717689de - rustc_hir_analysis[bc190f9e45137b48]::check::check::check_item_type
14: 0x715771771a80 - rustc_hir_analysis[bc190f9e45137b48]::check::wfcheck::check_well_formed
15: 0x715771770963 - rustc_query_impl[fd26d931c9f411e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fd26d931c9f411e2]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 1usize]>>
16: 0x715771770405 - rustc_query_system[e99dca0ec3704a41]::query::plumbing::try_execute_query::<rustc_query_impl[fd26d931c9f411e2]::DynamicConfig<rustc_data_structures[53f175478fdd5634]::vec_cache::VecCache<rustc_span[b748a797078a6d67]::def_id::LocalDefId, rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[e99dca0ec3704a41]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[fd26d931c9f411e2]::plumbing::QueryCtxt, false>
17: 0x71577176fe81 - rustc_query_impl[fd26d931c9f411e2]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
18: 0x71577176d2ac - rustc_hir_analysis[bc190f9e45137b48]::check::wfcheck::check_mod_type_wf
19: 0x71577176d0cb - rustc_query_impl[fd26d931c9f411e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fd26d931c9f411e2]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 1usize]>>
20: 0x715771f80ec8 - rustc_query_system[e99dca0ec3704a41]::query::plumbing::try_execute_query::<rustc_query_impl[fd26d931c9f411e2]::DynamicConfig<rustc_query_system[e99dca0ec3704a41]::query::caches::DefaultCache<rustc_span[b748a797078a6d67]::def_id::LocalModDefId, rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fd26d931c9f411e2]::plumbing::QueryCtxt, false>
21: 0x715771f80c70 - rustc_query_impl[fd26d931c9f411e2]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
22: 0x715771217078 - rustc_hir_analysis[bc190f9e45137b48]::check_crate
23: 0x715771301de8 - rustc_interface[8e3e2112eb65afd0]::passes::run_required_analyses
24: 0x715771f45a1e - rustc_interface[8e3e2112eb65afd0]::passes::analysis
25: 0x715771f459ef - rustc_query_impl[fd26d931c9f411e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fd26d931c9f411e2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 0usize]>>
26: 0x715771fa18d5 - rustc_query_system[e99dca0ec3704a41]::query::plumbing::try_execute_query::<rustc_query_impl[fd26d931c9f411e2]::DynamicConfig<rustc_query_system[e99dca0ec3704a41]::query::caches::SingleCache<rustc_middle[f9e9d25ce9da1d13]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[fd26d931c9f411e2]::plumbing::QueryCtxt, false>
27: 0x715771fa160e - rustc_query_impl[fd26d931c9f411e2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
28: 0x715771ff1b1e - rustc_interface[8e3e2112eb65afd0]::passes::create_and_enter_global_ctxt::<core[5f45370c6fd7858f]::option::Option<rustc_interface[8e3e2112eb65afd0]::queries::Linker>, rustc_driver_impl[df7680cc67222e37]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
29: 0x715771fcc6d6 - rustc_interface[8e3e2112eb65afd0]::interface::run_compiler::<(), rustc_driver_impl[df7680cc67222e37]::run_compiler::{closure#0}>::{closure#1}
30: 0x715771e3b387 - std[502aa70c49e1fa42]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8e3e2112eb65afd0]::util::run_in_thread_with_globals<rustc_interface[8e3e2112eb65afd0]::util::run_in_thread_pool_with_globals<rustc_interface[8e3e2112eb65afd0]::interface::run_compiler<(), rustc_driver_impl[df7680cc67222e37]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
31: 0x715771e3b820 - <<std[502aa70c49e1fa42]::thread::Builder>::spawn_unchecked_<rustc_interface[8e3e2112eb65afd0]::util::run_in_thread_with_globals<rustc_interface[8e3e2112eb65afd0]::util::run_in_thread_pool_with_globals<rustc_interface[8e3e2112eb65afd0]::interface::run_compiler<(), rustc_driver_impl[df7680cc67222e37]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5f45370c6fd7858f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
32: 0x715771e3cdef - std::sys::pal::unix::thread::Thread::new::thread_start::hdb7432b4fd06676b
33: 0x71576c2a339d - <unknown>
34: 0x71576c32849c - <unknown>
35: 0x0 - <unknown>
error: 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: please make sure that you have updated to the latest nightly
note: rustc 1.86.0-nightly (252b07bba 2025-01-10) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [check_well_formed] checking that `S2Vec` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases
--> /tmp/icemaker_global_tempdir.zpUXb9piRFak/rustc_testrunner_tmpdir_reporting.TDveU8fCV8dR/mvce.rs:7:22
|
7 | type T5<U: Bound> = <_ as Bound>::Assoc;
| ^ not allowed in type signatures
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0121`.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.