-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Do not error during method probe on Sized
predicates for types that aren't the method receiver
#99146
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
Do not error during method probe on Sized
predicates for types that aren't the method receiver
#99146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
pub trait Example { | ||
fn query<Q>(self, q: Q); | ||
} | ||
|
||
impl Example for i32 { | ||
fn query<Q>(self, _: Q) { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
mod nested { | ||
use super::Example; | ||
fn example() { | ||
1.query::<dyn ToString>("") | ||
//~^ ERROR the size for values of type `dyn ToString` cannot be known at compilation time | ||
//~| ERROR mismatched types | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error is actually more verbose than what it used to (erroneously) say before, but it's more consistent with an error you'd get if you, for example, passed any other DST as a generic arg. It also makes the second error, the mismatched types ( |
||
--> $DIR/issue-61525.rs:14:33 | ||
| | ||
LL | 1.query::<dyn ToString>("") | ||
| ----- ^^ doesn't have a size known at compile-time | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Sized` is not implemented for `dyn ToString` | ||
note: required by a bound in `Example::query` | ||
--> $DIR/issue-61525.rs:2:14 | ||
| | ||
LL | fn query<Q>(self, q: Q); | ||
| ^ required by this bound in `Example::query` | ||
help: consider relaxing the implicit `Sized` restriction | ||
| | ||
LL | fn query<Q: ?Sized>(self, q: Q); | ||
| ++++++++ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-61525.rs:14:33 | ||
| | ||
LL | 1.query::<dyn ToString>("") | ||
| --------------------- ^^ expected trait object `dyn ToString`, found `&str` | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected trait object `dyn ToString` | ||
found reference `&'static str` | ||
note: associated function defined here | ||
--> $DIR/issue-61525.rs:2:8 | ||
| | ||
LL | fn query<Q>(self, q: Q); | ||
| ^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0308. | ||
For more information about an error, try `rustc --explain E0277`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you're right. not super familiar with the tracing macros, sorry😅