-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
when running this code
fn main() {
println!("{}", 0u8.clamp(7,3))
}i get the following output
thread 'main' panicked at /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:1078:9:
assertion failed: min <= max
this is very unhelpful in any non-trivial codebase that uses this method.
this is a pretty niche error but it can happen.
something like
thread 'main' panicked at src/main.rs:3:20:
invalid clamp range : there are no numbers smaller than 7 and greater than 3
would be ideal, but any improvement would be good.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.