]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #50670 - alexcrichton:remove-extern-crate-correct-span, r=Manishearth
authorkennytm <kennytm@gmail.com>
Sun, 13 May 2018 08:15:49 +0000 (16:15 +0800)
committerkennytm <kennytm@gmail.com>
Sun, 13 May 2018 09:20:31 +0000 (17:20 +0800)
rustc: Include semicolon when removing `extern crate`

Currently the lint for removing `extern crate` suggests removing `extern crate`
most of the time, but the rest of the time it suggest replacing it with `use
crate_name`. Unfortunately though when spliced into the original code you're
replacing

    extern crate foo;

with

    use foo

which is syntactically invalid! This commit ensure that the trailing semicolon
is included in rustc's suggestion to ensure that the code continues to compile
afterwards.

1  2 
src/librustc_lint/builtin.rs
src/test/ui-fulldeps/unnecessary-extern-crate.stderr

Simple merge
index b0b56f527e64f68c695c5a0141104de6ea91c75f,e27ccaeba0c2be41724df6513b7fcafbb7407f59..ab5457018eda66d9e0a068faa17919396fd78062
@@@ -11,58 -11,58 +11,58 @@@ LL | #![deny(unnecessary_extern_crate)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:17:1
 +  --> $DIR/unnecessary-extern-crate.rs:19:1
     |
  LL | extern crate alloc as x;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x`
+    | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:23:1
 +  --> $DIR/unnecessary-extern-crate.rs:25:1
     |
  LL | pub extern crate test as y;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y`
+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:26:1
 +  --> $DIR/unnecessary-extern-crate.rs:28:1
     |
  LL | pub extern crate libc;
-    | ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use libc`
+    | ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use libc;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:32:5
 +  --> $DIR/unnecessary-extern-crate.rs:34:5
     |
  LL |     extern crate alloc;
-    |     ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc`
+    |     ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:35:5
 +  --> $DIR/unnecessary-extern-crate.rs:37:5
     |
  LL |     extern crate alloc as x;
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x`
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:38:5
 +  --> $DIR/unnecessary-extern-crate.rs:40:5
     |
  LL |     pub extern crate test;
-    |     ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test`
+    |     ^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:41:5
 +  --> $DIR/unnecessary-extern-crate.rs:43:5
     |
  LL |     pub extern crate test as y;
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y`
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `pub use`: `pub use test as y;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:45:9
 +  --> $DIR/unnecessary-extern-crate.rs:47:9
     |
  LL |         extern crate alloc;
-    |         ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc`
+    |         ^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc;`
  
  error: `extern crate` is unnecessary in the new edition
 -  --> $DIR/unnecessary-extern-crate.rs:48:9
 +  --> $DIR/unnecessary-extern-crate.rs:50:9
     |
  LL |         extern crate alloc as x;
-    |         ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x`
+    |         ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `use`: `use alloc as x;`
  
  error: aborting due to 10 previous errors