diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-03 11:07:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-03 11:07:01 +0100 |
| commit | 8dacfc2adac25b8e749a19623ce4db543bb33306 (patch) | |
| tree | 4347631bddde91e7243e60aa55c196531388d59e /src/test/ui/on-unimplemented | |
| parent | 3045d22263b88e17e3ff2e824b25d727d31dea6d (diff) | |
| parent | 1d0c015f9b5e4da3695ed23f269dc51a8d09b8a9 (diff) | |
| download | rust-8dacfc2adac25b8e749a19623ce4db543bb33306.tar.gz rust-8dacfc2adac25b8e749a19623ce4db543bb33306.zip | |
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.
Diffstat (limited to 'src/test/ui/on-unimplemented')
| -rw-r--r-- | src/test/ui/on-unimplemented/enclosing-scope.rs | 27 | ||||
| -rw-r--r-- | src/test/ui/on-unimplemented/enclosing-scope.stderr | 66 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/test/ui/on-unimplemented/enclosing-scope.rs b/src/test/ui/on-unimplemented/enclosing-scope.rs new file mode 100644 index 00000000000..881bff63f5f --- /dev/null +++ b/src/test/ui/on-unimplemented/enclosing-scope.rs @@ -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 +} diff --git a/src/test/ui/on-unimplemented/enclosing-scope.stderr b/src/test/ui/on-unimplemented/enclosing-scope.stderr new file mode 100644 index 00000000000..092e560330b --- /dev/null +++ b/src/test/ui/on-unimplemented/enclosing-scope.stderr @@ -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`. |
