Skip to content

Build errors with edition=2018 after clean cargo fix --edition #55592

Description

@SimonSapin

With nightly-2018-11-01 in Servo, after finally getting cargo fix --edition to complete without warnings. (Which was not easy: rust-lang/rustfix#149, https://github.com/rust-lang-nursery/rustfix/issues/150), I added edition = "2018" to (almost) all Cargo.toml files.

At this point, the theory is that cargo check should Just Work, but it doesn’t. I’ve hit multiple issues, let me know if they should be filed separately.

Dependencies not known to Cargo

error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)          
  --> components/dom_struct/lib.rs:11:5                                                                                
   |                                                                                                                   
11 | use proc_macro::TokenStream;                                                                                      
   |     ^^^^^^^^^^                                                                                                    
   |                                                                                                                   
   = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable  

The "extern prelude" is one way to fix this, but another is to is a crate-local path crate::proc_macro::TokenStream to the name that is introduced by extern crate.

This feature is also missing a tracking issue, the error message points to the implementation PR: #54658 (comment)

Ambiguous imports

error: `time` import is ambiguous                                                                                      
  --> components/compositing/compositor.rs:41:5                                                                        
   |                                                                                                                   
23 | use profile_traits::time::{self, ProfilerCategory, profile};                                                      
   |                            ---- may refer to `self::time` in the future                                           
...                                                                                                                    
41 | use time::{now, precise_time_ns, precise_time_s};                                                                 
   |     ^^^^ can refer to external crate `::time`                                                                     
   |                                                                                                                   
   = help: write `::time` or `self::time` explicitly instead                                                           
   = note: in the future, `#![feature(uniform_paths)]` may become the default                                          
                                                                                                                       
error: aborting due to previous error  

Migrating generated code

cargo fix did fix similar cases in "normal" source files, but generated code needs to be fixed in the code generator.

These were the remaining ones after I’d already taken care of the absolute paths.

error: expected expression, found reserved keyword `try`                                                               
   --> /home/simon/servo2/target/debug/build/script-b336041ffdaa5d29/out/Bindings/AnalyserNodeBinding.rs:291:23        
    |                                                                                                                  
291 |                 match try!(crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions::new(cx, val)) {
    |                       ^^^ expected expression                                                                    
       
error: expected pattern, found reserved keyword `async`                                                                
    --> /home/simon/servo2/target/debug/build/script-b336041ffdaa5d29/out/Bindings/XMLHttpRequestBinding.rs:1766:57    
     |                                                                                                                 
1766 |     fn Open_(&self, method: ByteString, url: USVString, async: bool, username: Option<USVString>, password: Option<USVString>) -> Fallible<()>;
     |                                                         ^^^^^ expected pattern                                  
                                                                                                                       
error: aborting due to previous error    

New warnings

Not as much of an issue than build errors, but slightly unexpected: switching editions uncovered new unused_mut warnings that were not present before. Maybe this is because 2018 currently implies NLL / MIR-borrowck?

Activity

  1. SimonSapin commented on Nov 1, 2018

    @SimonSapin
    ContributorAuthor

    Incorrect warnings

    warning: unused extern crate                                                                                           
      --> components/script_plugins/lib.rs:27:1                                                                            
       |                                                                                                                   
    27 | extern crate rustc_plugin;                                                                                        
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it                                                                        
       |                                                                                                                   
       = note: requested on the command line with `-W unused-extern-crates`                                                
                                                                                                                           
    warning: unused extern crate                                                                                           
      --> components/script_plugins/lib.rs:28:1                                                                            
       |                                                                                                                   
    28 | extern crate syntax;                                                                                              
       | ^^^^^^^^^^^^^^^^^^^^ help: remove it    

    Making the suggested removal causes build errors.

  2. Enselic commented on Nov 12, 2024

    @Enselic
    Member

    Triage: To make progress I think we're going to need some (reasonably easy) way to reproduce the issues.

  3. added
    S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
    on Nov 12, 2024
  4. workingjubilee commented on Jun 19, 2025

    @workingjubilee
    Member

    My understanding is that Servo from that time can no longer can be built and pass tests with a current rustc because of dependence on unstable compiler features. I am going to close this as "needs repro" will be indefinite from the POV of having something that repros on a current compiler. We can reopen if we find that to be incorrect later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2018Area: The 2018 editionC-bugCategory: This is a bug.F-rust_2018_preview`#![feature(rust_2018_preview)]`S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions