Skip to content

Commit ef367ed

Browse files
committed
transmutability: Stall new solver when inference variables remain
1 parent 2972b5e commit ef367ed

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,9 @@ where
11741174
dst: I::Ty,
11751175
assume: I::Const,
11761176
) -> Result<Certainty, NoSolution> {
1177+
if src.has_non_region_infer() || dst.has_non_region_infer() {
1178+
return Ok(Certainty::AMBIGUOUS);
1179+
}
11771180
self.delegate.is_transmutable(dst, src, assume)
11781181
}
11791182

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(transmutability)]
2+
trait OpaqueTrait {}
3+
4+
impl<T: std::mem::TransmuteFrom<(), ()>> OpaqueTrait for T {}
5+
//~^ ERROR: type provided when a constant was expected
6+
7+
impl<T> OpaqueTrait for &T where T: OpaqueTrait {}
8+
//~^ ERROR: conflicting implementations of trait `OpaqueTrait` for type `&_`
9+
10+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0747]: type provided when a constant was expected
2+
--> $DIR/transmutability-coherence.rs:4:37
3+
|
4+
LL | impl<T: std::mem::TransmuteFrom<(), ()>> OpaqueTrait for T {}
5+
| ^^
6+
7+
error[E0119]: conflicting implementations of trait `OpaqueTrait` for type `&_`
8+
--> $DIR/transmutability-coherence.rs:7:1
9+
|
10+
LL | impl<T: std::mem::TransmuteFrom<(), ()>> OpaqueTrait for T {}
11+
| ---------------------------------------------------------- first implementation here
12+
...
13+
LL | impl<T> OpaqueTrait for &T where T: OpaqueTrait {}
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0119, E0747.
19+
For more information about an error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)