Repository navigation
Tracking issue for future-incompatibility lint uncovered_param_in_projection #124559
Copy link
Copy link
Open
Labels
A-coherenceArea: CoherenceArea: CoherenceA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-trait-systemArea: Trait systemArea: Trait systemC-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCL-uncovered_param_in_projectionLint: uncovered_param_in_projectionLint: uncovered_param_in_projectionT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.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.
Description
This is a tracking issue for the lint uncovered_param_in_projection which was added in #117164.
The lint detects a violation of one of Rust's orphan rules for foreign trait implementations that concerns the use of type parameters inside trait associated type paths ("projections") whose output may not be a local type that is mistakenly considered to "cover" said parameters which is unsound and which will be rejected by a future version of the compiler.
Originally reported in #99554 (kept open) and tracked in rust-lang/types-team#104.
Example
// dependency.rs
#![crate_type = "lib"]
pub trait Trait<T, U> {}// dependent.rs
trait Identity {
type Output;
}
impl<T> Identity for T {
type Output = T;
}
struct Local;
impl<T> dependency::Trait<Local, T> for <T as Identity>::Output {}
fn main() {}This will produce:
warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
--> dependent.rs:11:6
|
11 | impl<T> dependency::Trait<Local, T> for <T as Identity>::Output {}
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #124559 <https://github.com/rust-lang/rust/issues/124559>
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
= note: `#[warn(uncovered_param_in_projection)]` on by default
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-coherenceArea: CoherenceArea: CoherenceA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-trait-systemArea: Trait systemArea: Trait systemC-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCL-uncovered_param_in_projectionLint: uncovered_param_in_projectionLint: uncovered_param_in_projectionT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.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.
Activity
Auto merge of rust-lang#117164 - fmease:orphan-norm, r=lcnr
weiznich commentedon May 13, 2024
This change affects diesel in a major feature breaking way 😞
You can reproduce this by using the following steps:
Which produces the following warning:
The relevant impl generated by the proc macro looks like this:
As far as I understand this issue this is the desired behavior that these impls are no longer valid . Removing this behavior is highly problematic for diesel as I do not see any other way to write that impl without major breaking changes to diesel itself. It's even likely that this would force us to remove a large popular feature from diesel itself in response to this breaking change.
fmease commentedon May 13, 2024
I will look into this later. Note that the current orphan rules are unsound.
It's possible that the warning emitted for
dieselare false positives (FPs) because the fix / lint for this unsoundness that is implemented on nightly (normalizing alias types in a certain way) is constrained by some known limitations of both trait solvers and that may lead to FPs.Let me see what is the case for
diesel.fmease commentedon May 13, 2024
I'm curious as to why
dieseldidn't show up in the various crater runs we did, let me double-check.weiznich commentedon May 24, 2024
@fmease Did you already had some time to investigate that. I would like to resolve this before cutting a new diesel release.
fmease commentedon May 24, 2024
I've pm'ed you.
weiznich commentedon May 28, 2024
@fmease I've filled diesel-rs/diesel#4050 on diesels side to fix this. This was likely not picked up by crates as it is a change that only landed on the master branch yet. It's not in any released diesel version yet.
Replace impl that triggered a lint on Rust 1.80
Replace impl that triggered a lint on Rust 1.80
Replace impl that triggered a lint on Rust 1.80
Replace impl that triggered a lint on Rust 1.80
[-]Tracking issue for future compatibility lint `uncovered_param_in_projection`[/-][+]Tracking issue for future-incompatibility lint `uncovered_param_in_projection`[/+]Replace impl that triggered a lint on Rust 1.80
Replace impl that triggered a lint on Rust 1.80