-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For named lifetimes point only at method signature
When refering to named lifetime conflict, point only at the method's signature span instead of the entire method. When the expected and found sup and sub traces are the same, avoid redundant text.
- Loading branch information
Showing
7 changed files
with
150 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
error[E0195]: lifetime parameters or bounds on method `no_bound` do not match the trait declaration | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:28:5 | ||
| | ||
28 | / fn no_bound<'b:'a>(self, b: Inv<'b>) { | ||
29 | | //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match | ||
30 | | } | ||
| |_____^ lifetimes do not match trait | ||
|
||
error[E0195]: lifetime parameters or bounds on method `has_bound` do not match the trait declaration | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:32:5 | ||
| | ||
32 | / fn has_bound<'b>(self, b: Inv<'b>) { | ||
33 | | //~^ ERROR lifetime parameters or bounds on method `has_bound` do not match | ||
34 | | } | ||
| |_____^ lifetimes do not match trait | ||
|
||
error[E0308]: method not compatible with trait | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 | ||
| | ||
36 | / fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { | ||
37 | | //~^ ERROR method not compatible with trait | ||
38 | | // | ||
39 | | // Note: This is a terrible error message. It is caused | ||
... | | ||
47 | | // cases. | ||
48 | | } | ||
| |_____^ lifetime mismatch | ||
| | ||
= note: expected type `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'d>)` | ||
found type `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'d>)` | ||
note: the lifetime 'c as defined on the method body at 36:5... | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 | ||
| | ||
36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...does not necessarily outlive the lifetime 'c as defined on the method body at 36:5 | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 | ||
| | ||
36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0276]: impl has stricter requirements than trait | ||
--> $DIR/regions-bound-missing-bound-in-impl.rs:53:5 | ||
| | ||
24 | fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>); | ||
| ------------------------------------------------------- definition of `another_bound` from trait | ||
... | ||
53 | fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'x: 't` | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018 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. | ||
|
||
use std::ops::Deref; | ||
trait Trait {} | ||
|
||
struct Struct; | ||
|
||
impl Deref for Struct { | ||
type Target = Trait; | ||
fn deref(&self) -> &Trait { | ||
unimplemented!(); | ||
} | ||
} | ||
//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter |
24 changes: 24 additions & 0 deletions
24
src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0601]: main function not found | ||
|
||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements | ||
--> $DIR/mismatched_trait_impl-2.rs:18:5 | ||
| | ||
18 | / fn deref(&self) -> &Trait { | ||
19 | | unimplemented!(); | ||
20 | | } | ||
| |_____^ | ||
| | ||
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 18:5... | ||
--> $DIR/mismatched_trait_impl-2.rs:18:5 | ||
| | ||
18 | / fn deref(&self) -> &Trait { | ||
19 | | unimplemented!(); | ||
20 | | } | ||
| |_____^ | ||
= note: ...but the lifetime must also be valid for the static lifetime... | ||
= note: ...so that the method type is compatible with trait: | ||
expected fn(&Struct) -> &Trait + 'static | ||
found fn(&Struct) -> &Trait | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters