-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -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 comment
The 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 (""
against dyn ToString
) not be suppressed any longer, which IMO is better.
@bors r+ |
Do not error during method probe on `Sized` predicates for types that aren't the method receiver Fixes rust-lang#61525 This is safe even though we're skipping an error because we end up confirming the method, which means we're still checking the `Sized` predicate in the end. It just means that we don't emit an erroneous message as below: ``` error: the `query` method cannot be invoked on a trait object --> src/lib.rs:14:11 | 14 | 1.query::<dyn ToString>("") | ^^^^^ | = note: another candidate was found in the following trait, perhaps add a `use` for it: `use crate::Example;` ``` Also fixes erroneously suggesting the same trait over again, as seen in the `issue-35976.rs` UI test.
Do not error during method probe on `Sized` predicates for types that aren't the method receiver Fixes rust-lang#61525 This is safe even though we're skipping an error because we end up confirming the method, which means we're still checking the `Sized` predicate in the end. It just means that we don't emit an erroneous message as below: ``` error: the `query` method cannot be invoked on a trait object --> src/lib.rs:14:11 | 14 | 1.query::<dyn ToString>("") | ^^^^^ | = note: another candidate was found in the following trait, perhaps add a `use` for it: `use crate::Example;` ``` Also fixes erroneously suggesting the same trait over again, as seen in the `issue-35976.rs` UI test.
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#97210 (Support `-A`, `-W`, `-D` and `-F` when running `./x.py clippy`) - rust-lang#99055 (Fix rustdoc help options) - rust-lang#99075 (Fix duplicated type annotation suggestion) - rust-lang#99124 (Fix sized check ICE in asm check) - rust-lang#99142 (fix(doctest): treat fatal parse errors as incomplete attributes) - rust-lang#99145 (Don't rerun the build script for the compiler each time on non-windows platforms) - rust-lang#99146 (Do not error during method probe on `Sized` predicates for types that aren't the method receiver) - rust-lang#99161 (compiletest: trim edition before passing as flag) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@@ -81,11 +81,25 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { | |||
let rcvr_substs = self.fresh_receiver_substs(self_ty, &pick); | |||
let all_substs = self.instantiate_method_substs(&pick, segment, rcvr_substs); | |||
|
|||
debug!("all_substs={:?}", all_substs); | |||
debug!("rcvr_substs={rcvr_substs:?}, all_substs={all_substs:?}"); |
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
debug!(?rcvr_substs, ?all_substs);
?
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😅
Fixes #61525
This is safe even though we're skipping an error because we end up confirming the method, which means we're still checking the
Sized
predicate in the end. It just means that we don't emit an erroneous message as below:Also fixes erroneously suggesting the same trait over again, as seen in the
issue-35976.rs
UI test.