diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2016-10-23 17:22:06 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2016-11-22 13:42:36 -0800 |
| commit | eb53ca3aad616069cb8f6f8fff71c27e9ba9640c (patch) | |
| tree | 8b305f44c0527577d57be9cc693465dd3b74f7e5 /src/test | |
| parent | fb122199aac1fd4f9a3c133e25791a9fcb2a6b83 (diff) | |
| download | rust-eb53ca3aad616069cb8f6f8fff71c27e9ba9640c.tar.gz rust-eb53ca3aad616069cb8f6f8fff71c27e9ba9640c.zip | |
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
|
```
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/compare-method/region-extra-2.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/compare-method/traits-misc-mismatch-2.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr | 7 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/main.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/missing-items/m2.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/span/impl-wrong-item-for-trait.stderr | 54 | ||||
| -rw-r--r-- | src/test/ui/span/issue-23827.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/span/issue-24356.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/span/multiline-span-simple.rs | 30 | ||||
| -rw-r--r-- | src/test/ui/span/multiline-span-simple.stderr | 20 |
11 files changed, 153 insertions, 36 deletions
diff --git a/src/test/ui/compare-method/region-extra-2.stderr b/src/test/ui/compare-method/region-extra-2.stderr index 54a551bcfed..12b0ecabcc7 100644 --- a/src/test/ui/compare-method/region-extra-2.stderr +++ b/src/test/ui/compare-method/region-extra-2.stderr @@ -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 diff --git a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr index 5003550fd1e..77b056f6978 100644 --- a/src/test/ui/compare-method/traits-misc-mismatch-2.stderr +++ b/src/test/ui/compare-method/traits-misc-mismatch-2.stderr @@ -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 diff --git a/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr b/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr index c53cf020a9b..b3e72f28d88 100644 --- a/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr +++ b/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr @@ -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 diff --git a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr b/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr index 353e251369a..1d1bc58805a 100644 --- a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr +++ b/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr @@ -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 diff --git a/src/test/ui/mismatched_types/main.stderr b/src/test/ui/mismatched_types/main.stderr index 9e26be6fddd..c87b635521e 100644 --- a/src/test/ui/mismatched_types/main.stderr +++ b/src/test/ui/mismatched_types/main.stderr @@ -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 `()` diff --git a/src/test/ui/missing-items/m2.stderr b/src/test/ui/missing-items/m2.stderr index caeb9ff415c..33135434544 100644 --- a/src/test/ui/missing-items/m2.stderr +++ b/src/test/ui/missing-items/m2.stderr @@ -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;` diff --git a/src/test/ui/span/impl-wrong-item-for-trait.stderr b/src/test/ui/span/impl-wrong-item-for-trait.stderr index 244285e3584..5c352436c3e 100644 --- a/src/test/ui/span/impl-wrong-item-for-trait.stderr +++ b/src/test/ui/span/impl-wrong-item-for-trait.stderr @@ -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>` diff --git a/src/test/ui/span/issue-23827.stderr b/src/test/ui/span/issue-23827.stderr index 5130bb53a19..6c1c2467530 100644 --- a/src/test/ui/span/issue-23827.stderr +++ b/src/test/ui/span/issue-23827.stderr @@ -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;` diff --git a/src/test/ui/span/issue-24356.stderr b/src/test/ui/span/issue-24356.stderr index 906ef25ca0e..963f4bd9bbc 100644 --- a/src/test/ui/span/issue-24356.stderr +++ b/src/test/ui/span/issue-24356.stderr @@ -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;` diff --git a/src/test/ui/span/multiline-span-simple.rs b/src/test/ui/span/multiline-span-simple.rs new file mode 100644 index 00000000000..16414766f39 --- /dev/null +++ b/src/test/ui/span/multiline-span-simple.rs @@ -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) +} diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr new file mode 100644 index 00000000000..26acef64c89 --- /dev/null +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -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 + |
