Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] backports #72054

Merged
merged 19 commits into from
May 11, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix error code for E0751
contrun authored and Mark-Simulacrum committed May 9, 2020
commit ac64f87dba09cf257436d8ed12ad2a5fe1a0a900
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0751.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ There are both a positive and negative trait implementation for the same type.

Erroneous code example:

```compile_fail,E0748
```compile_fail,E0751
trait MyTrait {}
impl MyTrait for i32 { }
impl !MyTrait for i32 { }
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/traits/specialize/mod.rs
Original file line number Diff line number Diff line change
@@ -345,7 +345,7 @@ fn report_negative_positive_conflict(
let mut err = struct_span_err!(
tcx.sess,
impl_span,
E0748,
E0751,
"found both positive and negative implementation of trait `{}`{}:",
overlap.trait_desc,
overlap.self_desc.clone().map_or(String::new(), |ty| format!(" for type `{}`", ty))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`:
error[E0751]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`:
--> $DIR/coherence-conflicting-negative-trait-impl.rs:11:1
|
LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
@@ -18,5 +18,5 @@ LL | unsafe impl<T: 'static> Send for TestType<T> {}

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0119, E0748.
Some errors have detailed explanations: E0119, E0751.
For more information about an error, try `rustc --explain E0119`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-33140-hack-boundaries.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ trait Trait2 {}

impl Trait2 for dyn Send {}
impl !Trait2 for dyn Send {}
//~^ ERROR E0748
//~^ ERROR E0751

// Problem 3: type parameter
trait Trait3<T: ?Sized> {}
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-33140-hack-boundaries.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | impl Trait1 for dyn Send {}
LL | impl Trait1 for dyn Send {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)`

error[E0748]: found both positive and negative implementation of trait `Trait2` for type `(dyn std::marker::Send + 'static)`:
error[E0751]: found both positive and negative implementation of trait `Trait2` for type `(dyn std::marker::Send + 'static)`:
--> $DIR/issue-33140-hack-boundaries.rs:25:1
|
LL | impl Trait2 for dyn Send {}
@@ -64,5 +64,5 @@ LL | impl Trait5 for dyn Send where u32: Copy {}

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0119, E0748.
Some errors have detailed explanations: E0119, E0751.
For more information about an error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ trait MyTrait {}
struct TestType<T>(::std::marker::PhantomData<T>);

unsafe impl<T: Clone> Send for TestType<T> {}
impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR E0748
impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR E0751

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`:
error[E0751]: found both positive and negative implementation of trait `std::marker::Send` for type `TestType<_>`:
--> $DIR/specialization-overlap-negative.rs:9:1
|
LL | unsafe impl<T: Clone> Send for TestType<T> {}
@@ -8,4 +8,4 @@ LL | impl<T: MyTrait> !Send for TestType<T> {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
4 changes: 2 additions & 2 deletions src/test/ui/specialization/specialization-polarity.rs
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@
auto trait Foo {}

impl<T> Foo for T {}
impl !Foo for u8 {} //~ ERROR E0748
impl !Foo for u8 {} //~ ERROR E0751

auto trait Bar {}

impl<T> !Bar for T {}
impl Bar for u8 {} //~ ERROR E0748
impl Bar for u8 {} //~ ERROR E0751

fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/specialization/specialization-polarity.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0748]: found both positive and negative implementation of trait `Foo` for type `u8`:
error[E0751]: found both positive and negative implementation of trait `Foo` for type `u8`:
--> $DIR/specialization-polarity.rs:10:1
|
LL | impl<T> Foo for T {}
| ----------------- positive implementation here
LL | impl !Foo for u8 {}
| ^^^^^^^^^^^^^^^^ negative implementation here

error[E0748]: found both positive and negative implementation of trait `Bar` for type `u8`:
error[E0751]: found both positive and negative implementation of trait `Bar` for type `u8`:
--> $DIR/specialization-polarity.rs:15:1
|
LL | impl<T> !Bar for T {}
@@ -16,4 +16,4 @@ LL | impl Bar for u8 {}

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
Original file line number Diff line number Diff line change
@@ -8,6 +8,6 @@ trait MyTrait {
impl<T> MyTrait for T {
default fn foo() {}
}
impl !MyTrait for u32 {} //~ ERROR E0748
impl !MyTrait for u32 {} //~ ERROR E0751

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
error[E0751]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
--> $DIR/negative-specializes-positive-item.rs:11:1
|
LL | impl<T> MyTrait for T {
@@ -9,4 +9,4 @@ LL | impl !MyTrait for u32 {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
// Negative impl for u32 cannot "specialize" the base impl.
trait MyTrait {}
impl<T> MyTrait for T {}
impl !MyTrait for u32 {} //~ ERROR E0748
impl !MyTrait for u32 {} //~ ERROR E0751

// The second impl specializes the first, no error.
trait MyTrait2 {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
error[E0751]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
--> $DIR/negative-specializes-positive.rs:7:1
|
LL | impl<T> MyTrait for T {}
@@ -8,4 +8,4 @@ LL | impl !MyTrait for u32 {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use std::pin::Pin;
struct MyType<'a>(Cell<Option<&'a mut MyType<'a>>>, PhantomPinned);

impl<'a> Clone for &'a mut MyType<'a> {
//~^ ERROR E0748
//~^ ERROR E0751
fn clone(&self) -> &'a mut MyType<'a> {
self.0.replace(None).unwrap()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `std::clone::Clone` for type `&mut MyType<'_>`:
error[E0751]: found both positive and negative implementation of trait `std::clone::Clone` for type `&mut MyType<'_>`:
--> $DIR/pin-unsound-issue-66544-clone.rs:7:1
|
LL | impl<'a> Clone for &'a mut MyType<'a> {
@@ -8,4 +8,4 @@ LL | impl<'a> Clone for &'a mut MyType<'a> {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use std::pin::Pin;
struct MyType<'a>(Cell<Option<&'a mut MyType<'a>>>, PhantomPinned);

impl<'a> DerefMut for &'a MyType<'a> {
//~^ ERROR E0748
//~^ ERROR E0751
fn deref_mut(&mut self) -> &mut MyType<'a> {
self.0.replace(None).unwrap()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `std::ops::DerefMut` for type `&MyType<'_>`:
error[E0751]: found both positive and negative implementation of trait `std::ops::DerefMut` for type `&MyType<'_>`:
--> $DIR/pin-unsound-issue-66544-derefmut.rs:12:1
|
LL | impl<'a> DerefMut for &'a MyType<'a> {
@@ -8,4 +8,4 @@ LL | impl<'a> DerefMut for &'a MyType<'a> {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@
trait MyTrait {}

impl<T> !MyTrait for T {}
impl MyTrait for u32 {} //~ ERROR E0748
impl MyTrait for u32 {} //~ ERROR E0751

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0748]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
error[E0751]: found both positive and negative implementation of trait `MyTrait` for type `u32`:
--> $DIR/positive-specializes-negative.rs:7:1
|
LL | impl<T> !MyTrait for T {}
@@ -8,4 +8,4 @@ LL | impl MyTrait for u32 {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0748`.
For more information about this error, try `rustc --explain E0751`.