Rollup merge of #141833 - Kivooeo:test-reform1, r=jieyouxu

`tests/ui`: A New Order [2/N]

part of rust-lang/rust#133895

r? `@jieyouxu`

let's try this kind of commits, one for each file, commit's name shows what i did, hope this is not harder to review than previous
This commit is contained in:
Matthias Krüger 2025-06-03 15:00:33 +02:00 committed by GitHub
commit 4fa33eb8d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 51 additions and 32 deletions

View file

@ -0,0 +1,18 @@
//! Tests that a `Vec<isize>` can call a method defined in a trait (`Foo`)
//! implemented for `&[isize]` with a by-value receiver (`self`), relying on auto-dereferencing
//! from `Vec` to `&[isize]` during method resolution.
//@ run-pass
trait Foo {
fn foo(self);
}
impl<'a> Foo for &'a [isize] {
fn foo(self) {}
}
pub fn main() {
let items = vec![ 3, 5, 1, 2, 4 ];
items.foo();
}

View file

@ -1,10 +0,0 @@
enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }
fn main() {
let red: Color = Color::Rgb(255, 0, 0);
match red {
Color::Rgb(r, g, b) => { println!("rgb"); }
Color::Hsl(h, s, l) => { println!("hsl"); }
//~^ ERROR no variant
}
}

View file

@ -1,14 +0,0 @@
//@ run-pass
trait Foo {
fn foo(self);
}
impl<'a> Foo for &'a [isize] {
fn foo(self) {}
}
pub fn main() {
let items = vec![ 3, 5, 1, 2, 4 ];
items.foo();
}

View file

@ -1,3 +1,5 @@
//! Tests invalid lifetime bounds and generic parameters in higher-ranked types.
type A = for<'b, 'a: 'b> fn(); //~ ERROR bounds cannot be used in this context
type B = for<'b, 'a: 'b,> fn(); //~ ERROR bounds cannot be used in this context
type C = for<'b, 'a: 'b +> fn(); //~ ERROR bounds cannot be used in this context

View file

@ -1,23 +1,23 @@
error: bounds cannot be used in this context
--> $DIR/bounds-lifetime.rs:1:22
--> $DIR/higher-ranked-invalid-bounds.rs:3:22
|
LL | type A = for<'b, 'a: 'b> fn();
| ^^
error: bounds cannot be used in this context
--> $DIR/bounds-lifetime.rs:2:22
--> $DIR/higher-ranked-invalid-bounds.rs:4:22
|
LL | type B = for<'b, 'a: 'b,> fn();
| ^^
error: bounds cannot be used in this context
--> $DIR/bounds-lifetime.rs:3:22
--> $DIR/higher-ranked-invalid-bounds.rs:5:22
|
LL | type C = for<'b, 'a: 'b +> fn();
| ^^
error[E0658]: only lifetime parameters can be used in this context
--> $DIR/bounds-lifetime.rs:4:18
--> $DIR/higher-ranked-invalid-bounds.rs:6:18
|
LL | type D = for<'a, T> fn();
| ^
@ -27,7 +27,7 @@ LL | type D = for<'a, T> fn();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: only lifetime parameters can be used in this context
--> $DIR/bounds-lifetime.rs:5:18
--> $DIR/higher-ranked-invalid-bounds.rs:7:18
|
LL | type E = dyn for<T, U> Fn();
| ^ ^

View file

@ -1,3 +1,5 @@
//! Tests bitwise operations with platform-specific and negative number behavior.
//@ run-pass
#[cfg(any(target_pointer_width = "32"))]

View file

@ -1,3 +1,5 @@
//! Tests moving an `Arc` value out of an `Option` in a match expression.
//@ run-pass
use std::sync::Arc;

View file

@ -0,0 +1,19 @@
//! Tests invalid enum variant in a match expression.
enum Color {
Rgb(isize, isize, isize),
Rgba(isize, isize, isize, isize),
}
fn main() {
let red: Color = Color::Rgb(255, 0, 0);
match red {
Color::Rgb(r, g, b) => {
println!("rgb");
}
Color::Hsl(h, s, l) => {
//~^ ERROR no variant
println!("hsl");
}
}
}

View file

@ -1,10 +1,10 @@
error[E0599]: no variant or associated item named `Hsl` found for enum `Color` in the current scope
--> $DIR/bogus-tag.rs:7:16
--> $DIR/pattern-match-invalid-variant.rs:14:16
|
LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }
LL | enum Color {
| ---------- variant or associated item `Hsl` not found for this enum
...
LL | Color::Hsl(h, s, l) => { println!("hsl"); }
LL | Color::Hsl(h, s, l) => {
| ^^^ variant or associated item not found in `Color`
error: aborting due to 1 previous error