diff --git a/tests/ui/filter-block-view-items.rs b/tests/ui/cfg/cfg-false-use-item.rs similarity index 72% rename from tests/ui/filter-block-view-items.rs rename to tests/ui/cfg/cfg-false-use-item.rs index cb599c2726470..d37b48cdedb77 100644 --- a/tests/ui/filter-block-view-items.rs +++ b/tests/ui/cfg/cfg-false-use-item.rs @@ -1,3 +1,5 @@ +//! Test that use items with cfg(false) are properly filtered out + //@ run-pass pub fn main() { diff --git a/tests/ui/illegal-ufcs-drop.fixed b/tests/ui/drop/explicit-drop-call-error.fixed similarity index 75% rename from tests/ui/illegal-ufcs-drop.fixed rename to tests/ui/drop/explicit-drop-call-error.fixed index 2b1c967ed1e07..f2f0245df96ff 100644 --- a/tests/ui/illegal-ufcs-drop.fixed +++ b/tests/ui/drop/explicit-drop-call-error.fixed @@ -1,3 +1,5 @@ +//! Test error for explicit destructor method calls via UFCS + //@ run-rustfix #![allow(dropping_references)] diff --git a/tests/ui/illegal-ufcs-drop.rs b/tests/ui/drop/explicit-drop-call-error.rs similarity index 75% rename from tests/ui/illegal-ufcs-drop.rs rename to tests/ui/drop/explicit-drop-call-error.rs index 99dda0dab3406..e41c806bd1e0d 100644 --- a/tests/ui/illegal-ufcs-drop.rs +++ b/tests/ui/drop/explicit-drop-call-error.rs @@ -1,3 +1,5 @@ +//! Test error for explicit destructor method calls via UFCS + //@ run-rustfix #![allow(dropping_references)] diff --git a/tests/ui/illegal-ufcs-drop.stderr b/tests/ui/drop/explicit-drop-call-error.stderr similarity index 88% rename from tests/ui/illegal-ufcs-drop.stderr rename to tests/ui/drop/explicit-drop-call-error.stderr index 4f214a12747e4..95d5c31ab6d05 100644 --- a/tests/ui/illegal-ufcs-drop.stderr +++ b/tests/ui/drop/explicit-drop-call-error.stderr @@ -1,5 +1,5 @@ error[E0040]: explicit use of destructor method - --> $DIR/illegal-ufcs-drop.rs:12:5 + --> $DIR/explicit-drop-call-error.rs:14:5 | LL | Drop::drop(&mut Foo) | ^^^^^^^^^^ diff --git a/tests/ui/format-no-std.rs b/tests/ui/fmt/format-macro-no-std.rs similarity index 81% rename from tests/ui/format-no-std.rs rename to tests/ui/fmt/format-macro-no-std.rs index 657b210a9a0b4..d096b4de01390 100644 --- a/tests/ui/format-no-std.rs +++ b/tests/ui/fmt/format-macro-no-std.rs @@ -1,3 +1,5 @@ +//! Test format! macro functionality in no_std environment + //@ run-pass //@ ignore-emscripten no no_std executables //@ ignore-wasm different `main` convention @@ -9,7 +11,8 @@ // Import global allocator and panic handler. extern crate std as other; -#[macro_use] extern crate alloc; +#[macro_use] +extern crate alloc; use alloc::string::ToString; @@ -21,7 +24,7 @@ extern "C" fn main(_argc: core::ffi::c_int, _argv: *const *const u8) -> core::ff let s = format!("test"); assert_eq!(s, "test".to_string()); - let s = format!("{test}", test=3_isize); + let s = format!("{test}", test = 3_isize); assert_eq!(s, "3".to_string()); let s = format!("hello {}", "world"); diff --git a/tests/ui/fun-indirect-call.rs b/tests/ui/fun-indirect-call.rs deleted file mode 100644 index 7919be07f7e46..0000000000000 --- a/tests/ui/fun-indirect-call.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -fn f() -> isize { return 42; } - -pub fn main() { - let g: fn() -> isize = f; - let i: isize = g(); - assert_eq!(i, 42); -} diff --git a/tests/ui/future-incompatible-lint-group.rs b/tests/ui/future-incompatible-lint-group.rs deleted file mode 100644 index ed2c47bb60907..0000000000000 --- a/tests/ui/future-incompatible-lint-group.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Ensure that the future_incompatible lint group only includes -// lints for changes that are not tied to an edition -#![deny(future_incompatible)] - -// Error since this is a `future_incompatible` lint -macro_rules! m { ($i) => {} } //~ ERROR missing fragment specifier - //~| WARN this was previously accepted - -trait Tr { - // Warn only since this is not a `future_incompatible` lint - fn f(u8) {} //~ WARN anonymous parameters are deprecated - //~| WARN this is accepted in the current edition -} - -fn main() {} diff --git a/tests/ui/global-scope.rs b/tests/ui/global-scope.rs deleted file mode 100644 index 33b56bca940a8..0000000000000 --- a/tests/ui/global-scope.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -pub fn f() -> isize { return 1; } - -pub mod foo { - pub fn f() -> isize { return 2; } - pub fn g() { - assert_eq!(f(), 2); - assert_eq!(::f(), 1); - } -} - -pub fn main() { return foo::g(); } diff --git a/tests/ui/hello.rs b/tests/ui/hello.rs deleted file mode 100644 index f329ee086f90c..0000000000000 --- a/tests/ui/hello.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ revisions: e2015 e2018 e2021 e2024 - -//@[e2018] edition:2018 -//@[e2021] edition:2021 -//@[e2024] edition:2024 - -fn main() { - println!("hello"); -} diff --git a/tests/ui/include-macros/parent_dir.rs b/tests/ui/include-macros/parent_dir.rs index 1dcf27324d1fd..9a81a6deeb12b 100644 --- a/tests/ui/include-macros/parent_dir.rs +++ b/tests/ui/include-macros/parent_dir.rs @@ -3,8 +3,6 @@ fn main() { let _ = include_str!("include-macros/file.txt"); //~ ERROR couldn't read //~^HELP different directory - let _ = include_str!("hello.rs"); //~ ERROR couldn't read - //~^HELP different directory let _ = include_bytes!("../../data.bin"); //~ ERROR couldn't read //~^HELP different directory let _ = include_str!("tests/ui/include-macros/file.txt"); //~ ERROR couldn't read diff --git a/tests/ui/include-macros/parent_dir.stderr b/tests/ui/include-macros/parent_dir.stderr index 4ee6fe104b06a..7a18b1de5d164 100644 --- a/tests/ui/include-macros/parent_dir.stderr +++ b/tests/ui/include-macros/parent_dir.stderr @@ -10,19 +10,8 @@ LL - let _ = include_str!("include-macros/file.txt"); LL + let _ = include_str!("file.txt"); | -error: couldn't read `$DIR/hello.rs`: $FILE_NOT_FOUND_MSG - --> $DIR/parent_dir.rs:6:13 - | -LL | let _ = include_str!("hello.rs"); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: there is a file with the same name in a different directory - | -LL | let _ = include_str!("../hello.rs"); - | +++ - error: couldn't read `$DIR/../../data.bin`: $FILE_NOT_FOUND_MSG - --> $DIR/parent_dir.rs:8:13 + --> $DIR/parent_dir.rs:6:13 | LL | let _ = include_bytes!("../../data.bin"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +23,7 @@ LL + let _ = include_bytes!("data.bin"); | error: couldn't read `$DIR/tests/ui/include-macros/file.txt`: $FILE_NOT_FOUND_MSG - --> $DIR/parent_dir.rs:10:13 + --> $DIR/parent_dir.rs:8:13 | LL | let _ = include_str!("tests/ui/include-macros/file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,5 +34,5 @@ LL - let _ = include_str!("tests/ui/include-macros/file.txt"); LL + let _ = include_str!("file.txt"); | -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/future-incompatible-lint-group.rs b/tests/ui/lint/future-incompatible-lint-group.rs new file mode 100644 index 0000000000000..d1adcf21cdceb --- /dev/null +++ b/tests/ui/lint/future-incompatible-lint-group.rs @@ -0,0 +1,21 @@ +//! Test that future_incompatible lint group only includes edition-independent lints + +// Ensure that the future_incompatible lint group only includes +// lints for changes that are not tied to an edition +#![deny(future_incompatible)] + +// Error since this is a `future_incompatible` lint +macro_rules! m { + ($i) => {}; + //~^ ERROR missing fragment specifier + //~| WARN this was previously accepted +} + +trait Tr { + // Warn only since this is not a `future_incompatible` lint + fn f(u8) {} + //~^ WARN anonymous parameters are deprecated + //~| WARN this is accepted in the current edition +} + +fn main() {} diff --git a/tests/ui/future-incompatible-lint-group.stderr b/tests/ui/lint/future-incompatible-lint-group.stderr similarity index 80% rename from tests/ui/future-incompatible-lint-group.stderr rename to tests/ui/lint/future-incompatible-lint-group.stderr index 4c867e0aab3cb..264911b46d4d9 100644 --- a/tests/ui/future-incompatible-lint-group.stderr +++ b/tests/ui/lint/future-incompatible-lint-group.stderr @@ -1,20 +1,20 @@ error: missing fragment specifier - --> $DIR/future-incompatible-lint-group.rs:6:19 + --> $DIR/future-incompatible-lint-group.rs:9:6 | -LL | macro_rules! m { ($i) => {} } - | ^^ +LL | ($i) => {}; + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 note: the lint level is defined here - --> $DIR/future-incompatible-lint-group.rs:3:9 + --> $DIR/future-incompatible-lint-group.rs:5:9 | LL | #![deny(future_incompatible)] | ^^^^^^^^^^^^^^^^^^^ = note: `#[deny(missing_fragment_specifier)]` implied by `#[deny(future_incompatible)]` warning: anonymous parameters are deprecated and will be removed in the next edition - --> $DIR/future-incompatible-lint-group.rs:11:10 + --> $DIR/future-incompatible-lint-group.rs:16:10 | LL | fn f(u8) {} | ^^ help: try naming the parameter or explicitly ignoring it: `_: u8` @@ -27,15 +27,15 @@ error: aborting due to 1 previous error; 1 warning emitted Future incompatibility report: Future breakage diagnostic: error: missing fragment specifier - --> $DIR/future-incompatible-lint-group.rs:6:19 + --> $DIR/future-incompatible-lint-group.rs:9:6 | -LL | macro_rules! m { ($i) => {} } - | ^^ +LL | ($i) => {}; + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 note: the lint level is defined here - --> $DIR/future-incompatible-lint-group.rs:3:9 + --> $DIR/future-incompatible-lint-group.rs:5:9 | LL | #![deny(future_incompatible)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-inherent-non-conflict.rs b/tests/ui/methods/inherent-methods-same-name.rs similarity index 68% rename from tests/ui/impl-inherent-non-conflict.rs rename to tests/ui/methods/inherent-methods-same-name.rs index 41ab865892a1a..d7d19bc332566 100644 --- a/tests/ui/impl-inherent-non-conflict.rs +++ b/tests/ui/methods/inherent-methods-same-name.rs @@ -1,17 +1,22 @@ +//! Test multiple inherent methods with same name on different type parameters + //@ run-pass // Ensure that a user-defined type admits multiple inherent methods // with the same name, which can be called on values that have a // precise enough type to allow distinguishing between the methods. - struct Foo(T); impl Foo { - fn bar(&self) -> i32 { self.0 as i32 } + fn bar(&self) -> i32 { + self.0 as i32 + } } impl Foo { - fn bar(&self) -> i32 { -(self.0 as i32) } + fn bar(&self) -> i32 { + -(self.0 as i32) + } } fn main() { diff --git a/tests/ui/impl-not-adjacent-to-type.rs b/tests/ui/modules/impl-cross-module.rs similarity index 78% rename from tests/ui/impl-not-adjacent-to-type.rs rename to tests/ui/modules/impl-cross-module.rs index ccf59ed439328..3ed8c18ff3cd2 100644 --- a/tests/ui/impl-not-adjacent-to-type.rs +++ b/tests/ui/modules/impl-cross-module.rs @@ -1,3 +1,5 @@ +//! Test implementing methods for types defined in other modules + //@ run-pass mod foo { diff --git a/tests/ui/resolve/global-scope-resolution.rs b/tests/ui/resolve/global-scope-resolution.rs new file mode 100644 index 0000000000000..176bab36da7cd --- /dev/null +++ b/tests/ui/resolve/global-scope-resolution.rs @@ -0,0 +1,21 @@ +//! Test global scope resolution with :: operator + +//@ run-pass + +pub fn f() -> isize { + return 1; +} + +pub mod foo { + pub fn f() -> isize { + return 2; + } + pub fn g() { + assert_eq!(f(), 2); + assert_eq!(::f(), 1); + } +} + +pub fn main() { + return foo::g(); +}