Skip to content

tests/ui: A New Order [4/N] #141974

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 1 commit into from
Jun 5, 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
13 changes: 0 additions & 13 deletions tests/ui/char.rs

This file was deleted.

54 changes: 0 additions & 54 deletions tests/ui/class-cast-to-trait.rs

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ui/class-cast-to-trait.stderr

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/class-method-missing.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/class-method-missing.stderr

This file was deleted.

60 changes: 0 additions & 60 deletions tests/ui/cleanup-rvalue-for-scope.rs

This file was deleted.

33 changes: 33 additions & 0 deletions tests/ui/drop/for-expr-temporary-drop-scope.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! Check that temporaries in the for into-iterable expr are not dropped
//! until the end of the for expr.

//@ run-pass

static mut FLAGS: u64 = 0;

struct AddFlags {
bits: u64,
}

impl Drop for AddFlags {
fn drop(&mut self) {
unsafe {
FLAGS += self.bits;
}
}
}

fn check_flags(expected: u64) {
unsafe {
let actual = FLAGS;
FLAGS = 0;
assert_eq!(actual, expected, "flags {}, expected {}", actual, expected);
}
}

fn main() {
for _ in &[AddFlags { bits: 1 }] {
check_flags(0);
}
check_flags(1);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Check that trying to cast an enum with a Drop impl to an integer is rejected.
//!
//! Issue: <https://github.com/rust-lang/rust/issues/35941>

enum E {
A = 0,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: cannot cast enum `E` into integer `u32` because it implements `Drop`
--> $DIR/cenum_impl_drop_cast.rs:13:13
--> $DIR/enum-drop-cast-error.rs:17:13
|
LL | let i = e as u32;
| ^^^^^^^^
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/privacy/trait-object-method-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Trait objects only allow access to methods defined in the trait.

trait MyTrait {
fn trait_method(&mut self);
}

struct ImplType;

impl MyTrait for ImplType {
fn trait_method(&mut self) {}
}

impl ImplType {
fn struct_impl_method(&mut self) {}
}

fn main() {
let obj: Box<dyn MyTrait> = Box::new(ImplType);
obj.struct_impl_method(); //~ ERROR no method named `struct_impl_method` found
}
15 changes: 15 additions & 0 deletions tests/ui/privacy/trait-object-method-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0599]: no method named `struct_impl_method` found for struct `Box<dyn MyTrait>` in the current scope
--> $DIR/trait-object-method-error.rs:19:9
|
LL | obj.struct_impl_method();
| ^^^^^^^^^^^^^^^^^^
|
help: there is a method `trait_method` with a similar name
|
LL - obj.struct_impl_method();
LL + obj.trait_method();
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0599`.
13 changes: 13 additions & 0 deletions tests/ui/traits/trait-impl-missing-method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Trait impls must define all required methods.

trait MyTrait {
fn trait_method(&self);
}

struct ImplType;

impl MyTrait for ImplType {} //~ ERROR not all trait items implemented, missing: `trait_method`

fn main() {
let _ = ImplType;
}
12 changes: 12 additions & 0 deletions tests/ui/traits/trait-impl-missing-method.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0046]: not all trait items implemented, missing: `trait_method`
--> $DIR/trait-impl-missing-method.rs:9:1
|
LL | fn trait_method(&self);
| ----------------------- `trait_method` from trait
...
LL | impl MyTrait for ImplType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `trait_method` in implementation

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0046`.
Loading