Skip to content
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

Incorrect unused parameter with GAT #80766

Closed
bobbobbio opened this issue Jan 7, 2021 · 1 comment · Fixed by #80558
Closed

Incorrect unused parameter with GAT #80766

bobbobbio opened this issue Jan 7, 2021 · 1 comment · Fixed by #80558
Labels
A-GATs Area: Generic associated types (GATs) A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way.

Comments

@bobbobbio
Copy link

I tried this code:

#![feature(generic_associated_types)]
#![allow(incomplete_features)]

trait Factory {
    type Output<'a>;
    fn build<'b>(&self, v: &'b u8) -> Self::Output<'b>;
}

#[allow(unused)]
struct Foo<'a, F: Factory> {
    f: F::Output<'a>,
}

I got this error:

error[E0392]: parameter `'a` is never used
  --> src/lib.rs:10:12
   |
10 | struct Foo<'a, F: Factory> {
   |            ^^ unused parameter
   |
   = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

I think it doesn't make sense since 'a is used in the field f, if I add the PhantomData like suggested, it works fine.

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (da305a2b0 2021-01-05)
binary: rustc
commit-hash: da305a2b00530aa34dea4e48389204c26fa35dbb
commit-date: 2021-01-05
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
@bobbobbio bobbobbio added the C-bug Category: This is a bug. label Jan 7, 2021
@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. labels Jan 7, 2021
@b-naber
Copy link
Contributor

b-naber commented Jan 11, 2021

#80558 is the fix for this.

@bors bors closed this as completed in bbc01bb Jan 22, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-GATs Area: Generic associated types (GATs) A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants