- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
fn main() { let _ = std::mem::size_of::<[i32]>(); }
Current output
312 | pub const fn size_of<T>() -> usize { | ^ required by this bound in `size_of`
The "this bound" doesn't actually point to a bound.
Desired output
Instead of "required by this bound"/"unsatisfied trait bound introduced here" we should say "note: T
has an implicit bound of Sized
"
Rationale and extra context
No response
Other cases
trait Foo { const VAL: usize; } impl<T> Foo for T { const VAL: usize = std::mem::size_of::<T>(); } fn main() { println!("{}", <[i32] as Foo>::VAL); }
Produces:
5 | impl<T> Foo for T { | - ^^^ ^ | | | unsatisfied trait bound introduced here
Rust Version
rustc 1.75.0 (82e1608df 2023-12-21) binary: rustc commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112 commit-date: 2023-12-21 host: x86_64-unknown-linux-gnu release: 1.75.0 LLVM version: 17.0.6
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.