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> {
5353 assert ! ( entry. is_some( ) ) ;
5454 }
5555
56- pub ( crate ) fn is_empty ( & self ) -> bool {
56+ pub fn is_empty ( & self ) -> bool {
5757 let OpaqueTypeStorage { opaque_types, duplicate_entries } = self ;
5858 opaque_types. is_empty ( ) && duplicate_entries. is_empty ( )
5959 }
Original file line number Diff line number Diff line change @@ -64,6 +64,16 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
6464 span : Span ,
6565 ) -> Option < Certainty > {
6666 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+
6777 if trait_pred. polarity ( ) == ty:: PredicatePolarity :: Positive {
6878 match self . 0 . tcx . as_lang_item ( trait_pred. def_id ( ) ) {
6979 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<_>> >>>>>>>>>>>>>>>>>>>>>`
22 --> $DIR/coherence-fulfill-overflow.rs:12:1
33 |
44LL | impl<T: ?Sized + TwoW> Trait for W<T> {}
55 | ------------------------------------- first implementation here
66LL | 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<_>>>>>>>>>>>>>>>>>>>>>>>`
118
129error: aborting due to 1 previous error
1310
You can’t perform that action at this time.
0 commit comments