Closed
Description
split from #70167
comment by @eddyb
Alternatively, instead of using
path.res
to get theDefId
, maybe we could use theRes
olution from the segment we found the const parameter in?
I believe nowadays we have per-segment resolutions, which would avoid breaking GATs in the future.Actually, I expect
Struct::<N>::method::<M>()
is also broken, let's try it... Yupp: (playground)#![feature(const_generics)] struct Struct<const N: usize>; impl<const N: usize> Struct<N> { fn method<const M: usize>(&self) {} } fn test<const N: usize, const M: usize>(x: Struct<N>) { Struct::<N>::method::<M>(&x); x.method::<N>(); }EDIT: took a second look and that
M
is in aQPath::TypeRelative
, which has to be resolved by the body oftest
, which means it's as bad as the method call form (which I just added).Maybe we should disallow passing explicit generic args to methods for now?
Since I have no idea how one would figure out the expected type.
This fails with
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> src/lib.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
error: internal compiler error: unexpected const parent path Expr(expr(HirId { owner: DefId(0:10 ~ playground[eddc]::test[0]), local_id: 12 }: Struct<>::method::<>))
error: internal compiler error: unexpected const parent in type_of_def_id(): Expr(expr(HirId { owner: DefId(0:10 ~ playground[eddc]::test[0]), local_id: 24 }: x.method::<>()))
error: internal compiler error: mir_const_qualif: MIR had errors
--> src/lib.rs:10:27
|
10 | Struct::<N>::method::<M>(&x);
| ^
error: internal compiler error: PromoteTemps: MIR had errors
--> src/lib.rs:10:27
|
10 | Struct::<N>::method::<M>(&x);
| ^
error: internal compiler error: broken MIR in DefId(0:15 ~ playground[eddc]::test[0]::{{constant}}[1]) ("return type"): bad type [type error]
--> src/lib.rs:10:27
|
10 | Struct::<N>::method::<M>(&x);
| ^
error: internal compiler error: broken MIR in DefId(0:15 ~ playground[eddc]::test[0]::{{constant}}[1]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src/lib.rs:10:27: 10:28, scope: scope[0] } }): bad type [type error]
--> src/lib.rs:10:27
|
10 | Struct::<N>::method::<M>(&x);
| ^
error: internal compiler error: mir_const_qualif: MIR had errors
--> src/lib.rs:11:16
|
11 | x.method::<N>();
| ^
error: internal compiler error: PromoteTemps: MIR had errors
--> src/lib.rs:11:16
|
11 | x.method::<N>();
| ^
error: internal compiler error: broken MIR in DefId(0:16 ~ playground[eddc]::test[0]::{{constant}}[2]) ("return type"): bad type [type error]
--> src/lib.rs:11:16
|
11 | x.method::<N>();
| ^
error: internal compiler error: broken MIR in DefId(0:16 ~ playground[eddc]::test[0]::{{constant}}[2]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src/lib.rs:11:16: 11:17, scope: scope[0] } }): bad type [type error]
--> src/lib.rs:11:16
|
11 | x.method::<N>();
| ^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.44.0-nightly (1057dc97a 2020-03-20) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: could not compile `playground`.
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.`#![feature(const_generics)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.