Rollup merge of #125792 - compiler-errors:dont-drop-upcast-cand, r=lcnr
Don't drop `Unsize` candidate in intercrate mode Fixes #125767
This commit is contained in:
commit
e1745122ae
@ -921,6 +921,12 @@ fn need_migrate_deref_output_trait_object(
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
) -> Option<ty::PolyExistentialTraitRef<'tcx>> {
|
||||
// Don't drop any candidates in intercrate mode, as it's incomplete.
|
||||
// (Not that it matters, since `Unsize` is not a stable trait.)
|
||||
if self.infcx.intercrate {
|
||||
return None;
|
||||
}
|
||||
|
||||
let tcx = self.tcx();
|
||||
if tcx.features().trait_upcasting {
|
||||
return None;
|
||||
|
13
tests/ui/specialization/dont-drop-upcast-candidate.rs
Normal file
13
tests/ui/specialization/dont-drop-upcast-candidate.rs
Normal file
@ -0,0 +1,13 @@
|
||||
#![feature(unsize)]
|
||||
|
||||
use std::marker::Unsize;
|
||||
use std::ops::Deref;
|
||||
|
||||
trait Foo: Bar {}
|
||||
trait Bar {}
|
||||
|
||||
impl<T> Bar for T where dyn Foo: Unsize<dyn Bar> {}
|
||||
impl Bar for () {}
|
||||
//~^ ERROR conflicting implementations of trait `Bar` for type `()`
|
||||
|
||||
fn main() {}
|
11
tests/ui/specialization/dont-drop-upcast-candidate.stderr
Normal file
11
tests/ui/specialization/dont-drop-upcast-candidate.stderr
Normal file
@ -0,0 +1,11 @@
|
||||
error[E0119]: conflicting implementations of trait `Bar` for type `()`
|
||||
--> $DIR/dont-drop-upcast-candidate.rs:10:1
|
||||
|
|
||||
LL | impl<T> Bar for T where dyn Foo: Unsize<dyn Bar> {}
|
||||
| ------------------------------------------------ first implementation here
|
||||
LL | impl Bar for () {}
|
||||
| ^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
Loading…
Reference in New Issue
Block a user