Closed
Description
Code
trait Tr {
type Item;
}
type A2 = dyn for<'a> Tr + ?foo(b);
fn main() {}
Original Code (Fuzzing)
trait Tr: ?Sized {
type Item = &usize;
//~^ ERROR 18:17: 18:18: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
fn poke(&mut self, item: Self::Item) {
self += *item;
}
}
//~^ ERROR `?Trait` is not permitted in supertraits
type A1 = dyn Tr + (?Sized);
//~^ ERROR `?Trait` is not permitted in trait object types
type A2 = dyn for<'adds_bnd> Tr + (?simd_fexp2(a));
//~^ ERROR `?Trait` is not permitted in trait object types
fn main() {}
// /root/workspace/seeds_250219/tests/ui/maybe-bounds.rs
Meta
rustc --version --verbose
:
rustc 1.87.0-nightly (f8a913b13 2025-02-23)
binary: rustc
commit-hash: f8a913b1381e90379c7ca63ac2b88b9518936628
commit-date: 2025-02-23
host: x86_64-apple-darwin
release: 1.87.0-nightly
LLVM version: 20.1.0
Error output
error[E0658]: `?Trait` is not permitted in trait object types
--> 05C5.rs:5:28
|
5 | type A2 = dyn for<'a> Tr + ?foo(b);
| ^^^^^^^
|
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
= note: this compiler was built on 2025-02-23; consider upgrading it if it is out of date
error[E0405]: cannot find trait `foo` in this scope
--> 05C5.rs:5:29
|
5 | type A2 = dyn for<'a> Tr + ?foo(b);
| ^^^ not found in this scope
error[E0412]: cannot find type `b` in this scope
--> 05C5.rs:5:33
|
5 | type A2 = dyn for<'a> Tr + ?foo(b);
| ^ not found in this scope
thread 'rustc' panicked at /rustc/f8a913b1381e90379c7ca63ac2b88b9518936628/compiler/rustc_hir/src/def.rs:683:45:
attempted .def_id() on invalid res: Err
Backtrace
thread 'rustc' panicked at /rustc/f8a913b1381e90379c7ca63ac2b88b9518936628/compiler/rustc_hir/src/def.rs:683:45:
attempted .def_id() on invalid res: Err
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::check_for_required_assoc_tys
3: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty
4: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
5: rustc_hir_analysis::collect::type_of::type_of
[... omitted 1 frame ...]
6: rustc_hir_analysis::collect::lower_item
7: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
8: rustc_hir_analysis::check::wfcheck::check_item
9: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
10: <rustc_middle::hir::ModuleItems>::par_opaques::<rustc_hir_analysis::check::wfcheck::check_mod_type_wf::{closure#4}>::{closure#0}
11: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
12: rustc_hir_analysis::check_crate
13: rustc_interface::passes::run_required_analyses
14: rustc_interface::passes::analysis
[... omitted 1 frame ...]
15: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
16: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please attach the file at `/Volumes/T7/workspace/250224 scratch/codes/rustc-ice-2025-02-24T05_09_01-67498.txt` to your bug report
query stack during panic:
#0 [type_of] expanding type alias `A2`
#1 [check_well_formed] checking that `A2` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0405, E0412, E0658.
For more information about an error, try `rustc --explain E0405`.
Notes
- ICE location:
compiler/rustc_hir/src/def.rs Line-683
rust/compiler/rustc_hir/src/def.rs
Lines 677 to 684 in f8a913b