-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #109356 - jackh726:issue-108544, r=lcnr
Only check outlives goals on impl compared to trait Fixes #108544 r? `@compiler-errors`
- Loading branch information
Showing
3 changed files
with
77 additions
and
12 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
23 changes: 23 additions & 0 deletions
23
tests/ui/implied-bounds/implied_bounds_entailment_skip_non_outlives.rs
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,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() {} |
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,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() {} |