summaryrefslogtreecommitdiffstats
path: root/src/test/ui/underscore-imports
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/underscore-imports
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/underscore-imports')
-rw-r--r--src/test/ui/underscore-imports/auxiliary/duplicate.rs14
-rw-r--r--src/test/ui/underscore-imports/auxiliary/underscore-imports.rs20
-rw-r--r--src/test/ui/underscore-imports/basic.rs62
-rw-r--r--src/test/ui/underscore-imports/basic.stderr20
-rw-r--r--src/test/ui/underscore-imports/cycle.rs18
-rw-r--r--src/test/ui/underscore-imports/duplicate.rs15
-rw-r--r--src/test/ui/underscore-imports/hygiene-2.rs34
-rw-r--r--src/test/ui/underscore-imports/hygiene.rs40
-rw-r--r--src/test/ui/underscore-imports/intercrate.rs11
-rw-r--r--src/test/ui/underscore-imports/macro-expanded.rs45
-rw-r--r--src/test/ui/underscore-imports/shadow.rs23
-rw-r--r--src/test/ui/underscore-imports/shadow.stderr15
-rw-r--r--src/test/ui/underscore-imports/unused-2018.rs17
-rw-r--r--src/test/ui/underscore-imports/unused-2018.stderr20
14 files changed, 0 insertions, 354 deletions
diff --git a/src/test/ui/underscore-imports/auxiliary/duplicate.rs b/src/test/ui/underscore-imports/auxiliary/duplicate.rs
deleted file mode 100644
index 92d741b6a..000000000
--- a/src/test/ui/underscore-imports/auxiliary/duplicate.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// force-host
-// no-prefer-dynamic
-
-#![crate_type = "proc-macro"]
-
-extern crate proc_macro;
-
-use proc_macro::*;
-
-#[proc_macro_attribute]
-pub fn duplicate(_: TokenStream, input: TokenStream) -> TokenStream {
- let clone = input.clone();
- input.into_iter().chain(clone.into_iter()).collect()
-}
diff --git a/src/test/ui/underscore-imports/auxiliary/underscore-imports.rs b/src/test/ui/underscore-imports/auxiliary/underscore-imports.rs
deleted file mode 100644
index c335336be..000000000
--- a/src/test/ui/underscore-imports/auxiliary/underscore-imports.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#[macro_export]
-macro_rules! do_nothing {
- () => ()
-}
-
-mod m1 {
- pub trait InScope1 {
- fn in_scope1(&self) {}
- }
- impl InScope1 for () {}
-}
-mod m2 {
- pub trait InScope2 {
- fn in_scope2(&self) {}
- }
- impl InScope2 for () {}
-}
-
-pub use m1::InScope1 as _;
-pub use m2::InScope2 as _;
diff --git a/src/test/ui/underscore-imports/basic.rs b/src/test/ui/underscore-imports/basic.rs
deleted file mode 100644
index c021ad5ee..000000000
--- a/src/test/ui/underscore-imports/basic.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// check-pass
-// aux-build:underscore-imports.rs
-
-#![warn(unused_imports, unused_extern_crates)]
-
-#[macro_use]
-extern crate underscore_imports as _;
-
-do_nothing!(); // OK
-
-struct S;
-
-mod m {
- pub trait Tr1 {
- fn tr1_is_in_scope(&self) {}
- }
- pub trait Tr2 {
- fn tr2_is_in_scope(&self) {}
- }
-
- impl Tr1 for ::S {}
- impl Tr2 for ::S {}
-}
-
-mod unused {
- use m::Tr1 as _; //~ WARN unused import
- use S as _; //~ WARN unused import
- extern crate core as _; // OK
-}
-
-mod outer {
- mod middle {
- pub use m::Tr1 as _;
- pub use m::Tr2 as _; // OK, no name conflict
- struct Tr1; // OK, no name conflict
- fn check() {
- // Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
- }
-
- mod inner {
- // `_` imports are fetched by glob imports
- use super::*;
- fn check() {
- // Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
- }
- }
- }
-
- // `_` imports are fetched by glob imports
- use self::middle::*;
- fn check() {
- // Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/underscore-imports/basic.stderr b/src/test/ui/underscore-imports/basic.stderr
deleted file mode 100644
index c51493562..000000000
--- a/src/test/ui/underscore-imports/basic.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-warning: unused import: `m::Tr1 as _`
- --> $DIR/basic.rs:26:9
- |
-LL | use m::Tr1 as _;
- | ^^^^^^^^^^^
- |
-note: the lint level is defined here
- --> $DIR/basic.rs:4:9
- |
-LL | #![warn(unused_imports, unused_extern_crates)]
- | ^^^^^^^^^^^^^^
-
-warning: unused import: `S as _`
- --> $DIR/basic.rs:27:9
- |
-LL | use S as _;
- | ^^^^^^
-
-warning: 2 warnings emitted
-
diff --git a/src/test/ui/underscore-imports/cycle.rs b/src/test/ui/underscore-imports/cycle.rs
deleted file mode 100644
index bacf9b2d5..000000000
--- a/src/test/ui/underscore-imports/cycle.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Check that cyclic glob imports are allowed with underscore imports
-
-// check-pass
-
-mod x {
- pub use crate::y::*;
- pub use std::ops::Deref as _;
-}
-
-mod y {
- pub use crate::x::*;
- pub use std::ops::Deref as _;
-}
-
-pub fn main() {
- use x::*;
- (&0).deref();
-}
diff --git a/src/test/ui/underscore-imports/duplicate.rs b/src/test/ui/underscore-imports/duplicate.rs
deleted file mode 100644
index 20bc7848a..000000000
--- a/src/test/ui/underscore-imports/duplicate.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// check-pass
-// aux-build:duplicate.rs
-
-extern crate duplicate;
-
-#[duplicate::duplicate]
-use main as _; // OK
-
-macro_rules! duplicate {
- ($item: item) => { $item $item }
-}
-
-duplicate!(use std as _;); // OK
-
-fn main() {}
diff --git a/src/test/ui/underscore-imports/hygiene-2.rs b/src/test/ui/underscore-imports/hygiene-2.rs
deleted file mode 100644
index 510d91d0d..000000000
--- a/src/test/ui/underscore-imports/hygiene-2.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Make sure that underscore imports with different contexts can exist in the
-// same scope.
-
-// check-pass
-
-#![feature(decl_macro)]
-
-mod x {
- pub use std::ops::Deref as _;
-}
-
-macro n() {
- pub use crate::x::*;
-}
-
-#[macro_export]
-macro_rules! p {
- () => { pub use crate::x::*; }
-}
-
-macro m($y:ident) {
- mod $y {
- crate::n!(); // Reexport of `Deref` should not be imported in `main`
- crate::p!(); // Reexport of `Deref` should be imported into `main`
- }
-}
-
-m!(y);
-
-fn main() {
- use crate::y::*;
- #[allow(noop_method_call)]
- (&()).deref();
-}
diff --git a/src/test/ui/underscore-imports/hygiene.rs b/src/test/ui/underscore-imports/hygiene.rs
deleted file mode 100644
index c4db65245..000000000
--- a/src/test/ui/underscore-imports/hygiene.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Make sure that underscore imports have the same hygiene considerations as other imports.
-
-// check-pass
-
-#![feature(decl_macro)]
-
-mod x {
- pub use std::ops::Deref as _;
-}
-
-macro glob_import() {
- pub use crate::x::*;
-}
-
-macro underscore_import() {
- use std::ops::DerefMut as _;
-}
-
-mod y {
- crate::glob_import!();
- crate::underscore_import!();
-}
-
-macro create_module($y:ident) {
- mod $y {
- crate::glob_import!();
- crate::underscore_import!();
- }
-}
-
-create_module!(z);
-
-fn main() {
- use crate::y::*;
- use crate::z::*;
- glob_import!();
- underscore_import!();
- (&()).deref();
- (&mut ()).deref_mut();
-}
diff --git a/src/test/ui/underscore-imports/intercrate.rs b/src/test/ui/underscore-imports/intercrate.rs
deleted file mode 100644
index 144f95bac..000000000
--- a/src/test/ui/underscore-imports/intercrate.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// check-pass
-// aux-build:underscore-imports.rs
-
-extern crate underscore_imports;
-
-use underscore_imports::*;
-
-fn main() {
- ().in_scope1();
- ().in_scope2();
-}
diff --git a/src/test/ui/underscore-imports/macro-expanded.rs b/src/test/ui/underscore-imports/macro-expanded.rs
deleted file mode 100644
index 43f527bc9..000000000
--- a/src/test/ui/underscore-imports/macro-expanded.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Check that macro expanded underscore imports behave as expected
-
-// check-pass
-
-#![feature(decl_macro, rustc_attrs)]
-
-mod x {
- pub use std::ops::Not as _;
-}
-
-macro m() {
- mod w {
- mod y {
- pub use std::ops::Deref as _;
- }
- use crate::x::*;
- use self::y::*;
- use std::ops::DerefMut as _;
- fn f() {
- false.not();
- (&()).deref();
- (&mut ()).deref_mut();
- }
- }
-}
-
-#[rustc_macro_transparency = "transparent"]
-macro n() {
- mod z {
- pub use std::ops::Deref as _;
- }
- use crate::x::*;
- use crate::z::*;
- use std::ops::DerefMut as _;
- fn f() {
- false.not();
- (&()).deref();
- (&mut ()).deref_mut();
- }
-}
-
-m!();
-n!();
-
-fn main() {}
diff --git a/src/test/ui/underscore-imports/shadow.rs b/src/test/ui/underscore-imports/shadow.rs
deleted file mode 100644
index 325f2001b..000000000
--- a/src/test/ui/underscore-imports/shadow.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Check that underscore imports don't cause glob imports to be unshadowed
-
-mod a {
- pub use std::ops::Deref as Shadow;
-}
-
-mod b {
- pub use crate::a::*;
- macro_rules! m {
- ($i:ident) => { pub struct $i; }
- }
- m!(Shadow);
-}
-
-mod c {
- use crate::b::Shadow as _; // Only imports the struct
-
- fn f(x: &()) {
- x.deref(); //~ ERROR no method named `deref` found
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/underscore-imports/shadow.stderr b/src/test/ui/underscore-imports/shadow.stderr
deleted file mode 100644
index 7faede4e6..000000000
--- a/src/test/ui/underscore-imports/shadow.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0599]: no method named `deref` found for reference `&()` in the current scope
- --> $DIR/shadow.rs:19:11
- |
-LL | x.deref();
- | ^^^^^ method not found in `&()`
- |
- = help: items from traits can only be used if the trait is in scope
-help: the following trait is implemented but not in scope; perhaps add a `use` for it:
- |
-LL | use std::ops::Deref;
- |
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/underscore-imports/unused-2018.rs b/src/test/ui/underscore-imports/unused-2018.rs
deleted file mode 100644
index d06a26a5f..000000000
--- a/src/test/ui/underscore-imports/unused-2018.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// edition:2018
-
-#![deny(unused_imports)]
-
-mod multi_segment {
- use core::any; //~ ERROR unused import: `core::any`
-}
-
-mod single_segment {
- use core; //~ ERROR unused import: `core`
-}
-
-mod single_segment_underscore {
- use core as _; // OK
-}
-
-fn main() {}
diff --git a/src/test/ui/underscore-imports/unused-2018.stderr b/src/test/ui/underscore-imports/unused-2018.stderr
deleted file mode 100644
index 2afb9a10e..000000000
--- a/src/test/ui/underscore-imports/unused-2018.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: unused import: `core::any`
- --> $DIR/unused-2018.rs:6:9
- |
-LL | use core::any;
- | ^^^^^^^^^
- |
-note: the lint level is defined here
- --> $DIR/unused-2018.rs:3:9
- |
-LL | #![deny(unused_imports)]
- | ^^^^^^^^^^^^^^
-
-error: unused import: `core`
- --> $DIR/unused-2018.rs:10:9
- |
-LL | use core;
- | ^^^^
-
-error: aborting due to 2 previous errors
-