-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Test that we require implementing trait items whose bounds don't hold in the current impl #112929
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
Merged
bors
merged 1 commit into
rust-lang:master
from
oli-obk:what_if_an_impl_item_just_doesnt_wanna_be_impld
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub trait Trait {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub trait Trait {} | ||
|
||
impl Trait for () {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//! This test checks that we do need to implement | ||
//! all members, even if their where bounds only hold | ||
//! due to other impls. | ||
|
||
trait Foo<T> { | ||
fn foo() | ||
where | ||
Self: Foo<()>; | ||
} | ||
|
||
impl Foo<()> for () { | ||
fn foo() {} | ||
} | ||
|
||
impl Foo<u32> for () {} | ||
//~^ ERROR: not all trait items implemented, missing: `foo` | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl.rs:15:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: Foo<()>; | ||
| |______________________- `foo` from trait | ||
... | ||
LL | impl Foo<u32> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! This test checks that we currently need to implement | ||
//! members, even if their where bounds don't hold for the impl type. | ||
|
||
trait Foo<T> { | ||
fn foo() | ||
where | ||
Self: Foo<()>; | ||
} | ||
|
||
impl Foo<u32> for () {} | ||
//~^ ERROR: not all trait items implemented, missing: `foo` | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl2.rs:10:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: Foo<()>; | ||
| |______________________- `foo` from trait | ||
... | ||
LL | impl Foo<u32> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! Check that we don't break orphan rules. | ||
//! The dependency may add an impl for `u8` later, | ||
//! which would break this crate. We want to avoid adding | ||
//! more ways in which adding an impl can be a breaking change. | ||
|
||
// aux-build:trivial3.rs | ||
|
||
extern crate trivial3; | ||
|
||
pub trait Foo { | ||
fn foo() | ||
where | ||
Self: trivial3::Trait; | ||
} | ||
|
||
impl Foo for u8 {} | ||
//~^ ERROR not all trait items implemented, missing: `foo` | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl3.rs:16:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: trivial3::Trait; | ||
| |______________________________- `foo` from trait | ||
... | ||
LL | impl Foo for u8 {} | ||
| ^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Check that we don't break orphan rules. | ||
//! The dependency may add an impl for `u8` later, | ||
//! which would break this crate. We want to avoid adding | ||
//! more ways in which adding an impl can be a breaking change. | ||
//! This test differs from `trivial_impl3` because there actually | ||
//! exists any impl for `Trait`, which has an effect on coherence. | ||
|
||
// aux-build:trivial4.rs | ||
|
||
extern crate trivial4; | ||
|
||
pub trait Foo { | ||
fn foo() | ||
where | ||
Self: trivial4::Trait; | ||
} | ||
|
||
impl Foo for u8 {} | ||
//~^ ERROR not all trait items implemented, missing: `foo` | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl4.rs:18:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: trivial4::Trait; | ||
| |______________________________- `foo` from trait | ||
... | ||
LL | impl Foo for u8 {} | ||
| ^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! This test checks that we currently need to implement | ||
//! members, even if their where bounds don't hold for the impl type. | ||
|
||
trait Foo { | ||
fn foo() | ||
where | ||
Self: Sized; | ||
} | ||
|
||
impl Foo for () { | ||
fn foo() {} | ||
} | ||
|
||
// Must not be allowed | ||
impl Foo for i32 {} | ||
//~^ ERROR: not all trait items implemented, missing: `foo` | ||
|
||
// Should be allowed | ||
impl Foo for dyn std::fmt::Debug {} | ||
//~^ ERROR: not all trait items implemented, missing: `foo` | ||
|
||
impl Foo for dyn std::fmt::Display { | ||
fn foo() {} | ||
} | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl_sized.rs:15:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: Sized; | ||
| |____________________- `foo` from trait | ||
... | ||
LL | impl Foo for i32 {} | ||
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error[E0046]: not all trait items implemented, missing: `foo` | ||
--> $DIR/trivial_impl_sized.rs:19:1 | ||
| | ||
LL | / fn foo() | ||
LL | | where | ||
LL | | Self: Sized; | ||
| |____________________- `foo` from trait | ||
... | ||
LL | impl Foo for dyn std::fmt::Debug {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.