File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
rustc_infer/src/infer/opaque_types
rustc_trait_selection/src/solve
tests/ui/traits/next-solver/coherence Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
53
53
assert ! ( entry. is_some( ) ) ;
54
54
}
55
55
56
- pub ( crate ) fn is_empty ( & self ) -> bool {
56
+ pub fn is_empty ( & self ) -> bool {
57
57
let OpaqueTypeStorage { opaque_types, duplicate_entries } = self ;
58
58
opaque_types. is_empty ( ) && duplicate_entries. is_empty ( )
59
59
}
Original file line number Diff line number Diff line change @@ -64,6 +64,16 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
64
64
span : Span ,
65
65
) -> Option < Certainty > {
66
66
if let Some ( trait_pred) = goal. predicate . as_trait_clause ( ) {
67
+ if self . shallow_resolve ( trait_pred. self_ty ( ) . skip_binder ( ) ) . is_ty_var ( )
68
+ // We don't do this fast path when opaques are defined since we may
69
+ // eventually use opaques to incompletely guide inference via ty var
70
+ // self types.
71
+ // FIXME: Properly consider opaques here.
72
+ && self . inner . borrow_mut ( ) . opaque_types ( ) . is_empty ( )
73
+ {
74
+ return Some ( Certainty :: AMBIGUOUS ) ;
75
+ }
76
+
67
77
if trait_pred. polarity ( ) == ty:: PredicatePolarity :: Positive {
68
78
match self . 0 . tcx . as_lang_item ( trait_pred. def_id ( ) ) {
69
79
Some ( LangItem :: Sized )
Original file line number Diff line number Diff line change 1
- error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_ >>>>>>>>>>>>>>>>>>>>>`
1
+ error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>> >>>>>>>>>>>>>>>>>>>>>`
2
2
--> $DIR/coherence-fulfill-overflow.rs:12:1
3
3
|
4
4
LL | impl<T: ?Sized + TwoW> Trait for W<T> {}
5
5
| ------------------------------------- first implementation here
6
6
LL | impl<T: ?Sized + TwoW> Trait for T {}
7
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>`
8
- |
9
- = note: overflow evaluating the requirement `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>: TwoW`
10
- = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`coherence_fulfill_overflow`)
7
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>`
11
8
12
9
error: aborting due to 1 previous error
13
10
You can’t perform that action at this time.
0 commit comments