Skip to content

Commit 183ad51

Browse files
authored
Rollup merge of rust-lang#125865 - ajwock:ice_not_fully_resolved, r=fee1-dead
Fix ICE caused by ignoring EffectVars in type inference Fixes rust-lang#119830 ​r? ``@matthiaskrgr``
2 parents e68ab49 + 66a1386 commit 183ad51

File tree

5 files changed

+98
-11
lines changed

5 files changed

+98
-11
lines changed

compiler/rustc_infer/src/infer/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ pub enum FixupError {
587587
UnresolvedFloatTy(FloatVid),
588588
UnresolvedTy(TyVid),
589589
UnresolvedConst(ConstVid),
590+
UnresolvedEffect(EffectVid),
590591
}
591592

592593
/// See the `region_obligations` field for more information.
@@ -614,6 +615,7 @@ impl fmt::Display for FixupError {
614615
),
615616
UnresolvedTy(_) => write!(f, "unconstrained type"),
616617
UnresolvedConst(_) => write!(f, "unconstrained const value"),
618+
UnresolvedEffect(_) => write!(f, "unconstrained effect value"),
617619
}
618620
}
619621
}

compiler/rustc_infer/src/infer/resolve.rs

+3
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
167167
ty::ConstKind::Infer(InferConst::Fresh(_)) => {
168168
bug!("Unexpected const in full const resolver: {:?}", c);
169169
}
170+
ty::ConstKind::Infer(InferConst::EffectVar(evid)) => {
171+
return Err(FixupError::UnresolvedEffect(evid));
172+
}
170173
_ => {}
171174
}
172175
c.try_super_fold_with(self)

tests/crashes/119830.rs

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ check-fail
2+
// Fixes #119830
3+
4+
#![feature(effects)]
5+
#![feature(min_specialization)]
6+
#![feature(const_trait_impl)]
7+
8+
trait Specialize {}
9+
10+
trait Foo {}
11+
12+
impl<T> const Foo for T {}
13+
//~^ error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
14+
//~| error: the const parameter `host` is not constrained by the impl trait, self type, or predicates [E0207]
15+
16+
impl<T> const Foo for T where T: const Specialize {}
17+
//~^ error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
18+
//~| error: `const` can only be applied to `#[const_trait]` traits
19+
//~| error: the const parameter `host` is not constrained by the impl trait, self type, or predicates [E0207]
20+
//~| error: specialization impl does not specialize any associated items
21+
//~| error: could not resolve generic parameters on overridden impl
22+
23+
fn main() {
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
2+
--> $DIR/spec-effectvar-ice.rs:12:15
3+
|
4+
LL | trait Foo {}
5+
| - help: mark `Foo` as const: `#[const_trait]`
6+
LL |
7+
LL | impl<T> const Foo for T {}
8+
| ^^^
9+
|
10+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
11+
= note: adding a non-const method body in the future would be a breaking change
12+
13+
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
14+
--> $DIR/spec-effectvar-ice.rs:16:15
15+
|
16+
LL | trait Foo {}
17+
| - help: mark `Foo` as const: `#[const_trait]`
18+
...
19+
LL | impl<T> const Foo for T where T: const Specialize {}
20+
| ^^^
21+
|
22+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
23+
= note: adding a non-const method body in the future would be a breaking change
24+
25+
error: `const` can only be applied to `#[const_trait]` traits
26+
--> $DIR/spec-effectvar-ice.rs:16:40
27+
|
28+
LL | impl<T> const Foo for T where T: const Specialize {}
29+
| ^^^^^^^^^^
30+
31+
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
32+
--> $DIR/spec-effectvar-ice.rs:12:9
33+
|
34+
LL | impl<T> const Foo for T {}
35+
| ^^^^^ unconstrained const parameter
36+
|
37+
= note: expressions using a const parameter must map each value to a distinct output value
38+
= note: proving the result of expressions other than the parameter are unique is not supported
39+
40+
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
41+
--> $DIR/spec-effectvar-ice.rs:16:9
42+
|
43+
LL | impl<T> const Foo for T where T: const Specialize {}
44+
| ^^^^^ unconstrained const parameter
45+
|
46+
= note: expressions using a const parameter must map each value to a distinct output value
47+
= note: proving the result of expressions other than the parameter are unique is not supported
48+
49+
error: specialization impl does not specialize any associated items
50+
--> $DIR/spec-effectvar-ice.rs:16:1
51+
|
52+
LL | impl<T> const Foo for T where T: const Specialize {}
53+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
|
55+
note: impl is a specialization of this impl
56+
--> $DIR/spec-effectvar-ice.rs:12:1
57+
|
58+
LL | impl<T> const Foo for T {}
59+
| ^^^^^^^^^^^^^^^^^^^^^^^
60+
61+
error: could not resolve generic parameters on overridden impl
62+
--> $DIR/spec-effectvar-ice.rs:16:1
63+
|
64+
LL | impl<T> const Foo for T where T: const Specialize {}
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66+
67+
error: aborting due to 7 previous errors
68+
69+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)