Auto merge of #126951 - matthiaskrgr:rollup-xg0o4mc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #126618 (Mark assoc tys live only if the corresponding trait is live) - #126746 (Deny `use<>` for RPITITs) - #126868 (not use offset when there is not ends with brace) - #126884 (Do not ICE when suggesting dereferencing closure arg) - #126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level) - #126915 (Don't suggest awaiting in closure patterns) - #126943 (De-duplicate all consecutive native libs regardless of their options) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
31f8b70d2e
46 changed files with 499 additions and 152 deletions
|
@ -17,3 +17,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
fn g_free2(p: *mut ());
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[link(name = "glib-2.0", kind = "raw-dylib")]
|
||||
extern "C" {
|
||||
fn g_free3(p: *mut ());
|
||||
}
|
||||
|
|
|
@ -71,4 +71,11 @@ async fn suggest_await_in_generic_pattern() {
|
|||
}
|
||||
}
|
||||
|
||||
// Issue #126903
|
||||
async fn do_async() {}
|
||||
fn dont_suggest_awaiting_closure_patterns() {
|
||||
Some(do_async()).map(|()| {});
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -133,6 +133,18 @@ help: consider `await`ing on the `Future`
|
|||
LL | match dummy_result().await {
|
||||
| ++++++
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:77:27
|
||||
|
|
||||
LL | Some(do_async()).map(|()| {});
|
||||
| ^^
|
||||
| |
|
||||
| expected future, found `()`
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected opaque type `impl Future<Output = ()>`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
@ -11,6 +11,7 @@ async fn foo() {
|
|||
async_in_foo(async_out_foo::<4>().await).await;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Faz<const N: usize>;
|
||||
|
||||
impl<const N: usize> Foo<N> for Faz<N> {}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::ops::Add;
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct A<B>(B);
|
||||
|
||||
impl<B> Add for A<B> where B: Add<Output = B> {
|
||||
|
@ -12,6 +13,7 @@ impl<B> Add for A<B> where B: Add<Output = B> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct C<B>(B);
|
||||
|
||||
impl<B: Add<Output = B>> Add for C<B> {
|
||||
|
@ -22,6 +24,7 @@ impl<B: Add<Output = B>> Add for C<B> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct D<B>(B);
|
||||
|
||||
impl<B: std::ops::Add<Output = B>> Add for D<B> {
|
||||
|
@ -32,6 +35,7 @@ impl<B: std::ops::Add<Output = B>> Add for D<B> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct E<B>(B);
|
||||
|
||||
impl<B: Add<Output = B>> Add for E<B> where B: Add<Output = B> {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::ops::Add;
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct A<B>(B);
|
||||
|
||||
impl<B> Add for A<B> where B: Add {
|
||||
|
@ -12,6 +13,7 @@ impl<B> Add for A<B> where B: Add {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct C<B>(B);
|
||||
|
||||
impl<B: Add> Add for C<B> {
|
||||
|
@ -22,6 +24,7 @@ impl<B: Add> Add for C<B> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct D<B>(B);
|
||||
|
||||
impl<B> Add for D<B> {
|
||||
|
@ -32,6 +35,7 @@ impl<B> Add for D<B> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct E<B>(B);
|
||||
|
||||
impl<B: Add> Add for E<B> where <B as Add>::Output = B {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: equality constraints are not yet supported in `where` clauses
|
||||
--> $DIR/missing-bounds.rs:37:33
|
||||
--> $DIR/missing-bounds.rs:41:33
|
||||
|
|
||||
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ not supported
|
||||
|
@ -11,7 +11,7 @@ LL | impl<B: Add> Add for E<B> where B: Add<Output = B> {
|
|||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/missing-bounds.rs:11:11
|
||||
--> $DIR/missing-bounds.rs:12:11
|
||||
|
|
||||
LL | impl<B> Add for A<B> where B: Add {
|
||||
| - expected this type parameter
|
||||
|
@ -24,14 +24,14 @@ LL | A(self.0 + rhs.0)
|
|||
= note: expected type parameter `B`
|
||||
found associated type `<B as Add>::Output`
|
||||
help: the type constructed contains `<B as Add>::Output` due to the type of the argument passed
|
||||
--> $DIR/missing-bounds.rs:11:9
|
||||
--> $DIR/missing-bounds.rs:12:9
|
||||
|
|
||||
LL | A(self.0 + rhs.0)
|
||||
| ^^--------------^
|
||||
| |
|
||||
| this argument influences the type of `A`
|
||||
note: tuple struct defined here
|
||||
--> $DIR/missing-bounds.rs:5:8
|
||||
--> $DIR/missing-bounds.rs:6:8
|
||||
|
|
||||
LL | struct A<B>(B);
|
||||
| ^
|
||||
|
@ -41,7 +41,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> {
|
|||
| ++++++++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/missing-bounds.rs:21:14
|
||||
--> $DIR/missing-bounds.rs:23:14
|
||||
|
|
||||
LL | impl<B: Add> Add for C<B> {
|
||||
| - expected this type parameter
|
||||
|
@ -54,7 +54,7 @@ LL | Self(self.0 + rhs.0)
|
|||
= note: expected type parameter `B`
|
||||
found associated type `<B as Add>::Output`
|
||||
note: tuple struct defined here
|
||||
--> $DIR/missing-bounds.rs:15:8
|
||||
--> $DIR/missing-bounds.rs:17:8
|
||||
|
|
||||
LL | struct C<B>(B);
|
||||
| ^
|
||||
|
@ -64,7 +64,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> {
|
|||
| ++++++++++++
|
||||
|
||||
error[E0369]: cannot add `B` to `B`
|
||||
--> $DIR/missing-bounds.rs:31:21
|
||||
--> $DIR/missing-bounds.rs:34:21
|
||||
|
|
||||
LL | Self(self.0 + rhs.0)
|
||||
| ------ ^ ----- B
|
||||
|
@ -77,7 +77,7 @@ LL | impl<B: std::ops::Add<Output = B>> Add for D<B> {
|
|||
| +++++++++++++++++++++++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/missing-bounds.rs:42:14
|
||||
--> $DIR/missing-bounds.rs:46:14
|
||||
|
|
||||
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
|
||||
| - expected this type parameter
|
||||
|
@ -90,7 +90,7 @@ LL | Self(self.0 + rhs.0)
|
|||
= note: expected type parameter `B`
|
||||
found associated type `<B as Add>::Output`
|
||||
note: tuple struct defined here
|
||||
--> $DIR/missing-bounds.rs:35:8
|
||||
--> $DIR/missing-bounds.rs:39:8
|
||||
|
|
||||
LL | struct E<B>(B);
|
||||
| ^
|
||||
|
|
|
@ -6,6 +6,7 @@ fn type_param<T>() -> impl Sized + use<> {}
|
|||
trait Foo {
|
||||
fn bar() -> impl Sized + use<>;
|
||||
//~^ ERROR `impl Trait` must mention the `Self` type of the trait
|
||||
//~| ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
--> $DIR/forgot-to-capture-type.rs:7:30
|
||||
|
|
||||
LL | fn bar() -> impl Sized + use<>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
|
||||
|
||||
error: `impl Trait` must mention all type parameters in scope in `use<...>`
|
||||
--> $DIR/forgot-to-capture-type.rs:3:23
|
||||
|
|
||||
|
@ -18,5 +26,5 @@ LL | fn bar() -> impl Sized + use<>;
|
|||
|
|
||||
= note: currently, all type parameters are required to be mentioned in the precise captures list
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:7:19
|
||||
|
|
||||
LL | fn hello<'a>() -> impl Sized + use<'a> {}
|
||||
| ^^^^^^^^^^^^^-------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
|
||||
= note: `#[warn(impl_trait_redundant_captures)]` on by default
|
||||
|
||||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:12:27
|
||||
|
|
||||
LL | fn inherent(&self) -> impl Sized + use<'_> {}
|
||||
| ^^^^^^^^^^^^^-------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
--> $DIR/redundant.rs:18:35
|
||||
|
|
||||
LL | fn in_trait() -> impl Sized + use<'a, Self>;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
|
||||
|
||||
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
--> $DIR/redundant.rs:23:35
|
||||
|
|
||||
LL | fn in_trait() -> impl Sized + use<'a> {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,24 +1,27 @@
|
|||
//@ compile-flags: -Zunstable-options --edition=2024
|
||||
//@ check-pass
|
||||
//@ revisions: normal rpitit
|
||||
//@[normal] check-pass
|
||||
|
||||
#![feature(precise_capturing)]
|
||||
|
||||
fn hello<'a>() -> impl Sized + use<'a> {}
|
||||
//~^ WARN all possible in-scope parameters are already captured
|
||||
//[normal]~^ WARN all possible in-scope parameters are already captured
|
||||
|
||||
struct Inherent;
|
||||
impl Inherent {
|
||||
fn inherent(&self) -> impl Sized + use<'_> {}
|
||||
//~^ WARN all possible in-scope parameters are already captured
|
||||
//[normal]~^ WARN all possible in-scope parameters are already captured
|
||||
}
|
||||
|
||||
#[cfg(rpitit)]
|
||||
trait Test<'a> {
|
||||
fn in_trait() -> impl Sized + use<'a, Self>;
|
||||
//~^ WARN all possible in-scope parameters are already captured
|
||||
//[rpitit]~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
}
|
||||
#[cfg(rpitit)]
|
||||
impl<'a> Test<'a> for () {
|
||||
fn in_trait() -> impl Sized + use<'a> {}
|
||||
//~^ WARN all possible in-scope parameters are already captured
|
||||
//[rpitit]~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:6:19
|
||||
|
|
||||
LL | fn hello<'a>() -> impl Sized + use<'a> {}
|
||||
| ^^^^^^^^^^^^^-------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
|
||||
= note: `#[warn(impl_trait_redundant_captures)]` on by default
|
||||
|
||||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:11:27
|
||||
|
|
||||
LL | fn inherent(&self) -> impl Sized + use<'_> {}
|
||||
| ^^^^^^^^^^^^^-------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
||||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:16:22
|
||||
|
|
||||
LL | fn in_trait() -> impl Sized + use<'a, Self>;
|
||||
| ^^^^^^^^^^^^^-------------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
||||
warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
--> $DIR/redundant.rs:20:22
|
||||
|
|
||||
LL | fn in_trait() -> impl Sized + use<'a> {}
|
||||
| ^^^^^^^^^^^^^-------
|
||||
| |
|
||||
| help: remove the `use<...>` syntax
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
21
tests/ui/impl-trait/precise-capturing/rpitit.rs
Normal file
21
tests/ui/impl-trait/precise-capturing/rpitit.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
//@ known-bug: unknown
|
||||
|
||||
// RPITITs don't have variances in their GATs, so they always relate invariantly
|
||||
// and act as if they capture all their args.
|
||||
// To fix this soundly, we need to make sure that all the trait header args
|
||||
// remain captured, since they affect trait selection.
|
||||
|
||||
#![feature(precise_capturing)]
|
||||
|
||||
trait Foo<'a> {
|
||||
fn hello() -> impl PartialEq + use<Self>;
|
||||
}
|
||||
|
||||
fn test<'a, 'b, T: for<'r> Foo<'r>>() {
|
||||
PartialEq::eq(
|
||||
&<T as Foo<'a>>::hello(),
|
||||
&<T as Foo<'b>>::hello(),
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {}
|
50
tests/ui/impl-trait/precise-capturing/rpitit.stderr
Normal file
50
tests/ui/impl-trait/precise-capturing/rpitit.stderr
Normal file
|
@ -0,0 +1,50 @@
|
|||
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
--> $DIR/rpitit.rs:11:36
|
||||
|
|
||||
LL | fn hello() -> impl PartialEq + use<Self>;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
|
||||
|
||||
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
|
||||
--> $DIR/rpitit.rs:11:19
|
||||
|
|
||||
LL | trait Foo<'a> {
|
||||
| -- this lifetime parameter is captured
|
||||
LL | fn hello() -> impl PartialEq + use<Self>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/rpitit.rs:15:5
|
||||
|
|
||||
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | / PartialEq::eq(
|
||||
LL | | &<T as Foo<'a>>::hello(),
|
||||
LL | | &<T as Foo<'b>>::hello(),
|
||||
LL | | );
|
||||
| |_____^ argument requires that `'a` must outlive `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/rpitit.rs:15:5
|
||||
|
|
||||
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | / PartialEq::eq(
|
||||
LL | | &<T as Foo<'a>>::hello(),
|
||||
LL | | &<T as Foo<'b>>::hello(),
|
||||
LL | | );
|
||||
| |_____^ argument requires that `'b` must outlive `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
help: `'a` and `'b` must be the same: replace one with the other
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(precise_capturing)]
|
||||
|
||||
trait Foo {
|
||||
fn bar<'a>() -> impl Sized + use<Self>;
|
||||
//~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
10
tests/ui/impl-trait/precise-capturing/self-capture.stderr
Normal file
10
tests/ui/impl-trait/precise-capturing/self-capture.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
|
||||
--> $DIR/self-capture.rs:4:34
|
||||
|
|
||||
LL | fn bar<'a>() -> impl Sized + use<Self>;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
11
tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs
Normal file
11
tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#![deny(dead_code)]
|
||||
|
||||
struct T1; //~ ERROR struct `T1` is never constructed
|
||||
|
||||
trait Foo { type Unused; } //~ ERROR trait `Foo` is never used
|
||||
impl Foo for T1 { type Unused = Self; }
|
||||
|
||||
pub trait Bar { type Used; }
|
||||
impl Bar for T1 { type Used = Self; }
|
||||
|
||||
fn main() {}
|
20
tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr
Normal file
20
tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: struct `T1` is never constructed
|
||||
--> $DIR/unused-trait-with-assoc-ty.rs:3:8
|
||||
|
|
||||
LL | struct T1;
|
||||
| ^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unused-trait-with-assoc-ty.rs:1:9
|
||||
|
|
||||
LL | #![deny(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: trait `Foo` is never used
|
||||
--> $DIR/unused-trait-with-assoc-ty.rs:5:7
|
||||
|
|
||||
LL | trait Foo { type Unused; }
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -15,7 +15,7 @@ impl<T: ::std::fmt::Display> Foo<T> {
|
|||
}
|
||||
}
|
||||
|
||||
trait Tr { //~ WARN trait `Tr` is never used
|
||||
trait Tr {
|
||||
type U;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
warning: trait `Tr` is never used
|
||||
--> $DIR/issue-22546.rs:18:7
|
||||
|
|
||||
LL | trait Tr {
|
||||
| ^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// #125634
|
||||
struct Thing;
|
||||
|
||||
// Invariant in 'a, Covariant in 'b
|
||||
struct TwoThings<'a, 'b>(*mut &'a (), &'b mut ());
|
||||
|
||||
impl Thing {
|
||||
fn enter_scope<'a>(self, _scope: impl for<'b> FnOnce(TwoThings<'a, 'b>)) {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
Thing.enter_scope(|ctx| {
|
||||
SameLifetime(ctx); //~ ERROR lifetime may not live long enough
|
||||
});
|
||||
}
|
||||
|
||||
struct SameLifetime<'a>(TwoThings<'a, 'a>);
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,17 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/account-for-lifetimes-in-closure-suggestion.rs:13:22
|
||||
|
|
||||
LL | Thing.enter_scope(|ctx| {
|
||||
| ---
|
||||
| |
|
||||
| has type `TwoThings<'_, '1>`
|
||||
| has type `TwoThings<'2, '_>`
|
||||
LL | SameLifetime(ctx);
|
||||
| ^^^ this usage requires that `'1` must outlive `'2`
|
||||
|
|
||||
= note: requirement occurs because of the type `TwoThings<'_, '_>`, which makes the generic argument `'_` invariant
|
||||
= note: the struct `TwoThings<'a, 'b>` is invariant over the parameter `'a`
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
//@ known-bug: rust-lang/rust#124563
|
||||
|
||||
// #124563
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub trait Trait {}
|
||||
|
@ -17,11 +16,11 @@ where
|
|||
T: Trait,
|
||||
{
|
||||
type Trait = T;
|
||||
type Bar = BarImpl<'a, 'b, T>;
|
||||
type Bar = BarImpl<'a, 'b, T>; //~ ERROR lifetime bound not satisfied
|
||||
|
||||
fn foo(&mut self) {
|
||||
self.enter_scope(|ctx| {
|
||||
BarImpl(ctx);
|
||||
self.enter_scope(|ctx| { //~ ERROR lifetime may not live long enough
|
||||
BarImpl(ctx); //~ ERROR lifetime may not live long enough
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,3 +43,5 @@ where
|
|||
{
|
||||
type Foo = FooImpl<'a, 'b, T>;
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,49 @@
|
|||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:16
|
||||
|
|
||||
LL | type Bar = BarImpl<'a, 'b, T>;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined here
|
||||
--> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:6
|
||||
|
|
||||
LL | impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T>
|
||||
| ^^
|
||||
note: but lifetime parameter must outlive the lifetime `'b` as defined here
|
||||
--> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:10
|
||||
|
|
||||
LL | impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T>
|
||||
| ^^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:23:21
|
||||
|
|
||||
LL | self.enter_scope(|ctx| {
|
||||
| ---
|
||||
| |
|
||||
| has type `&'1 mut FooImpl<'_, '_, T>`
|
||||
| has type `&mut FooImpl<'2, '_, T>`
|
||||
LL | BarImpl(ctx);
|
||||
| ^^^ this usage requires that `'1` must outlive `'2`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:22:9
|
||||
|
|
||||
LL | impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T>
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | / self.enter_scope(|ctx| {
|
||||
LL | | BarImpl(ctx);
|
||||
LL | | });
|
||||
| |__________^ argument requires that `'a` must outlive `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
= note: requirement occurs because of a mutable reference to `FooImpl<'_, '_, T>`
|
||||
= note: mutable references are invariant over their type parameter
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0478`.
|
17
tests/ui/regions/regions-escape-method.fixed
Normal file
17
tests/ui/regions/regions-escape-method.fixed
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Test a method call where the parameter `B` would (illegally) be
|
||||
// inferred to a region bound in the method argument. If this program
|
||||
// were accepted, then the closure passed to `s.f` could escape its
|
||||
// argument.
|
||||
//@ run-rustfix
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
fn f<B, F>(&self, _: F) where F: FnOnce(&i32) -> B {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S;
|
||||
s.f(|p| *p) //~ ERROR lifetime may not live long enough
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
// inferred to a region bound in the method argument. If this program
|
||||
// were accepted, then the closure passed to `s.f` could escape its
|
||||
// argument.
|
||||
//@ run-rustfix
|
||||
|
||||
struct S;
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-escape-method.rs:15:13
|
||||
--> $DIR/regions-escape-method.rs:16:13
|
||||
|
|
||||
LL | s.f(|p| p)
|
||||
| -- ^ returning this value requires that `'1` must outlive `'2`
|
||||
| ||
|
||||
| |return type of closure is &'2 i32
|
||||
| has type `&'1 i32`
|
||||
|
|
||||
help: dereference the return value
|
||||
|
|
||||
LL | s.f(|p| *p)
|
||||
| +
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// issue#126764
|
||||
|
||||
struct S;
|
||||
|
||||
trait T {
|
||||
fn f();
|
||||
}
|
||||
impl T for S;
|
||||
//~^ ERROR: unknown start of token
|
||||
//~| ERROR: expected `{}`
|
||||
//~| ERROR: not all trait items implemented, missing: `f`
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,31 @@
|
|||
error: unknown start of token: \u{ff1b}
|
||||
--> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:13
|
||||
|
|
||||
LL | impl T for S;
|
||||
| ^^
|
||||
|
|
||||
help: Unicode character ';' (Fullwidth Semicolon) looks like ';' (Semicolon), but it is not
|
||||
|
|
||||
LL | impl T for S;
|
||||
| ~
|
||||
|
||||
error: expected `{}`, found `;`
|
||||
--> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:13
|
||||
|
|
||||
LL | impl T for S;
|
||||
| ^^
|
||||
|
|
||||
= help: try using `{}` instead
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `f`
|
||||
--> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:1
|
||||
|
|
||||
LL | fn f();
|
||||
| ------- `f` from trait
|
||||
LL | }
|
||||
LL | impl T for S;
|
||||
| ^^^^^^^^^^^^ missing `f` in implementation
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0046`.
|
Loading…
Add table
Add a link
Reference in a new issue