]> git.lizzy.rs Git - rust.git/commitdiff
Add test for current behaviour.
authorDavid Wood <david@davidtw.co>
Thu, 25 Apr 2019 06:53:06 +0000 (07:53 +0100)
committerDavid Wood <david@davidtw.co>
Thu, 25 Apr 2019 06:53:06 +0000 (07:53 +0100)
This commit adds a test that causes a suggestion to replace `extern
crate` with `use` when doing so would cause a compliation error, as the
new name of the import would not be added to the prelude if a `use` was
used.

src/test/ui/suggestions/issue-57672.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-57672.stderr [new file with mode: 0644]

diff --git a/src/test/ui/suggestions/issue-57672.rs b/src/test/ui/suggestions/issue-57672.rs
new file mode 100644 (file)
index 0000000..c8ea6e5
--- /dev/null
@@ -0,0 +1,14 @@
+// aux-build:foo.rs
+// compile-flags:--extern foo
+// edition:2018
+
+#![deny(unused_extern_crates)]
+
+extern crate foo as foo_renamed;
+//~^ ERROR `extern crate` is not idiomatic in the new edition
+
+pub mod m {
+    pub use foo_renamed::Foo;
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/issue-57672.stderr b/src/test/ui/suggestions/issue-57672.stderr
new file mode 100644 (file)
index 0000000..c9e4c37
--- /dev/null
@@ -0,0 +1,14 @@
+error: `extern crate` is not idiomatic in the new edition
+  --> $DIR/issue-57672.rs:7:1
+   |
+LL | extern crate foo as foo_renamed;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
+   |
+note: lint level defined here
+  --> $DIR/issue-57672.rs:5:9
+   |
+LL | #![deny(unused_extern_crates)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+