-
Notifications
You must be signed in to change notification settings - Fork 13.4k
improve pretty printing for associated items in trait objects #120739
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
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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,31 @@ | ||
// Test for pretty-printing trait object types. | ||
|
||
trait Super { | ||
type Assoc; | ||
} | ||
trait Any: Super {} | ||
trait Fixed: Super<Assoc = u8> {} | ||
trait FixedSub: Fixed {} | ||
|
||
trait SuperGeneric<'a> { | ||
type Assoc; | ||
} | ||
trait AnyGeneric<'a>: SuperGeneric<'a> {} | ||
trait FixedGeneric1<'a>: SuperGeneric<'a, Assoc = &'a u8> {} | ||
trait FixedGeneric2<'a>: Super<Assoc = &'a u8> {} | ||
trait FixedHrtb: for<'a> SuperGeneric<'a, Assoc = &'a u8> {} | ||
|
||
fn dyn_super(x: &dyn Super<Assoc = u8>) { x } //~ERROR mismatched types | ||
fn dyn_any(x: &dyn Any<Assoc = u8>) { x } //~ERROR mismatched types | ||
fn dyn_fixed(x: &dyn Fixed) { x } //~ERROR mismatched types | ||
fn dyn_fixed_multi(x: &dyn Fixed<Assoc = u16>) { x } //~ERROR mismatched types | ||
fn dyn_fixed_sub(x: &dyn FixedSub) { x } //~ERROR mismatched types | ||
|
||
fn dyn_super_generic(x: &dyn for<'a> SuperGeneric<'a, Assoc = &'a u8>) { x } //~ERROR mismatched types | ||
fn dyn_any_generic(x: &dyn for<'a> AnyGeneric<'a, Assoc = &'a u8>) { x } //~ERROR mismatched types | ||
fn dyn_fixed_generic1(x: &dyn for<'a> FixedGeneric1<'a>) { x } //~ERROR mismatched types | ||
fn dyn_fixed_generic2(x: &dyn for<'a> FixedGeneric2<'a>) { x } //~ERROR mismatched types | ||
fn dyn_fixed_generic_multi(x: &dyn for<'a> FixedGeneric1<'a, Assoc = &u8>) { x } //~ERROR mismatched types | ||
fn dyn_fixed_hrtb(x: &dyn FixedHrtb) { x } //~ERROR mismatched types | ||
|
||
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,124 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:18:43 | ||
| | ||
LL | fn dyn_super(x: &dyn Super<Assoc = u8>) { x } | ||
| - ^ expected `()`, found `&dyn Super<Assoc = u8>` | ||
| | | ||
| help: try adding a return type: `-> &dyn Super<Assoc = u8>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn Super<Assoc = u8>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:19:39 | ||
| | ||
LL | fn dyn_any(x: &dyn Any<Assoc = u8>) { x } | ||
| - ^ expected `()`, found `&dyn Any<Assoc = u8>` | ||
| | | ||
| help: try adding a return type: `-> &dyn Any<Assoc = u8>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn Any<Assoc = u8>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:20:31 | ||
| | ||
LL | fn dyn_fixed(x: &dyn Fixed) { x } | ||
| - ^ expected `()`, found `&dyn Fixed` | ||
| | | ||
| help: try adding a return type: `-> &dyn Fixed` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn Fixed` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:21:50 | ||
| | ||
LL | fn dyn_fixed_multi(x: &dyn Fixed<Assoc = u16>) { x } | ||
| - ^ expected `()`, found `&dyn Fixed<Assoc = u16>` | ||
| | | ||
| help: try adding a return type: `-> &dyn Fixed<Assoc = u16>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn Fixed<Assoc = u16>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:22:38 | ||
| | ||
LL | fn dyn_fixed_sub(x: &dyn FixedSub) { x } | ||
| - ^ expected `()`, found `&dyn FixedSub` | ||
| | | ||
| help: try adding a return type: `-> &dyn FixedSub` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn FixedSub` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:24:74 | ||
| | ||
LL | fn dyn_super_generic(x: &dyn for<'a> SuperGeneric<'a, Assoc = &'a u8>) { x } | ||
| - ^ expected `()`, found `&dyn SuperGeneric<'a, Assoc = &u8>` | ||
| | | ||
| help: try adding a return type: `-> &dyn for<'a> SuperGeneric<'a, Assoc = &'a u8>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn for<'a> SuperGeneric<'a, Assoc = &'a u8>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:25:70 | ||
| | ||
LL | fn dyn_any_generic(x: &dyn for<'a> AnyGeneric<'a, Assoc = &'a u8>) { x } | ||
| - ^ expected `()`, found `&dyn AnyGeneric<'a, Assoc = &u8>` | ||
| | | ||
| help: try adding a return type: `-> &dyn for<'a> AnyGeneric<'a, Assoc = &'a u8>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn for<'a> AnyGeneric<'a, Assoc = &'a u8>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:26:60 | ||
| | ||
LL | fn dyn_fixed_generic1(x: &dyn for<'a> FixedGeneric1<'a>) { x } | ||
| - ^ expected `()`, found `&dyn FixedGeneric1<'a>` | ||
| | | ||
| help: try adding a return type: `-> &dyn for<'a> FixedGeneric1<'a>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn for<'a> FixedGeneric1<'a>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:27:60 | ||
| | ||
LL | fn dyn_fixed_generic2(x: &dyn for<'a> FixedGeneric2<'a>) { x } | ||
| - ^ expected `()`, found `&dyn FixedGeneric2<'a>` | ||
| | | ||
| help: try adding a return type: `-> &dyn for<'a> FixedGeneric2<'a>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn for<'a> FixedGeneric2<'a>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:28:78 | ||
| | ||
LL | fn dyn_fixed_generic_multi(x: &dyn for<'a> FixedGeneric1<'a, Assoc = &u8>) { x } | ||
| - ^ expected `()`, found `&dyn FixedGeneric1<'a, Assoc = &u8>` | ||
| | | ||
| help: try adding a return type: `-> &dyn for<'a> FixedGeneric1<'a, Assoc = &u8>` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn for<'a> FixedGeneric1<'a, Assoc = &u8>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/pretty.rs:29:40 | ||
| | ||
LL | fn dyn_fixed_hrtb(x: &dyn FixedHrtb) { x } | ||
| - ^ expected `()`, found `&dyn FixedHrtb` | ||
| | | ||
| help: try adding a return type: `-> &dyn FixedHrtb` | ||
| | ||
= note: expected unit type `()` | ||
found reference `&dyn FixedHrtb` | ||
|
||
error: aborting due to 11 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
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
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.