Deduplicate const eval error spans for better output
This commit is contained in:
parent
44730271f7
commit
ce90db1ff1
4 changed files with 15 additions and 29 deletions
|
@ -116,7 +116,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||||
// point to the `const` statement as a secondary span
|
// point to the `const` statement as a secondary span
|
||||||
// they don't have any label
|
// they don't have any label
|
||||||
for sp in primary_spans {
|
for sp in primary_spans {
|
||||||
lint.span_label(sp, "");
|
if sp != span {
|
||||||
|
lint.span_label(sp, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lint.emit();
|
lint.emit();
|
||||||
|
|
|
@ -50,15 +50,11 @@ warning: reaching this expression at runtime will panic or abort
|
||||||
--> $DIR/promoted_errors.rs:14:20
|
--> $DIR/promoted_errors.rs:14:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", 1/(false as u32));
|
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
|
warning: reaching this expression at runtime will panic or abort
|
||||||
--> $DIR/promoted_errors.rs:9:20
|
--> $DIR/promoted_errors.rs:9:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", 1/(1-1));
|
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
|
error: any use of this value will cause an error
|
||||||
--> $DIR/dangling-alloc-id-ice.rs:8:1
|
--> $DIR/dangling-alloc-id-ice.rs:8:1
|
||||||
|
|
|
|
||||||
LL | const FOO: &() = {
|
LL | / const FOO: &() = {
|
||||||
| _^
|
LL | | let y = ();
|
||||||
| |_|
|
LL | | unsafe { Foo { y: &y }.long_live_the_unit }
|
||||||
| ||
|
LL | | };
|
||||||
LL | || let y = ();
|
| |__^ type validation failed: encountered dangling pointer in final constant
|
||||||
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
|
= note: #[deny(const_err)] on by default
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
error: any use of this value will cause an error
|
error: any use of this value will cause an error
|
||||||
--> $DIR/dangling_raw_ptr.rs:1:1
|
--> $DIR/dangling_raw_ptr.rs:1:1
|
||||||
|
|
|
|
||||||
LL | const FOO: *const u32 = {
|
LL | / const FOO: *const u32 = {
|
||||||
| _^
|
LL | | let x = 42;
|
||||||
| |_|
|
LL | | &x
|
||||||
| ||
|
LL | | };
|
||||||
LL | || let x = 42;
|
| |__^ type validation failed: encountered dangling pointer in final constant
|
||||||
LL | || &x
|
|
||||||
LL | || };
|
|
||||||
| || ^
|
|
||||||
| ||__|
|
|
||||||
| |___type validation failed: encountered dangling pointer in final constant
|
|
||||||
|
|
|
||||||
|
|
|
|
||||||
= note: #[deny(const_err)] on by default
|
= note: #[deny(const_err)] on by default
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue