-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed as not planned
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.disposition-closeThis PR / issue is in PFCP or FCP with a disposition to close it.This PR / issue is in PFCP or FCP with a disposition to close it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
I tried this code (playground):
pub trait Foo<'a> {}
impl Foo<'_> for () {}
impl<'a, T> Foo<'a> for Option<T> where T: Foo<'a> {}
pub fn bar<T>()
where
T: for<'a> Foo<'a>,
{
}
fn baz<'a>()
where
(): Foo<'a>,
{
bar::<Option<()>>();
}
Or with references instead of Option
impl<'a, 'b, T> Foo<'a> for &'b T where T: Foo<'a> {}
bar::<&()>();
I expected to see this happen: Compile successfully, with or without the unneeded (): Foo<'a>
bound.
Instead, this happened: It works when the (): Foo<'a>
bound is removed, but as written it produces:
error: implementation of `Foo` is not general enough
--> src/lib.rs:16:5
|
1 | pub trait Foo<'a> {}
| -------------------- trait `Foo` defined here
...
16 | bar::<Option<()>>();
| ^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= note: `Option<()>` must implement `Foo<'0>`, for any lifetime `'0`...
= note: ...but `Option<()>` actually implements `Foo<'1>`, for some specific lifetime `'1`
Meta
rustc --version --verbose
:
rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.50.0
Also happens on Nightly.
Dovchik, felstormrage, altanozlu, elv-will, oleiade and 22 more
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.disposition-closeThis PR / issue is in PFCP or FCP with a disposition to close it.This PR / issue is in PFCP or FCP with a disposition to close it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.