Show multiline spans in full if short enough
When dealing with multiline spans that span few lines, show the complete
span instead of restricting to the first character of the first line.
For example, instead of:
```
% ./rustc foo.rs
error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied
--> foo.rs:13:9
|
13 | foo(1 + bar(x,
| ^ trait `{integer}: std::ops::Add<()>` not satisfied
|
```
show
```
% ./rustc foo.rs
error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied
--> foo.rs:13:9
|
13 | foo(1 + bar(x,
| ________^ starting here...
14 | | y),
| |_____________^ ...ending here: trait `{integer}: std::ops::Add<()>` not satisfied
|
```
This commit is contained in:
parent
fb122199aa
commit
eb53ca3aad
15 changed files with 1086 additions and 149 deletions
|
|
@ -1,11 +1,15 @@
|
|||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/region-extra-2.rs:19:5
|
||||
|
|
||||
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
|
||||
| -------------------------------------- definition of `renew` from trait
|
||||
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
|
||||
| -------------------------------------- definition of `renew` from trait
|
||||
...
|
||||
19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
|
||||
| ^ impl has extra requirement `'a: 'b`
|
||||
19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
|
||||
| _____^ starting here...
|
||||
20 | | //~^ ERROR E0276
|
||||
21 | | &mut self[..]
|
||||
22 | | }
|
||||
| |_____^ ...ending here: impl has extra requirement `'a: 'b`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/traits-misc-mismatch-2.rs:23:5
|
||||
|
|
||||
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
|
||||
| ------------------------------------------------------------------ definition of `zip` from trait
|
||||
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
|
||||
| ------------------------------------------------------------------ definition of `zip` from trait
|
||||
...
|
||||
23 | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
|
||||
| ^ impl has extra requirement `U: Iterator<B>`
|
||||
23 | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
|
||||
| _____^ starting here...
|
||||
24 | | //~^ ERROR E0276
|
||||
25 | | ZipIterator{a: self, b: other}
|
||||
26 | | }
|
||||
| |_____^ ...ending here: impl has extra requirement `U: Iterator<B>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,26 @@
|
|||
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
|
||||
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:32:1
|
||||
|
|
||||
32 | impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
|
||||
| ^
|
||||
32 | impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
|
||||
| _^ starting here...
|
||||
33 | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
|
||||
34 | |
|
||||
35 | | // (unsafe to access self.1 due to #[may_dangle] on A)
|
||||
36 | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
|
||||
37 | | }
|
||||
| |_^ ..ending here
|
||||
|
||||
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
|
||||
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:38:1
|
||||
|
|
||||
38 | impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
|
||||
| ^
|
||||
38 | impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
|
||||
| _^ starting here...
|
||||
39 | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
|
||||
40 | |
|
||||
41 | | // (unsafe to access self.1 due to #[may_dangle] on 'a)
|
||||
42 | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
|
||||
43 | | }
|
||||
| |_^ ..ending here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen
|
|||
help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()>
|
||||
--> $DIR/consider-using-explicit-lifetime.rs:25:5
|
||||
|
|
||||
25 | fn from_str(path: &str) -> Result<Self, ()> {
|
||||
| ^
|
||||
25 | fn from_str(path: &str) -> Result<Self, ()> {
|
||||
| _____^ starting here...
|
||||
26 | | Ok(Foo { field: path })
|
||||
27 | | }
|
||||
| |_____^ ..ending here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/main.rs:12:18
|
||||
|
|
||||
12 | let x: u32 = (
|
||||
| ^ expected u32, found ()
|
||||
12 | let x: u32 = (
|
||||
| __________________^ starting here...
|
||||
13 | | );
|
||||
| |_____^ ...ending here: expected u32, found ()
|
||||
|
|
||||
= note: expected type `u32`
|
||||
= note: found type `()`
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ error: main function not found
|
|||
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
|
||||
--> $DIR/m2.rs:20:1
|
||||
|
|
||||
20 | impl m1::X for X {
|
||||
| ^ missing `CONSTANT`, `Type`, `method` in implementation
|
||||
20 | impl m1::X for X {
|
||||
| _^ starting here...
|
||||
21 | | }
|
||||
| |_^ ...ending here: missing `CONSTANT`, `Type`, `method` in implementation
|
||||
|
|
||||
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
|
||||
= note: `Type` from trait: `type Type;`
|
||||
|
|
|
|||
|
|
@ -10,11 +10,19 @@ error[E0323]: item `bar` is an associated const, which doesn't match its trait `
|
|||
error[E0046]: not all trait items implemented, missing: `bar`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:22:1
|
||||
|
|
||||
16 | fn bar(&self);
|
||||
| -------------- `bar` from trait
|
||||
16 | fn bar(&self);
|
||||
| -------------- `bar` from trait
|
||||
...
|
||||
22 | impl Foo for FooConstForMethod {
|
||||
| ^ missing `bar` in implementation
|
||||
22 | impl Foo for FooConstForMethod {
|
||||
| _^ starting here...
|
||||
23 | | //~^ ERROR E0046
|
||||
24 | | //~| NOTE missing `bar` in implementation
|
||||
25 | | const bar: u64 = 1;
|
||||
26 | | //~^ ERROR E0323
|
||||
27 | | //~| NOTE does not match trait
|
||||
28 | | const MY_CONST: u32 = 1;
|
||||
29 | | }
|
||||
| |_^ ...ending here: missing `bar` in implementation
|
||||
|
||||
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `<FooMethodForConst as Foo>`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:37:5
|
||||
|
|
@ -28,11 +36,19 @@ error[E0324]: item `MY_CONST` is an associated method, which doesn't match its t
|
|||
error[E0046]: not all trait items implemented, missing: `MY_CONST`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:33:1
|
||||
|
|
||||
17 | const MY_CONST: u32;
|
||||
| -------------------- `MY_CONST` from trait
|
||||
17 | const MY_CONST: u32;
|
||||
| -------------------- `MY_CONST` from trait
|
||||
...
|
||||
33 | impl Foo for FooMethodForConst {
|
||||
| ^ missing `MY_CONST` in implementation
|
||||
33 | impl Foo for FooMethodForConst {
|
||||
| _^ starting here...
|
||||
34 | | //~^ ERROR E0046
|
||||
35 | | //~| NOTE missing `MY_CONST` in implementation
|
||||
36 | | fn bar(&self) {}
|
||||
37 | | fn MY_CONST() {}
|
||||
38 | | //~^ ERROR E0324
|
||||
39 | | //~| NOTE does not match trait
|
||||
40 | | }
|
||||
| |_^ ...ending here: missing `MY_CONST` in implementation
|
||||
|
||||
error[E0325]: item `bar` is an associated type, which doesn't match its trait `<FooTypeForMethod as Foo>`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:47:5
|
||||
|
|
@ -46,17 +62,27 @@ error[E0325]: item `bar` is an associated type, which doesn't match its trait `<
|
|||
error[E0046]: not all trait items implemented, missing: `bar`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:44:1
|
||||
|
|
||||
16 | fn bar(&self);
|
||||
| -------------- `bar` from trait
|
||||
16 | fn bar(&self);
|
||||
| -------------- `bar` from trait
|
||||
...
|
||||
44 | impl Foo for FooTypeForMethod {
|
||||
| ^ missing `bar` in implementation
|
||||
44 | impl Foo for FooTypeForMethod {
|
||||
| _^ starting here...
|
||||
45 | | //~^ ERROR E0046
|
||||
46 | | //~| NOTE missing `bar` in implementation
|
||||
47 | | type bar = u64;
|
||||
48 | | //~^ ERROR E0325
|
||||
49 | | //~| NOTE does not match trait
|
||||
50 | | const MY_CONST: u32 = 1;
|
||||
51 | | }
|
||||
| |_^ ...ending here: missing `bar` in implementation
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `fmt`
|
||||
--> $DIR/impl-wrong-item-for-trait.rs:53:1
|
||||
|
|
||||
53 | impl Debug for FooTypeForMethod {
|
||||
| ^ missing `fmt` in implementation
|
||||
53 | impl Debug for FooTypeForMethod {
|
||||
| _^ starting here...
|
||||
54 | | }
|
||||
| |_^ ...ending here: missing `fmt` in implementation
|
||||
|
|
||||
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
error[E0046]: not all trait items implemented, missing: `Output`
|
||||
--> $DIR/issue-23827.rs:36:1
|
||||
|
|
||||
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||
| ^ missing `Output` in implementation
|
||||
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||
| _^ starting here...
|
||||
37 | | //~^ ERROR E0046
|
||||
38 | | //~| NOTE missing `Output` in implementation
|
||||
39 | | //~| NOTE `Output` from trait: `type Output;`
|
||||
40 | | extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
|
||||
41 | | Fn::call(&self, (comp,))
|
||||
42 | | }
|
||||
43 | | }
|
||||
| |_^ ...ending here: missing `Output` in implementation
|
||||
|
|
||||
= note: `Output` from trait: `type Output;`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
error[E0046]: not all trait items implemented, missing: `Target`
|
||||
--> $DIR/issue-24356.rs:30:9
|
||||
|
|
||||
30 | impl Deref for Thing {
|
||||
| ^ missing `Target` in implementation
|
||||
30 | impl Deref for Thing {
|
||||
| _________^ starting here...
|
||||
31 | | //~^ ERROR E0046
|
||||
32 | | //~| NOTE missing `Target` in implementation
|
||||
33 | | //~| NOTE `Target` from trait: `type Target;`
|
||||
34 | | fn deref(&self) -> i8 { self.0 }
|
||||
35 | | }
|
||||
| |_________^ ...ending here: missing `Target` in implementation
|
||||
|
|
||||
= note: `Target` from trait: `type Target;`
|
||||
|
||||
|
|
|
|||
30
src/test/ui/span/multiline-span-simple.rs
Normal file
30
src/test/ui/span/multiline-span-simple.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo(a: u32, b: u32) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
fn bar(a: u32, b: u32) {
|
||||
a + b;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = 1;
|
||||
let y = 2;
|
||||
let z = 3;
|
||||
foo(1 +
|
||||
|
||||
bar(x,
|
||||
|
||||
y),
|
||||
|
||||
z)
|
||||
}
|
||||
20
src/test/ui/span/multiline-span-simple.stderr
Normal file
20
src/test/ui/span/multiline-span-simple.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied
|
||||
--> $DIR/multiline-span-simple.rs:23:9
|
||||
|
|
||||
23 | foo(1 +
|
||||
| _________^ starting here...
|
||||
24 | |
|
||||
25 | | bar(x,
|
||||
26 | |
|
||||
27 | | y),
|
||||
| |______________^ ...ending here: the trait `std::ops::Add<()>` is not implemented for `{integer}`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
= help: <u32 as std::ops::Add>
|
||||
= help: <&'a u32 as std::ops::Add<u32>>
|
||||
= help: <u32 as std::ops::Add<&'a u32>>
|
||||
= help: <&'b u32 as std::ops::Add<&'a u32>>
|
||||
= help: and 90 others
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue