1
Fork 0

Deduplicate const eval error spans for better output

This commit is contained in:
Esteban Küber 2019-03-11 09:43:05 -07:00
parent 44730271f7
commit ce90db1ff1
4 changed files with 15 additions and 29 deletions

View file

@ -116,7 +116,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
// 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();

View file

@ -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

View file

@ -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

View file

@ -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