mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Deduplicate const eval error spans for better output
This commit is contained in:
@@ -116,7 +116,9 @@ pub fn report_as_lint(&self,
|
||||
// point to the `const` statement as a secondary span
|
||||
// they don't have any label
|
||||
for sp in primary_spans {
|
||||
lint.span_label(sp, "");
|
||||
if sp != span {
|
||||
lint.span_label(sp, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
lint.emit();
|
||||
|
||||
@@ -50,15 +50,11 @@ warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:14:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| attempt to divide by zero
|
||||
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:9:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| attempt to divide by zero
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/dangling-alloc-id-ice.rs:8:1
|
||||
|
|
||||
LL | const FOO: &() = {
|
||||
| _^
|
||||
| |_|
|
||||
| ||
|
||||
LL | || let y = ();
|
||||
LL | || unsafe { Foo { y: &y }.long_live_the_unit }
|
||||
LL | || };
|
||||
| || ^
|
||||
| ||__|
|
||||
| |___type validation failed: encountered dangling pointer in final constant
|
||||
|
|
||||
LL | / const FOO: &() = {
|
||||
LL | | let y = ();
|
||||
LL | | unsafe { Foo { y: &y }.long_live_the_unit }
|
||||
LL | | };
|
||||
| |__^ type validation failed: encountered dangling pointer in final constant
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/dangling_raw_ptr.rs:1:1
|
||||
|
|
||||
LL | const FOO: *const u32 = {
|
||||
| _^
|
||||
| |_|
|
||||
| ||
|
||||
LL | || let x = 42;
|
||||
LL | || &x
|
||||
LL | || };
|
||||
| || ^
|
||||
| ||__|
|
||||
| |___type validation failed: encountered dangling pointer in final constant
|
||||
|
|
||||
LL | / const FOO: *const u32 = {
|
||||
LL | | let x = 42;
|
||||
LL | | &x
|
||||
LL | | };
|
||||
| |__^ type validation failed: encountered dangling pointer in final constant
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user