-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improper_ctypes incorrectly warns on projections featuring opaque types #73251
Comments
I'm not sure if this is incorrect - I think this is what I'd expect. In the declaration of |
Hmm, that might be true. I definitely think that the following should not lint here (with #![feature(type_alias_impl_trait)]
pub trait Foo {
type Assoc;
}
impl Foo for () {
type Assoc = u32;
}
type Bar = impl Foo<Assoc = u32>;
fn assign() -> Bar {}
extern "C" {
pub fn lint_me() -> <Bar as Foo>::Assoc;
} |
I agree that seems like it should be fine. So, this happens because of this call: rust/src/librustc_lint/types.rs Lines 962 to 967 in a37c32e
It makes sense that we want to lint on opaque types on extern declarations, it's unclear whether we would want to allow projections which contain opaque types - this would solve the case you've shown here, but could be used to "sneak" opaque types by the lint (in this playground, the projection normalizes to an opaque type; it's hard to detect because the normalization goes further and resolves it to Any thoughts on whether we should change the behavior here? |
Hm, I think it might be worth it to normalize using |
I'll put up a PR with my experiments from last night later in that case. |
…in-projections, r=estebank lint: normalize projections using opaque types Fixes rust-lang#73251. This PR normalizes projections which use opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this PR fail).
…in-projections, r=estebank lint: normalize projections using opaque types Fixes rust-lang#73251. This PR normalizes projections which use opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this PR fail).
…in-projections, r=estebank lint: normalize projections using opaque types Fixes rust-lang#73251. This PR normalizes projections which use opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this PR fail).
…in-projections, r=estebank lint: normalize projections using opaque types Fixes rust-lang#73251. This PR normalizes projections which use opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this PR fail).
…in-projections, r=estebank lint: normalize projections using opaque types Fixes rust-lang#73251. This PR normalizes projections which use opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this PR fail).
cc @davidtwco
Gives the following incorrect warning:
The text was updated successfully, but these errors were encountered: