-
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
the name std
is defined multiple times
#59243
Comments
The second instance is |
Where exactly is |
Ok, it turns out this is a legitimate bug, I misinterpreted it as a more commonly reported diagnostic issue.
If you set On 2018 edition, however, |
The solution is to either encode gensyms/hygiene into metadata properly (this is a large task and a long standing issue), or come up with some hack preventing the injected |
Fixed in #59296 |
Do not encode gensymed imports in metadata (Unless they are underscore `_` imports which are re-gensymed on crate loading, see rust-lang#56392.) We cannot encode gensymed imports properly in metadata and if we encode them improperly, we can get erroneous name conflicts downstream. Gensymed imports are produced by the compiler, so we control their set, and can be sure that none of them needs being encoded for use from other crates. A workaround that fixes rust-lang#59243.
Do not encode gensymed imports in metadata (Unless they are underscore `_` imports which are re-gensymed on crate loading, see rust-lang#56392.) We cannot encode gensymed imports properly in metadata and if we encode them improperly, we can get erroneous name conflicts downstream. Gensymed imports are produced by the compiler, so we control their set, and can be sure that none of them needs being encoded for use from other crates. A workaround that fixes rust-lang#59243.
The error happens on latest stable and nightly.
Steps to reproduce:
cargo new --lib lib1
;src/lib.rs
:tests/test1.rs
:cargo test
returns error:The error only happens if the module is named
std
(for instance,core
andalloc
work without error). The error is not produced iftest1.rs
doesn't uselib1
in any way. Iftest1.rs
doesn't contain imports but uses the library directly (e.g.::lib1::x()
), the error is produced.cargo build
always succeeds.I don't know if this is supposed to be forbidden but the error message seems to be misleading.
The text was updated successfully, but these errors were encountered: