diff options
| author | bors <bors@rust-lang.org> | 2022-09-19 07:41:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-19 07:41:54 +0000 |
| commit | 503e19d01e941b88bf6d5b28e9108d046abcfa2d (patch) | |
| tree | f2b6f6bd176a03ff1c4e0b2588707d733eecb14c /src | |
| parent | efa717bc2d82c19c6957f362a936a6f95169d138 (diff) | |
| parent | 44738ee336f72e683b2c24dac22b919567ec03a7 (diff) | |
Auto merge of #101629 - compiler-errors:issue-101623, r=sanxiyn
Be careful about `expr_ty_adjusted` when noting block tail type Fixes #101623
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/expr/malformed_closure/ruby_style_closure.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-101623.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-101623.stderr | 14 |
3 files changed, 40 insertions, 1 deletions
diff --git a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr b/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr index 9db9cfc7ff0..759d79493a9 100644 --- a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr +++ b/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr @@ -14,7 +14,7 @@ LL | let p = Some(45).and_then({ LL | | LL | | |x| println!("doubling {}", x); LL | | Some(x * 2) - | | ----------- + | | ----------- this tail expression is of type `std::option::Option<_>` LL | | LL | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` diff --git a/src/test/ui/suggestions/issue-101623.rs b/src/test/ui/suggestions/issue-101623.rs new file mode 100644 index 00000000000..d18a4a21f0a --- /dev/null +++ b/src/test/ui/suggestions/issue-101623.rs @@ -0,0 +1,25 @@ +pub struct Stuff { + inner: *mut (), +} + +pub struct Wrap<T>(T); + +fn fun<T>(t: T) -> Wrap<T> { + todo!() +} + +pub trait Trait<'de> { + fn do_stuff(_: Wrap<&'de mut Self>); +} + +impl<'a> Trait<'a> for () { + fn do_stuff(_: Wrap<&'a mut Self>) {} +} + +fn fun2(t: &mut Stuff) -> () { + let Stuff { inner, .. } = t; + Trait::do_stuff({ fun(&mut *inner) }); + //~^ ERROR the trait bound `*mut (): Trait<'_>` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-101623.stderr b/src/test/ui/suggestions/issue-101623.stderr new file mode 100644 index 00000000000..361483cc08d --- /dev/null +++ b/src/test/ui/suggestions/issue-101623.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `*mut (): Trait<'_>` is not satisfied + --> $DIR/issue-101623.rs:21:21 + | +LL | Trait::do_stuff({ fun(&mut *inner) }); + | --------------- ^^----------------^^ + | | | + | | the trait `Trait<'_>` is not implemented for `*mut ()` + | required by a bound introduced by this call + | + = help: the trait `Trait<'a>` is implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
