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

Derive breaks wildcard import #80490

Closed
dtolnay opened this issue Dec 29, 2020 · 3 comments
Closed

Derive breaks wildcard import #80490

dtolnay opened this issue Dec 29, 2020 · 3 comments
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 29, 2020

#![allow(unused_imports, dead_code)]

//use crate::a::Type;  // <-- uncommenting makes it work
use crate::a::*;

pub type Repro = Type;

mod a {
    use crate::b::*;

    #[derive(Clone)]  // <-- commenting makes it work
    pub struct Type;
}

mod b {
    pub struct Type;
}

fn main() {}
$ rustc src/lib.rs --edition=2018
error[E0412]: cannot find type `Type` in this scope
 --> src/lib.rs:6:18
  |
6 | pub type Repro = Type;
  |                  ^^^^ not found in this scope
  |
help: consider importing one of these items
  |
4 | use crate::a::Type;
  |
4 | use crate::b::Type;
  |

Observations:

  • Changing use crate::a::* to use crate::a::Type makes it work. My expectation would be that * includes Type.
  • Removing the derive on Type makes the wildcard import work.
  • Also reproduces with a proc macro derive in place of standard library builtin derive. Tested with derive(serde::Serialize).
  • Does not reproduce with handwritten Clone impl, only with derive.
  • Reproduces on every compiler since 1.15.0 through most recent nightly.
@dtolnay dtolnay added A-resolve Area: Name resolution T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Dec 29, 2020
@dtolnay
Copy link
Member Author

dtolnay commented Dec 29, 2020

Mentioning @petrochenkov @davidhewitt since you have been active in name resolution recently. (This is not a new bug but you might have insight.)

@petrochenkov
Copy link
Contributor

Looks similar to #56593, this is a long standing issue.

@dtolnay
Copy link
Member Author

dtolnay commented Dec 29, 2020

Thanks, good call. I failed to find that one searching for variations of "wildcard" and "derive".

@dtolnay dtolnay closed this as completed Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants