Skip to content

2018 edition module/path changes don't work for libtest benchmarks #55133

@dekellum

Description

@dekellum

In the project branch with current head of dekellum/body-image@15b9789, I'm attempting to preview the 2018 edition changes and test cargo fix. Besides my own education the process has uncovered a few issues in my project where I can actually back-port fixes that are also relevant today with rust 1.27.2. Thanks for the 2018 improvements and cargo fix!

I also found one limitation of the module/path changes that seems worth mentioning hear in case its an oversight, and because I can't find any other issue addressing it. It seems as of the rust nightlies I'm testing I still, oddly, need to use extern crate test in the benches/*.

Given starting benches/*.rs benchmarks with the following:

#![feature(test)]
extern crate test;

As of rustc 1.30.0-nightly (\5c875d938 2018-09-24), this produces a warning like in other places, as expected:

warning: `extern crate` is not idiomatic in the new edition                                                                             
--> benches/barc.rs:6:1                                                                                                                
  |                                                                                                                                     
6 | extern crate test;                                                    
  | ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`                                                                                      
  |                                                                                                                                     

However, as of rustc 1.31.0-nightly (\4699283c5 2018-10-13), the warning goes away?

Next, in both of these nightly releases, if I make the expected modification dropping extern crate test and use test::Bencher (see the change of dekellum/body-image@15b9789), I get the following error:

error[E0432]: unresolved import `test`                                                                                                  
  --> benches/async_streams.rs:12:5                                                                                                     
   |                                                                                                                                    
12 | use test::Bencher;                                                                                                                 
   |     ^^^^ Could not find `test` in `{{root}}`                                                                                       

Note finally that I was able to remove all the other extern crate statements for the benches/* dependencies.

I suspect the non-stable, nightly-only nature of libtest benchmarks somehow has contributed to this, but many projects include benches/*. Should this be fixed or at least noted as a shortcoming somewhere?

meta

rustc 1.31.0-nightly (4699283c5 2018-10-13)
binary: rustc
commit-hash: 4699283c5b549d1559c198123a67fef498aa6a44
commit-date: 2018-10-13
host: x86_64-unknown-linux-gnu
release: 1.31.0-nightly
LLVM version: 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions