Skip to content

tests/ui: A New Order [26/N] #143301

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

Merged
merged 2 commits into from
Jul 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions tests/ui/auxiliary/svh-a-base.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/auxiliary/svh-b.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:30:28
--> $DIR/super-let-lifetime-and-drop.rs:30:28
|
LL | super let b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -11,7 +11,7 @@ LL | }
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:46:28
--> $DIR/super-let-lifetime-and-drop.rs:46:28
|
LL | super let b = &DropMe(&mut x);
| --------------
Expand All @@ -26,7 +26,7 @@ LL | }
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:64:32
--> $DIR/super-let-lifetime-and-drop.rs:64:32
|
LL | super let b = identity(&DropMe(&mut x));
| --------------
Expand All @@ -40,7 +40,7 @@ LL | };
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:87:36
--> $DIR/super-let-lifetime-and-drop.rs:87:36
|
LL | super let b = identity(&DropMe(&mut x));
| --------------
Expand All @@ -55,7 +55,7 @@ LL | ));
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:107:28
--> $DIR/super-let-lifetime-and-drop.rs:107:28
|
LL | super let b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -67,7 +67,7 @@ LL | }
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:125:28
--> $DIR/super-let-lifetime-and-drop.rs:125:28
|
LL | super let b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -79,7 +79,7 @@ LL | }
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:143:28
--> $DIR/super-let-lifetime-and-drop.rs:143:28
|
LL | super let b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -91,7 +91,7 @@ LL | }
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:159:28
--> $DIR/super-let-lifetime-and-drop.rs:159:28
|
LL | b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -102,7 +102,7 @@ LL | drop(a);
| - borrow later used here

error[E0716]: temporary value dropped while borrowed
--> $DIR/super-let.rs:172:33
--> $DIR/super-let-lifetime-and-drop.rs:172:33
|
LL | #[cfg(borrowck)] { a = &String::from("asdf"); };
| ^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
Expand All @@ -115,7 +115,7 @@ LL | let _ = a;
= note: consider using a `let` binding to create a longer lived value

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:206:28
--> $DIR/super-let-lifetime-and-drop.rs:206:28
|
LL | super let d = &DropMe(&mut x);
| --------------
Expand All @@ -130,7 +130,7 @@ LL | }
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:227:32
--> $DIR/super-let-lifetime-and-drop.rs:227:32
|
LL | super let d = identity(&DropMe(&mut x));
| --------------
Expand All @@ -145,7 +145,7 @@ LL | };
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:246:28
--> $DIR/super-let-lifetime-and-drop.rs:246:28
|
LL | super let b = DropMe(&mut x);
| ------ `x` is borrowed here
Expand All @@ -157,7 +157,7 @@ LL | }
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`

error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/super-let.rs:263:28
--> $DIR/super-let-lifetime-and-drop.rs:263:28
|
LL | let dropme = Some(DropMe(&mut x));
| ------ `x` is borrowed here
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! This test verifies that a direct non-primitive cast from an enum to an integer type
//! is correctly disallowed, even when a `From` implementation exists for that enum.

//@ run-rustfix

#![allow(dead_code, unused_variables)]

enum NonNullary {
Nullary,
Other(isize),
Expand All @@ -16,5 +21,7 @@ impl From<NonNullary> for isize {

fn main() {
let v = NonNullary::Nullary;
let val = isize::from(v); //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
let val = isize::from(v);
//~^ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
//~| HELP consider using the `From` trait instead
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! This test verifies that a direct non-primitive cast from an enum to an integer type
//! is correctly disallowed, even when a `From` implementation exists for that enum.
//@ run-rustfix

#![allow(dead_code, unused_variables)]

enum NonNullary {
Nullary,
Other(isize),
Expand All @@ -16,5 +21,7 @@ impl From<NonNullary> for isize {

fn main() {
let v = NonNullary::Nullary;
let val = v as isize; //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
let val = v as isize;
//~^ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
//~| HELP consider using the `From` trait instead
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0605]: non-primitive cast: `NonNullary` as `isize`
--> $DIR/tag-variant-cast-non-nullary.rs:19:15
--> $DIR/cast-enum-to-primitive-error.rs:24:15
|
LL | let val = v as isize;
| ^^^^^^^^^^ an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! This test checks that various forms of "trivial" casts and coercions
//! can be explicitly performed using the `as` keyword without compilation errors.
//@ run-pass
// Test that all coercions can actually be done using casts (modulo the lints).

#![allow(trivial_casts, trivial_numeric_casts)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: method `foo` is never used
--> $DIR/trivial_casts-rpass.rs:7:8
--> $DIR/coercion-as-explicit-cast.rs:9:8
|
LL | trait Foo {
| --- method in this trait
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/generics/generic-enum-errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This test checks that unused generics are rejected by compiler
enum Quux<T> {
//~^ ERROR: parameter `T` is never used
Bar,
}

fn foo(c: Quux) {
//~^ ERROR missing generics for enum `Quux`
assert!((false));
}

fn main() {
panic!();
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0392]: type parameter `T` is never used
--> $DIR/tag-type-args.rs:1:11
--> $DIR/generic-enum-errors.rs:3:11
|
LL | enum Quux<T> { Bar }
LL | enum Quux<T> {
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error[E0107]: missing generics for enum `Quux`
--> $DIR/tag-type-args.rs:4:11
--> $DIR/generic-enum-errors.rs:8:11
|
LL | fn foo(c: Quux) { assert!((false)); }
LL | fn foo(c: Quux) {
| ^^^^ expected 1 generic argument
|
note: enum defined here, with 1 generic parameter: `T`
--> $DIR/tag-type-args.rs:1:6
--> $DIR/generic-enum-errors.rs:3:6
|
LL | enum Quux<T> { Bar }
LL | enum Quux<T> {
| ^^^^ -
help: add missing generic argument
|
LL | fn foo(c: Quux<T>) { assert!((false)); }
LL | fn foo(c: Quux<T>) {
| +++

error: aborting due to 2 previous errors
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/modules/module-super-access.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Check path resolution using `super`
//@ run-pass

#![allow(dead_code)]

pub mod a {
pub fn f() {}
pub mod b {
fn g() {
super::f(); // Accessing `f` from module `a` (parent of `b`)
}
}
}

pub fn main() {}
6 changes: 6 additions & 0 deletions tests/ui/modules/super-at-crate-root.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Check that `super` keyword used at the crate root (top-level) results in a compilation error
//! as there is no parent module to resolve.
use super::f; //~ ERROR there are too many leading `super` keywords

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0433]: failed to resolve: there are too many leading `super` keywords
--> $DIR/super-at-top-level.rs:1:5
--> $DIR/super-at-crate-root.rs:4:5
|
LL | use super::f;
| ^^^^^ there are too many leading `super` keywords
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//! Checks trailing commas are accepted in various places:
//! - Generic parameters in function and struct definitions.
//! - Function and method arguments.
//! - Tuple and array literal expressions.
//! - Tuple and array destructuring patterns, including those with `..`.
//! - Enum variant declarations.
//! - Attributes.
//@ run-pass

fn f<T,>(_: T,) {}
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/ptr_ops/ptr-swap-basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Check the basic functionality of `std::mem::swap` to ensure it correctly
//! exchanges the values of two mutable variables.

//@ run-pass

use std::mem::swap;

pub fn main() {
let mut x = 3;
let mut y = 7;
swap(&mut x, &mut y);
assert_eq!(x, 7);
assert_eq!(y, 3);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! Check that `std::ptr::swap` behaves correctly when the source and destination
//! pointers refer to the same memory location, avoiding issues like overlapping `memcpy`.
//!
//! Regression test: <https://github.com/rust-lang/rust/issues/5041>
//@ run-pass

#![allow(dead_code)]
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same


use std::ptr;

pub fn main() {
let mut test = TestDescAndFn {
desc: TestDesc {
name: TestName::DynTestName("test".to_string()),
should_fail: false
},
desc: TestDesc { name: TestName::DynTestName("test".to_string()), should_fail: false },
testfn: TestFn::DynTestFn(22),
};
do_swap(&mut test);
Expand All @@ -24,7 +24,7 @@ fn do_swap(test: &mut TestDescAndFn) {
}

pub enum TestName {
DynTestName(String)
DynTestName(String),
}

pub enum TestFn {
Expand All @@ -34,7 +34,7 @@ pub enum TestFn {

pub struct TestDesc {
name: TestName,
should_fail: bool
should_fail: bool,
}

pub struct TestDescAndFn {
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/recursion/recursion-tail-call-no-arg-leak.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This test verifies that tail call optimization does not lead to argument slot leaks.
//!
//! Regression test for: <https://github.com/rust-lang/rust/issues/160>

//@ run-pass

fn inner(dummy: String, b: bool) {
if b {
return inner(dummy, false);
}
}

pub fn main() {
inner("hi".to_string(), true);
}
Loading
Loading