Avoid deriving bounds from FnPtr#156194
Conversation
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
according to the blame history, maybe r? @estebank need to confirm this change.
|
Can this lead to pass→fail regressions? Does this need crater? Is T-compiler really the right team or is it T-libs{-api} or T-lang? |
|
Oh, I found a pass→fail case, but I think the new behavior is semantically correct. code trait SomeTrait {
type SomeType<'a>;
}
#[derive(Clone)]
struct Concrete;
struct NotClone<'a>(&'a ());
impl SomeTrait for Concrete {
type SomeType<'a> = NotClone<'a>;
}
#[derive(Clone)]
struct Foo<T: SomeTrait> {
x: for<'a> fn(T::SomeType<'a>),
}
trait Local {}
impl<T: Clone> Local for T {}
// Before this PR: Foo<Concrete> does not satisfy Clone
// After this PR: it does -> impl conflicts
impl Local for Foo<Concrete> {}
fn main() {}output ❯ rustc +issue143131 main.rs
error[E0119]: conflicting implementations of trait `Local` for type `Foo<Concrete>`
--> main.rs:23:1
|
21 | impl<T: Clone> Local for T {}
| -------------------------- first implementation here
22 |
23 | impl Local for Foo<Concrete> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<Concrete>`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.This happens because the PR makes the derived The affected pattern seems quite narrow, but I agree that a crater run would be the safer way to measure the actual ecosystem impact. |
closes: #143131
closes: #155446
We don't need bounds for the inputs and outputs of function pointers.
for the code below, for example,
Before
An error occurs for a lifetime.
After
where T::SomeType<'_>: ::core::clone::Clone, which was incorrect, and unnecessary, has goneNo errors.