-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #66651 - Areredify:on-unimplemented-scope, r=davidtwco
Add `enclosing scope` parameter to `rustc_on_unimplemented` Adds a new parameter to `#[rustc_on_unimplemented]`, `enclosing scope`, which highlights the function or closure scope with a message. The wip part refers to adding this annotation to `Try` trait to improve ergonomics (which I don't know how to do since I change both std and librustc) Closes #61709.
- Loading branch information
Showing
11 changed files
with
235 additions
and
37 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
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
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
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,27 @@ | ||
// Test scope annotations from `enclosing_scope` parameter | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_on_unimplemented(enclosing_scope="in this scope")] | ||
trait Trait{} | ||
|
||
struct Foo; | ||
|
||
fn f<T: Trait>(x: T) {} | ||
|
||
fn main() { | ||
let x = || { | ||
f(Foo{}); //~ ERROR the trait bound `Foo: Trait` is not satisfied | ||
let y = || { | ||
f(Foo{}); //~ ERROR the trait bound `Foo: Trait` is not satisfied | ||
}; | ||
}; | ||
|
||
{ | ||
{ | ||
f(Foo{}); //~ ERROR the trait bound `Foo: Trait` is not satisfied | ||
} | ||
} | ||
|
||
f(Foo{}); //~ ERROR the trait bound `Foo: Trait` is not satisfied | ||
} |
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,66 @@ | ||
error[E0277]: the trait bound `Foo: Trait` is not satisfied | ||
--> $DIR/enclosing-scope.rs:14:11 | ||
| | ||
LL | fn f<T: Trait>(x: T) {} | ||
| - ----- required by this bound in `f` | ||
... | ||
LL | let x = || { | ||
| _____________- | ||
LL | | f(Foo{}); | ||
| | ^^^^^ the trait `Trait` is not implemented for `Foo` | ||
LL | | let y = || { | ||
LL | | f(Foo{}); | ||
LL | | }; | ||
LL | | }; | ||
| |_____- in this scope | ||
|
||
error[E0277]: the trait bound `Foo: Trait` is not satisfied | ||
--> $DIR/enclosing-scope.rs:16:15 | ||
| | ||
LL | fn f<T: Trait>(x: T) {} | ||
| - ----- required by this bound in `f` | ||
... | ||
LL | let y = || { | ||
| _________________- | ||
LL | | f(Foo{}); | ||
| | ^^^^^ the trait `Trait` is not implemented for `Foo` | ||
LL | | }; | ||
| |_________- in this scope | ||
|
||
error[E0277]: the trait bound `Foo: Trait` is not satisfied | ||
--> $DIR/enclosing-scope.rs:22:15 | ||
| | ||
LL | fn f<T: Trait>(x: T) {} | ||
| - ----- required by this bound in `f` | ||
LL | | ||
LL | / fn main() { | ||
LL | | let x = || { | ||
LL | | f(Foo{}); | ||
LL | | let y = || { | ||
... | | ||
LL | | f(Foo{}); | ||
| | ^^^^^ the trait `Trait` is not implemented for `Foo` | ||
... | | ||
LL | | f(Foo{}); | ||
LL | | } | ||
| |_- in this scope | ||
|
||
error[E0277]: the trait bound `Foo: Trait` is not satisfied | ||
--> $DIR/enclosing-scope.rs:26:7 | ||
| | ||
LL | fn f<T: Trait>(x: T) {} | ||
| - ----- required by this bound in `f` | ||
LL | | ||
LL | / fn main() { | ||
LL | | let x = || { | ||
LL | | f(Foo{}); | ||
LL | | let y = || { | ||
... | | ||
LL | | f(Foo{}); | ||
| | ^^^^^ the trait `Trait` is not implemented for `Foo` | ||
LL | | } | ||
| |_- in this scope | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
Oops, something went wrong.