Skip to content

Commit 3b3dc7b

Browse files
committed
Account for #[rustc_reservation_impl] when pointing at potential impls
1 parent 6453722 commit 3b3dc7b

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19061906
// Ignore automatically derived impls and `!Trait` impls.
19071907
.filter_map(|def_id| self.tcx.impl_trait_header(def_id).map(|h| (h, def_id)))
19081908
.filter_map(|(header, def_id)| {
1909-
(header.polarity != ty::ImplPolarity::Negative
1909+
(header.polarity == ty::ImplPolarity::Positive
19101910
|| self.tcx.is_automatically_derived(def_id))
19111911
.then(|| (header.trait_ref.instantiate_identity(), def_id))
19121912
})

tests/ui/traits/reservation-impl/no-use.next.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied
33
|
44
LL | <() as MyTrait>::foo(&());
55
| ^^ the trait `MyTrait` is not implemented for `()`
6-
|
7-
help: the trait `MyTrait` is implemented for `()`
8-
--> $DIR/no-use.rs:8:1
9-
|
10-
LL | impl MyTrait for () { fn foo(&self) {} }
11-
| ^^^^^^^^^^^^^^^^^^^
126

137
error: aborting due to 1 previous error
148

tests/ui/traits/reservation-impl/no-use.old.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied
33
|
44
LL | <() as MyTrait>::foo(&());
55
| ^^ the trait `MyTrait` is not implemented for `()`
6-
|
7-
help: the trait `MyTrait` is implemented for `()`
8-
--> $DIR/no-use.rs:8:1
9-
|
10-
LL | impl MyTrait for () { fn foo(&self) {} }
11-
| ^^^^^^^^^^^^^^^^^^^
126

137
error: aborting due to 1 previous error
148

0 commit comments

Comments
 (0)