File tree 4 files changed +54
-9
lines changed
compiler/rustc_trait_selection/src/traits/specialize
tests/ui/traits/negative-impls
4 files changed +54
-9
lines changed Original file line number Diff line number Diff line change @@ -483,15 +483,19 @@ fn report_negative_positive_conflict<'tcx>(
483
483
negative_impl_def_id : DefId ,
484
484
positive_impl_def_id : DefId ,
485
485
) -> ErrorGuaranteed {
486
- tcx. dcx ( )
487
- . create_err ( NegativePositiveConflict {
488
- impl_span : tcx. def_span ( local_impl_def_id) ,
489
- trait_desc : overlap. trait_ref ,
490
- self_ty : overlap. self_ty ,
491
- negative_impl_span : tcx. span_of_impl ( negative_impl_def_id) ,
492
- positive_impl_span : tcx. span_of_impl ( positive_impl_def_id) ,
493
- } )
494
- . emit ( )
486
+ let mut diag = tcx. dcx ( ) . create_err ( NegativePositiveConflict {
487
+ impl_span : tcx. def_span ( local_impl_def_id) ,
488
+ trait_desc : overlap. trait_ref ,
489
+ self_ty : overlap. self_ty ,
490
+ negative_impl_span : tcx. span_of_impl ( negative_impl_def_id) ,
491
+ positive_impl_span : tcx. span_of_impl ( positive_impl_def_id) ,
492
+ } ) ;
493
+
494
+ for cause in & overlap. intercrate_ambiguity_causes {
495
+ cause. add_intercrate_ambiguity_hint ( & mut diag) ;
496
+ }
497
+
498
+ diag. emit ( )
495
499
}
496
500
497
501
fn report_conflicting_impls < ' tcx > (
Original file line number Diff line number Diff line change
1
+ error[E0119]: conflicting implementations of trait `MyTrait` for type `String`
2
+ --> $DIR/ambiguity-cause.rs:10:1
3
+ |
4
+ LL | impl<T: Copy> MyTrait for T { }
5
+ | --------------------------- first implementation here
6
+ LL |
7
+ LL | impl MyTrait for String { }
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `String`
9
+ |
10
+ = note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::string::String` in future versions
11
+
12
+ error: aborting due to 1 previous error
13
+
14
+ For more information about this error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
1
+ //@ revisions: simple negative_coherence
2
+
3
+ #![ feature( negative_impls) ]
4
+ #![ cfg_attr( negative_coherence, feature( with_negative_coherence) ) ]
5
+
6
+ trait MyTrait { }
7
+
8
+ impl < T : Copy > MyTrait for T { }
9
+
10
+ impl MyTrait for String { }
11
+ //~^ ERROR conflicting implementations of trait `MyTrait` for type `String`
12
+
13
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0119]: conflicting implementations of trait `MyTrait` for type `String`
2
+ --> $DIR/ambiguity-cause.rs:10:1
3
+ |
4
+ LL | impl<T: Copy> MyTrait for T { }
5
+ | --------------------------- first implementation here
6
+ LL |
7
+ LL | impl MyTrait for String { }
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `String`
9
+ |
10
+ = note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::string::String` in future versions
11
+
12
+ error: aborting due to 1 previous error
13
+
14
+ For more information about this error, try `rustc --explain E0119`.
You can’t perform that action at this time.
0 commit comments