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

Build error with extern crates after upgrading to 2018 edition #56398

Closed
elliottslaughter opened this issue Dec 1, 2018 · 3 comments · Fixed by #56759
Closed

Build error with extern crates after upgrading to 2018 edition #56398

elliottslaughter opened this issue Dec 1, 2018 · 3 comments · Fixed by #56759

Comments

@elliottslaughter
Copy link
Contributor

I took my project here and converted it to the 2018 edition: https://github.com/elliottslaughter/integrity-checker

The flow I used was:

git clone https://github.com/elliottslaughter/integrity-checker
cd integrity-checker
cargo +beta fix --edition # no warnings on first try, one change
git commit -a -m 'Prep for edition.'
# go to Cargo.toml and set edition keyword
cargo +beta build

But even though cargo fix completes without warnings, the build is giving me:

   Compiling integrity-checker v0.1.0 (/Users/elliott/Programming/Rust/integrity-checker)                                                   
error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)                      
 --> src/error.rs:2:5                                                                                                                       
  |                                                                                                                                         
2 | use ignore;                                                                                                                             
  |     ^^^^^^ not an extern crate passed with `--extern`                                                                                   
  |                                                                                                                                         
note: this import refers to the built-in attribute imported here                                                                            
 --> src/error.rs:2:5                                                                                                                       
  |                                                                                                                                         
2 | use ignore;                                                                                                                             
  |     ^^^^^^                                                                                                                              
                                                                                                                                            
error: aborting due to previous error                                                                                                       
                                                                                                                                            
For more information about this error, try `rustc --explain E0658`.                                                                         
error: Could not compile `integrity-checker`.                                                                                               

To learn more, run the command again with --verbose.

For posterity I've saved the result of having applied cargo fix here:

https://github.com/elliottslaughter/integrity-checker/tree/rust-2018

$ rustc +beta --version
rustc 1.31.0-beta.20 (8940af3ce 2018-11-30)
$ cargo +beta --version
cargo 1.31.0-beta (339d9f9c8 2018-11-16)
@petrochenkov
Copy link
Contributor

Duplicate of #56326

@petrochenkov petrochenkov marked this as a duplicate of #56326 Dec 1, 2018
@ehuss
Copy link
Contributor

ehuss commented Dec 1, 2018

@petrochenkov This issue seems a little different because it does not involve edition idioms or migration lints. A smaller example, assume you are writing new code in 2018 from scratch:

cargo +beta new foo --lib
cd foo
cargo +beta new ignore --lib
echo 'ignore = {path = "ignore"}' >> Cargo.toml
echo 'use ignore;' >> src/lib.rs
cargo +beta check

The error message (as shown above) on current beta is somewhat confusing. If you're not aware that use ignore is attempting to import both an extern crate and an attribute from the standard prelude, as a user I would be thoroughly flummoxed. It doesn't help that ignore is passed in with --extern and the word "only" may not be clear enough.

Perhaps the fix for this and #56326 is the same, but that issue is currently marked as an idiom lint, but this affects "normal" code.

@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 1, 2018

Ultimately, the fix to both issues is to stabilize uniform paths (#56417), so that the feature gate error is no longer reported.

bors added a commit that referenced this issue Jan 12, 2019
Stabilize `uniform_paths`

Address all the things described in #56417.

Assign visibilities to `macro_rules` items - `pub` to `macro_export`-ed macros and `pub(crate)` to non-exported macros, these visibilities determine how far these macros can be reexported with `use`.

Prohibit use of reexported inert attributes and "tool modules", after renaming (e.g. `use inline as imported_inline`) their respective tools and even compiler passes won't be able to recognize and properly check them.

Also turn use of uniform paths in 2015 macros into an error, I'd prefer to neither remove nor stabilize them right away because I still want to make some experiments in this area (uniform path fallback was added to 2015 macros used on 2018 edition in #56053 (comment)).

UPDATE: The last commit also stabilizes the feature `uniform_paths`.

Closes #53130
Closes #55618
Closes #56326
Closes #56398
Closes #56417
Closes #56821
Closes #57252
Closes #57422
bors added a commit that referenced this issue Jan 12, 2019
Stabilize `uniform_paths`

Address all the things described in #56417.

Assign visibilities to `macro_rules` items - `pub` to `macro_export`-ed macros and `pub(crate)` to non-exported macros, these visibilities determine how far these macros can be reexported with `use`.

Prohibit use of reexported inert attributes and "tool modules", after renaming (e.g. `use inline as imported_inline`) their respective tools and even compiler passes won't be able to recognize and properly check them.

Also turn use of uniform paths in 2015 macros into an error, I'd prefer to neither remove nor stabilize them right away because I still want to make some experiments in this area (uniform path fallback was added to 2015 macros used on 2018 edition in #56053 (comment)).

UPDATE: The last commit also stabilizes the feature `uniform_paths`.

Closes #53130
Closes #55618
Closes #56326
Closes #56398
Closes #56417
Closes #56821
Closes #57252
Closes #57422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants