diff options
| author | bors <bors@rust-lang.org> | 2023-08-12 10:02:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-12 10:02:45 +0000 |
| commit | f1b854818db00bec14accbc9d1c72e6ebefe64db (patch) | |
| tree | f4de2918d416f703cf171279178ff64c575b1336 /tests | |
| parent | b08dd92552d663e3c877c8e5ce859e212205a09f (diff) | |
| parent | 3028dc4ef7719178b2567e92d57d893be1b45176 (diff) | |
| download | rust-f1b854818db00bec14accbc9d1c72e6ebefe64db.tar.gz rust-f1b854818db00bec14accbc9d1c72e6ebefe64db.zip | |
Auto merge of #109356 - jackh726:issue-108544, r=lcnr
Only check outlives goals on impl compared to trait Fixes #108544 r? `@compiler-errors`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs | 23 | ||||
| -rw-r--r-- | tests/ui/implied-bounds/trait-where-clause-implied.rs | 15 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs b/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs new file mode 100644 index 00000000000..8dcc35a281a --- /dev/null +++ b/tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs @@ -0,0 +1,23 @@ +// check-pass +// See issue #109356. We don't want a false positive to the `implied_bounds_entailment` lint. + +use std::borrow::Cow; + +pub trait Trait { + fn method(self) -> Option<Cow<'static, str>> + where + Self: Sized; +} + +impl<'a> Trait for Cow<'a, str> { + // If we're not careful here, we'll check `WF(return-type)` using the trait + // and impl where clauses, requiring that `Cow<'a, str>: Sized`. This is + // obviously true, but if we pick the `Self: Sized` clause from the trait + // over the "inherent impl", we will require `'a == 'static`, which triggers + // the `implied_bounds_entailment` lint. + fn method(self) -> Option<Cow<'static, str>> { + None + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/trait-where-clause-implied.rs b/tests/ui/implied-bounds/trait-where-clause-implied.rs new file mode 100644 index 00000000000..5f9ab66d3c8 --- /dev/null +++ b/tests/ui/implied-bounds/trait-where-clause-implied.rs @@ -0,0 +1,15 @@ +// check-pass + +pub trait Trait<'a, 'b> { + fn method(self, _: &'static &'static ()) + where + 'a: 'b; +} + +impl<'a> Trait<'a, 'static> for () { + // On first glance, this seems like we have the extra implied bound that + // `'a: 'static`, but we know this from the trait method where clause. + fn method(self, _: &'static &'a ()) {} +} + +fn main() {} |
