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

merge unused-extern-crate and unnecessary-extern-crate lints #51015

Merged

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented May 24, 2018

Extend the unused_extern_crates lint to offer a suggestion to remove the extern crate and remove the unnecessary_extern_crate lint.

Still a few minor issues to fix:

Spun off from #51010

Fixes #50672

r? @alexcrichton

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
    100% |████████████████████████████████| 4.2MB 276kB/s 
Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl (72kB)
    14% |████▌                           | 10kB 32.7MB/s eta 0:00:01
    28% |█████████                       | 20kB 36.5MB/s eta 0:00:01
    42% |█████████████▌                  | 30kB 42.7MB/s eta 0:00:01
    56% |██████████████████              | 40kB 44.8MB/s eta 0:00:01
---
[00:50:40] ....................................................................................................
[00:50:45] ....................................................................................................
[00:50:50] ...........................................................................i........................
[00:50:55] ....................................................i...............................................
[00:51:00] ........................................................................i.i.................F.......
[00:51:06] ......F.............................................................................................
[00:51:12] .....................................................................F.............i................
[00:51:15] .iiiiiiiii...................................................
[00:51:15] 
[00:51:15] ---- [ui] ui/rfc-2166-underscore-imports/basic.rs stdout ----
[00:51:15] diff of stderr:
[00:51:15] 
[00:51:15] 
[00:51:15] 20   --> $DIR/basic.rs:33:5
[00:51:15] 21    |
[00:51:15] 22 LL |     extern crate core as _; //~ WARN unused extern crate
[00:51:15] +    |     ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
[00:51:15] 24    |
[00:51:15] 25 note: lint level defined here
[00:51:15] 26   --> $DIR/basic.rs:14:25
[00:51:15] 26   --> $DIR/basic.rs:14:25
[00:51:15] 
[00:51:15] 
[00:51:15] The actual stderr differed from the expected stderr.
[00:51:15] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2166-underscore-imports/basic/basic.stderr
[00:51:15] To update references, rerun the tests and pass the `--bless` flag
[00:51:15] To only update this specific test, also pass `--test-args rfc-2166-underscore-imports/basic.rs`
[00:51:15] error: 1 errors occurred comparing output.
[00:51:15] status: exit code: 0
[00:51:15] status: exit code: 0
[00:51:15] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2166-underscore-imports/basic/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2166-underscore-imports/basic/auxiliary" "-A" "unused"
[00:51:15] ------------------------------------------
[00:51:15] 
[00:51:15] ------------------------------------------
[00:51:15] stderr:
[00:51:15] stderr:
[00:51:15] ------------------------------------------
[00:51:15] {"message":"unused import: `m::Tr1 as _`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":782,"byte_end":793,"line_start":31,"line_end":31,"column_start":9,"column_end":20,"is_primary":true,"text":[{"text":"    use m::Tr1 as _; //~ WARN unused import","highlight_start":9,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":524,"byte_end":538,"line_start":14,"line_end":14,"column_start":9,"column_end":23,"is_primary":true,"text":[{"text":"#![warn(unused_imports, unused_extern_crates)]","highlight_start":9,"highlight_end":23}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused import: `m::Tr1 as _`\n  --> /checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs:31:9\n   |\nLL |     use m::Tr1 as _; //~ WARN unused import\n   |         ^^^^^^^^^^^\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs:14:9\n   |\nLL | #![warn(unused_imports, unused_extern_crates)]\n   |         ^^^^^^^^^^^^^^\n\n"}
[00:51:15] {"message":"unused import: `S as _`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":826,"byte_end":832,"line_start":32,"line_end":32,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"    use S as _; //~ WARN unused import","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: unused import: `S as _`\n  --> /checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs:32:9\n   |\nLL |     use S as _; //~ WARN unused import\n   |         ^^^^^^\n\n"}
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":861,"byte_end":884,"line_start":33,"line_end":33,"column_start":5,"column_end":28,"is_primary":true,"text":[{"text":"    extern crate core as _; //~ WARN unused extern crate","highlight_start":5,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":540,"byte_end":560,"line_start":14,"line_end":14,"column_start":25,"column_end":45,"is_primary":true,"text":[{"text":"#![warn(unused_imports, unused_extern_crates)]","highlight_start":25,"highlight_end":45}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs","byte_start":861,"byte_end":884,"line_start":33,"line_end":33,"column_start":5,"column_end":28,"is_primary":true,"text":[{"text":"    extern crate core as _; //~ WARN unused extern crate","highlight_start":5,"highlight_end":28}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused extern crate\n  --> /checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs:33:5\n   |\nLL |     extern crate core as _; //~ WARN unused extern crate\n   |     ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/rfc-2166-underscore-imports/basic.rs:14:25\n   |\nLL | #![warn(unused_imports, unused_extern_crates)]\n   |                         ^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:51:15] ------------------------------------------
[00:51:15] 
[00:51:15] thread '[ui] ui/rfc-2166-underscore-imports/basic.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3044:9
[00:51:15] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:15] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:51:15] 
[00:51:15] ---- [ui] ui/rust-2018/extern-crate-idiomatic-in-2018.rs stdout ----
[00:51:15] 
[00:51:15] 7 note: lint level defined here
[00:51:15] 7 note: lint level defined here
[00:51:15] 8   --> $DIR/extern-crate-idiomatic-in-2018.rs:20:9
[00:51:15] 9    |
[00:51:15] - LL | #![deny(unused_extern_crates)]
[00:51:15] -    |         ^^^^^^^^^^^^^^^^^^^^
[00:51:15] + LL | #![deny(rust_2018_idioms)]
[00:51:15] +    |         ^^^^^^^^^^^^^^^^
[00:51:15] +    = note: #[deny(unused_extern_crates)] implied by #[deny(rust_2018_idioms)]
[00:51:15] 13 error: aborting due to previous error
[00:51:15] 14 
[00:51:15] 
[00:51:15] 
[00:51:15] 
[00:51:15] The actual stderr differed from the expected stderr.
[00:51:15] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rust-2018/extern-crate-idiomatic-in-2018/extern-crate-idiomatic-in-2018.stderr
[00:51:15] diff of fixed:
[00:51:15] 17 
[00:51:15] 17 
[00:51:15] 18 #![feature(rust_2018_preview)]
[00:51:15] 19 #![deny(absolute_path_not_starting_with_crate)]
[00:51:15] - #![deny(unused_extern_crates)]
[00:51:15] + #![deny(rust_2018_idioms)]
[00:51:15] 21 #![allow(dead_code)]
[00:51:15] 23 
[00:51:15] 
[00:51:15] 
[00:51:15] The actual fixed differed from the expected fixed.
[00:51:15] The actual fixed differed from the expected fixed.
[00:51:15] Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rust-2018/extern-crate-idiomatic-in-2018/extern-crate-idiomatic-in-2018.fixed
[00:51:15] To update references, rerun the tests and pass the `--bless` flag
[00:51:15] To only update this specific test, also pass `--test-args rust-2018/extern-crate-idiomatic-in-2018.rs`
[00:51:15] error: 2 errors occurred comparing output.
[00:51:15] status: exit code: 101
[00:51:15] status: exit code: 101
[00:51:15] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rust-2018/extern-crate-idiomatic-in-2018/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition" "2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rust-2018/extern-crate-idiomatic-in-2018/auxiliary" "-A" "unused"
[00:51:15] ------------------------------------------
[00:51:15] 
[00:51:15] ------------------------------------------
[00:51:15] stderr:
[00:51:15] stderr:
[00:51:15] ------------------------------------------
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs","byte_start":767,"byte_end":799,"line_start":23,"line_end":23,"column_start":1,"column_end":33,"is_primary":true,"text":[{"text":"extern crate edition_lint_paths;","highlight_start":1,"highlight_end":33}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs","byte_start":726,"byte_end":742,"line_start":20,"line_end":20,"column_start":9,"column_end":25,"is_primary":true,"text":[{"text":"#![deny(rust_2018_idioms)]","highlight_start":9,"highlight_end":25}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[deny(unused_extern_crates)] implied by #[deny(rust_2018_idioms)]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs","byte_start":767,"byte_end":799,"line_start":23,"line_end":23,"column_start":1,"column_end":33,"is_primary":true,"text":[{"text":"extern crate edition_lint_paths;","highlight_start":1,"highlight_end":33}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unused extern crate\n  --> /checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs:23:1\n   |\nLL | extern crate edition_lint_paths;\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/rust-2018/extern-crate-idiomatic-in-2018.rs:20:9\n   |\nLL | #![deny(rust_2018_idioms)]\n   |         ^^^^^^^^^^^^^^^^\n   = note:[00:51:15] 
[00:51:15] 18    | ^^^^^^^^^^^^^^^^^^ help: remove it
[00:51:15] 19 
[00:51:15] - warning: `extern crate` is unnecessary in the new edition
[00:51:15] + warning: unused extern crate
[00:51:15] 22    |
[00:51:15] 22    |
[00:51:15] 23 LL |     extern crate std as foo;
[00:51:15] 
[00:51:15] -    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use std as foo;`
[00:51:15] +    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
[00:51:15] 25 
[00:51:15] - warning: `extern crate` is unnecessary in the new edition
[00:51:15] + warning: unused extern crate
[00:51:15] 28    |
[00:51:15] 28    |
[00:51:15] 29 LL |     extern crate std;
[00:51:15] 
[00:51:15] -    |     ^^^^^^^^^^^^^^^^^ help: use `use`: `use std;`
[00:51:15] +    |     ^^^^^^^^^^^^^^^^^ help: remove it
[00:51:15] 32 
[00:51:15] 
[00:51:15] 
[00:51:15] The actual stderr differed from the expected stderr.
[00:51:15] The actual stderr differed from the expected stderr.
[00:51:15] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/removing-extern-crate/removing-extern-crate.stderr
[00:51:15] diff of fixed:
[00:51:15] 
[00:51:15] 16 #![warn(rust_2018_idioms)]
[00:51:15] 17 #![allow(unused_imports)]
[00:51:15] 18 
[00:51:15] - use std as foo;
[00:51:15] 21 
[00:51:15] + 
[00:51:15] + 
[00:51:15] 22 mod another {
[00:51:15] -     use std as foo;
[00:51:15] -     use std;
[00:51:15] +     
[00:51:15] 25 }
[00:51:15] 26 
[00:51:15] 26 
[00:51:15] 27 fn main() {}
[00:51:15] 
[00:51:15] The actual fixed differed from the expected fixed.
[00:51:15] The actual fixed differed from the expected fixed.
[00:51:15] Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/removing-extern-crate/removing-extern-crate.fixed
[00:51:15] To update references, rerun the tests and pass the `--bless` flag
[00:51:15] To only update this specific test, also pass `--test-args suggestions/removing-extern-crate.rs`
[00:51:15] error: 2 errors occurred comparing output.
[00:51:15] status: exit code: 0
[00:51:15] status: exit code: 0
[00:51:15] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/suggestions/removing-extern-crate.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/removing-extern-crate/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition" "2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/removing-extern-crate/auxiliary" "-A" "unused"
[00:51:15] ------------------------------------------
[00:51:15] 
[00:51:15] ------------------------------------------
[00:51:15] stderr:
[00:51:15] stderr:
[00:51:15] ------------------------------------------
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":624,"byte_end":648,"line_start":19,"line_end":19,"column_start":1,"column_end":25,"is_primary":true,"text":[{"text":"extern crate std as foo;","highlight_start":1,"highlight_end":25}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":578,"byte_end":594,"line_start":16,"line_end":16,"column_start":9,"column_end":25,"is_primary":true,"text":[{"text":"#![warn(rust_2018_idioms)]","highlight_start":9,"highlight_end":25}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":624,"byte_end":648,"line_start":19,"line_end":19,"column_start":1,"column_end":25,"is_primary":true,"text":[{"text":"extern crate std as foo;","highlight_start":1,"highlight_end":25}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused extern crate\n  --> /checkout/src/test/ui/suggestions/removing-extern-crate.rs:19:1\n   |\nLL | extern crate std as foo;\n   | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/suggestions/removing-extern-crate.rs:16:9\n   |\nLL | #![warn(rust_2018_idioms)]\n   |         ^^^^^^^^^^^^^^^^\n   = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]\n\n"}
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":649,"byte_end":667,"line_start":20,"line_end":20,"column_start":1,"column_end":19,"is_primary":true,"text":[{"text":"extern crate core;","highlight_start":1,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":649,"byte_end":667,"line_start":20,"line_end":20,"column_start":1,"column_end":19,"is_primary":true,"text":[{"text":"extern crate core;","highlight_start":1,"highlight_end":19}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused extern crate\n  --> /checkout/src/test/ui/suggestions/removing-extern-crate.rs:20:1\n   |\nLL | extern crate core;\n   | ^^^^^^^^^^^^^^^^^^ help: remove it\n\n"}
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":687,"byte_end":711,"line_start":23,"line_end":23,"column_start":5,"column_end":29,"is_primary":true,"text":[{"text":"    extern crate std as foo;","highlight_start":5,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":687,"byte_end":711,"line_start":23,"line_end":23,"column_start":5,"column_end":29,"is_primary":true,"text":[{"text":"    extern crate std as foo;","highlight_start":5,"highlight_end":29}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused extern crate\n  --> /checkout/src/test/ui/suggestions/removing-extern-crate.rs:23:5\n   |\nLL |     extern crate std as foo;\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it\n\n"}
[00:51:15] {"message":"unused extern crate","code":{"code":"unused_extern_crates","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":716,"byte_end":733,"line_start":24,"line_end":24,"column_start":5,"column_end":22,"is_primary":true,"text":[{"text":"    extern crate std;","highlight_start":5,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove it","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/suggestions/removing-extern-crate.rs","byte_start":716,"byte_end":733,"line_start":24,"line_end":24,"column_start":5,"column_end":22,"is_primary":true,"text":[{"text":"    extern crate std;","highlight_start":5,"highlight_end":22}],"label":null,"suggested_replacement":"","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused extern cratcck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:51:15] 
[00:51:15] 
[00:51:15] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:51:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:15] Build completed unsuccessfully in 0:02:44
[00:51:15] make: *** [check] Error 1
[00:51:15] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:01198c74
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

Seems like a fine idea to me! I haven't personally looked too closely at this lint yet for removing extern crate annotations, but fusing lints seems fine by me :)

@bors
Copy link
Contributor

bors commented May 25, 2018

☔ The latest upstream changes (presumably #50879) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from 3ee1606 to 8eedba0 Compare May 25, 2018 21:06
@nikomatsakis
Copy link
Contributor Author

ok I added the pub use logic etc back in, but I need to do more tests

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from 8eedba0 to 295046d Compare May 25, 2018 21:09
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:04:38] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:38] tidy error: /checkout/src/librustc_typeck/check_unused.rs:156: line longer than 100 chars
[00:04:39] some tidy checks failed
[00:04:39] 
[00:04:39] 
[00:04:39] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:39] 
[00:04:39] 
[00:04:39] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:39] Build completed unsuccessfully in 0:01:50
[00:04:39] Build completed unsuccessfully in 0:01:50
[00:04:39] make: *** [tidy] Error 1
[00:04:39] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2c96fa88
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from 295046d to f2ddd1d Compare May 26, 2018 01:23
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Requirement already satisfied: PyYAML<=3.12,>=3.10 in /usr/lib/python2.7/dist-packages (from awscli)
Collecting botocore==1.10.28 (from awscli)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/2e/91/f0870d4de8eb78897ce781f3ff22fc492bbb9849b5c91f26db20b125ef36/botocore-1.10.28-py2.py3-none-any.whl (4.2MB)
    0% |                                | 10kB 43.2MB/s eta 0:00:01
    0% |▏                               | 20kB 38.7MB/s eta 0:00:01
    0% |▎                               | 30kB 43.6MB/s eta 0:00:01
    0% |▎                               | 40kB 19.2MB/s eta 0:00:01
---

[00:05:50] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:51] tidy error: /checkout/src/librustc_typeck/check_unused.rs:156: line longer than 100 chars
[00:05:52] some tidy checks failed
[00:05:52] 
[00:05:52] 
[00:05:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:52] 
[00:05:52] 
[00:05:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:52] Build completed unsuccessfully in 0:02:29
[00:05:52] Build completed unsuccessfully in 0:02:29
[00:05:52] make: *** [tidy] Error 1
[00:05:52] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:057af42d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

r=me when this is passing travis!

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch 2 times, most recently from 3583475 to 85bf5b0 Compare May 28, 2018 16:36
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:41:09]    Compiling aho-corasick v0.6.4
[00:41:16]    Compiling tempdir v0.3.7
[00:41:55]    Compiling minifier v0.0.11
[00:41:58]    Compiling rustdoc v0.0.0 (file:///checkout/src/librustdoc)
[00:41:59] error[E0532]: expected unit struct/variant or constant, found tuple variant `hir::Visibility::Crate`
[00:41:59]     --> librustdoc/clean/mod.rs:3033:13
[00:41:59]      |
[00:41:59] 3033 |             hir::Visibility::Crate => Visibility::Crate,
[00:41:59]      |             ^^^^^^^^^^^^^^^^^^^^^^ not a unit struct/variant or constant
[00:41:59] help: possible better candidates are found in other modules, you can import them into scope
[00:41:59] 14   | use clean::Visibility::Crate;
[00:41:59]      |
[00:41:59]      |
[00:41:59] 14   | use rustc::session::search_paths::PathKind::Crate;
[00:41:59] 14   | use syntax_pos::symbol::keywords::Crate;
[00:41:59]      |
[00:41:59] 
[00:42:16] error: aborting due to previous error
---
[00:42:16] 
[00:42:16] 
[00:42:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:42:16] Build completed unsuccessfully in 0:36:32
[00:42:16] Makefile:28: recipe for target 'all' failed
[00:42:16] make: *** [all] Error 1
18668 ./obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release
18316 ./obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps
15152 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu
15148 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from 85bf5b0 to da0e605 Compare May 28, 2018 18:12
@nikomatsakis nikomatsakis changed the title [WIP] merge unused-extern-crate and unnecessary-extern-crate lints merge unused-extern-crate and unnecessary-extern-crate lints May 28, 2018
@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from da0e605 to b0d6b75 Compare May 28, 2018 18:13
@nikomatsakis
Copy link
Contributor Author

This is gonna break clippy cc @Manishearth and @oli-obk — but pretty trivial change.

@nikomatsakis
Copy link
Contributor Author

@bors r=acrichto

@bors
Copy link
Contributor

bors commented May 28, 2018

📌 Commit b0d6b75 has been approved by acrichto

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2018
@bors
Copy link
Contributor

bors commented May 28, 2018

🔒 Merge conflict

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 28, 2018
@bors
Copy link
Contributor

bors commented May 28, 2018

☔ The latest upstream changes (presumably #50929) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from b0d6b75 to d3b30b1 Compare May 29, 2018 09:16
@nikomatsakis
Copy link
Contributor Author

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented May 29, 2018

📌 Commit d3b30b1 has been approved by alexcrichton

@andjo403
Copy link
Contributor

@nikomatsakis shall this lint also work with unused extern crates from the --extern flag to rustc?
have been thinking that it can be the only way to find if unused crates is added to the toml file.

@nikomatsakis
Copy link
Contributor Author

@andjo403 that would be a nice extension; it doesn't now though. Ideally, we'd have some way to point into the Cargo.toml...

@bors
Copy link
Contributor

bors commented May 29, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 29, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-aux of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:46:27]     Updating git repository `https://github.com/servo/gaol`
[01:46:27]     Updating git repository `https://github.com/servo/devices`
[01:46:28]     Updating git repository `https://github.com/servo/rust-azure`
[01:46:29]     Updating git repository `https://github.com/servo/fontsan`
[01:54:30] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:54:30] ; class=Net (12)
[01:58:17] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:58:17] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:58:17] ; class=Net (12)
[02:04:45]     Updating git repository `https://github.com/energymon/energymon-sys.git`
[02:04:46]     Updating git repository `https://github.com/djg/cubeb-pulse-rs`
[02:04:47]  Downloading libc v0.2.33
[02:05:02]  Downloading atomic_refcell v0.1.0
---
[02:14:41] fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
[02:14:42] From https://github.com/Aaronepower/tokei
[02:14:42]  * branch            master     -> FETCH_HEAD
[02:14:42] fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
[02:18:16] fatal: unable to access 'https://github.com/Aaronepower/tokei/': Failed to connect to github.com port 443: Connection timed out
[02:18:16] thread 'main' panicked at 'assertion failed: status.success()', tools/cargotest/main.rs:128:13
[02:18:16] 
[02:18:16] 
[02:18:16] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/cargotest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "/checkout/obj/build/ct"
[02:18:16] expected success, got: exit code: 101
[02:18:16] expected success, got: exit code: 101
[02:18:16] 
[02:18:16] 
[02:18:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/test/pretty src/test/run-pass/pretty src/test/run-fail/pretty src/test/run-pass-valgrind/pretty src/test/run-pass-fulldeps/pretty src/test/run-fail-fulldeps/pretty src/tools/cargo src/tools/cargotest
[02:18:16] Build completed unsuccessfully in 1:12:46
[02:18:16] make: *** [check-aux] Error 1
[02:18:16] Makefile:60: recipe for target 'check-aux' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1dd4b6ac
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-aux of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:46:27]     Updating git repository `https://github.com/servo/gaol`
[01:46:27]     Updating git repository `https://github.com/servo/devices`
[01:46:28]     Updating git repository `https://github.com/servo/rust-azure`
[01:46:29]     Updating git repository `https://github.com/servo/fontsan`
[01:54:30] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:54:30] ; class=Net (12)
[01:58:17] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:58:17] warning: spurious network error (2 tries remaining): curl error: Failed to connect to github.com port 443: Connection timed out
[01:58:17] ; class=Net (12)
[02:04:45]     Updating git repository `https://github.com/energymon/energymon-sys.git`
[02:04:46]     Updating git repository `https://github.com/djg/cubeb-pulse-rs`
[02:04:47]  Downloading libc v0.2.33
[02:05:02]  Downloading atomic_refcell v0.1.0
---
[02:14:41] fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
[02:14:42] From https://github.com/Aaronepower/tokei
[02:14:42]  * branch            master     -> FETCH_HEAD
[02:14:42] fatal: Could not parse object '5e11c4852fe4aa086b0e4fe5885822fbe57ba928'.
[02:18:16] fatal: unable to access 'https://github.com/Aaronepower/tokei/': Failed to connect to github.com port 443: Connection timed out
[02:18:16] thread 'main' panicked at 'assertion failed: status.success()', tools/cargotest/main.rs:128:13
[02:18:16] 
[02:18:16] 
[02:18:16] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/cargotest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "/checkout/obj/build/ct"
[02:18:16] expected success, got: exit code: 101
[02:18:16] expected success, got: exit code: 101
[02:18:16] 
[02:18:16] 
[02:18:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/test/pretty src/test/run-pass/pretty src/test/run-fail/pretty src/test/run-pass-valgrind/pretty src/test/run-pass-fulldeps/pretty src/test/run-fail-fulldeps/pretty src/tools/cargo src/tools/cargotest
[02:18:16] Build completed unsuccessfully in 1:12:46
[02:18:16] make: *** [check-aux] Error 1
[02:18:16] Makefile:60: recipe for target 'check-aux' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1dd4b6ac
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@kennytm
Copy link
Member

kennytm commented May 30, 2018

@bors retry p=29 #40474

[02:18:16] fatal: unable to access 'https://github.com/Aaronepower/tokei/': Failed to connect to github.com port 443: Connection timed out

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2018
@bors
Copy link
Contributor

bors commented May 30, 2018

🔒 Merge conflict

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
@nikomatsakis nikomatsakis force-pushed the issue-50672-remove-extern-crate-idiom branch from 7b7901b to b37cc85 Compare June 2, 2018 00:33
@kennytm
Copy link
Member

kennytm commented Jun 2, 2018

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Jun 2, 2018

📌 Commit b37cc85 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2018
@bors
Copy link
Contributor

bors commented Jun 2, 2018

⌛ Testing commit b37cc85 with merge 1b3d737...

bors added a commit that referenced this pull request Jun 2, 2018
…diom, r=alexcrichton

merge unused-extern-crate and unnecessary-extern-crate lints

Extend the `unused_extern_crates` lint to offer a suggestion to remove the extern crate and remove the `unnecessary_extern_crate` lint.

Still a few minor issues to fix:
- [x] this *does* now leave a blank line... (defer to #51176)
  - idea: extend the span to be replaced by 1 character if the next character is a `\n`
- [x] what about macros? do we need to watch out for that? (defer to #48704)
- [x] also it doesn't work for `extern crate foo; fn main() { foo::bar(); }`
  - this is subtle: the `foo` might be shadowing a glob import too, can't always remove
  - defer to #51177
- [x] we also don't do the `pub use` rewrite thang (#51013)

Spun off from #51010

Fixes #50672

r? @alexcrichton
@bors
Copy link
Contributor

bors commented Jun 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 1b3d737 to master...

@bors bors merged commit b37cc85 into rust-lang:master Jun 2, 2018
@SimonSapin
Copy link
Contributor

Does unused_extern_crates now warn by default?

fn main() {}
fn main() {
unsafe { a::getpid(); }
unsafe { b::getpid(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these calls testing? As per #49219 (comment), these don't exist on wasm32, is there a suitable replacement for libc?
Or should I just ignore the test on wasm32 (ideally I wouldn't).

cc @petrochenkov @alexcrichton

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that they make a, b, etc used, so they report "extern crate is not idiomatic" rather than "extern crate is unused".

AFAIK, libc has universally available names like c_int or c_void, so they can be used instead.

type A = a::c_int; // Makes `a` used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, wasm32 has an empty libc last I checked. Maybe we can flip alloc and libc, as I expect alloc to not be empty on wasm32?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alloc would do too.
Or a new custom crate in the auxiliary dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint for removing extern crate has false positive when crate is used
10 participants