-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Improve CTFE UB validation error messages #86275
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
Changes from 2 commits
87ecf84
b877240
19fddc0
5af1c72
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 |
|---|---|---|
|
|
@@ -26,23 +26,27 @@ use super::{ | |
|
|
||
| macro_rules! throw_validation_failure { | ||
| ($where:expr, { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )?) => {{ | ||
| let msg = rustc_middle::ty::print::with_no_trimmed_paths(|| { | ||
| let (path, msg) = rustc_middle::ty::print::with_no_trimmed_paths(|| { | ||
|
||
| let mut msg = String::new(); | ||
| msg.push_str("encountered "); | ||
| write!(&mut msg, $($what_fmt),+).unwrap(); | ||
| let where_ = &$where; | ||
| if !where_.is_empty() { | ||
| msg.push_str(" at "); | ||
| write_path(&mut msg, where_); | ||
| } | ||
| $( | ||
| msg.push_str(", but expected "); | ||
| write!(&mut msg, $($expected_fmt),+).unwrap(); | ||
| )? | ||
|
|
||
| msg | ||
| let where_ = &$where; | ||
| let path = if !where_.is_empty() { | ||
| let mut path = String::new(); | ||
| write_path(&mut path, where_); | ||
| Some(path) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| (path, msg) | ||
| }); | ||
| throw_ub!(ValidationFailure(msg)) | ||
| throw_ub!(ValidationFailure { path, msg }) | ||
| }}; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.