Skip to content

Commit 93e2919

Browse files
authored
Rollup merge of #141974 - Kivooeo:tf4, r=jieyouxu
`tests/ui`: A New Order [4/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. r? ``@jieyouxu`` added stderr tag for commit which means it included generated stderr
2 parents b7105c3 + 06ab34e commit 93e2919

13 files changed

+98
-170
lines changed

tests/ui/char.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/class-cast-to-trait.rs

Lines changed: 0 additions & 54 deletions
This file was deleted.

tests/ui/class-cast-to-trait.stderr

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/ui/class-method-missing.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/ui/class-method-missing.stderr

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/cleanup-rvalue-for-scope.rs

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! Check that temporaries in the for into-iterable expr are not dropped
2+
//! until the end of the for expr.
3+
4+
//@ run-pass
5+
6+
static mut FLAGS: u64 = 0;
7+
8+
struct AddFlags {
9+
bits: u64,
10+
}
11+
12+
impl Drop for AddFlags {
13+
fn drop(&mut self) {
14+
unsafe {
15+
FLAGS += self.bits;
16+
}
17+
}
18+
}
19+
20+
fn check_flags(expected: u64) {
21+
unsafe {
22+
let actual = FLAGS;
23+
FLAGS = 0;
24+
assert_eq!(actual, expected, "flags {}, expected {}", actual, expected);
25+
}
26+
}
27+
28+
fn main() {
29+
for _ in &[AddFlags { bits: 1 }] {
30+
check_flags(0);
31+
}
32+
check_flags(1);
33+
}

tests/ui/cenum_impl_drop_cast.rs renamed to tests/ui/enum/enum-drop-cast-error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Check that trying to cast an enum with a Drop impl to an integer is rejected.
2+
//!
3+
//! Issue: <https://github.com/rust-lang/rust/issues/35941>
4+
15
enum E {
26
A = 0,
37
}

tests/ui/cenum_impl_drop_cast.stderr renamed to tests/ui/enum/enum-drop-cast-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: cannot cast enum `E` into integer `u32` because it implements `Drop`
2-
--> $DIR/cenum_impl_drop_cast.rs:13:13
2+
--> $DIR/enum-drop-cast-error.rs:17:13
33
|
44
LL | let i = e as u32;
55
| ^^^^^^^^
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Trait objects only allow access to methods defined in the trait.
2+
3+
trait MyTrait {
4+
fn trait_method(&mut self);
5+
}
6+
7+
struct ImplType;
8+
9+
impl MyTrait for ImplType {
10+
fn trait_method(&mut self) {}
11+
}
12+
13+
impl ImplType {
14+
fn struct_impl_method(&mut self) {}
15+
}
16+
17+
fn main() {
18+
let obj: Box<dyn MyTrait> = Box::new(ImplType);
19+
obj.struct_impl_method(); //~ ERROR no method named `struct_impl_method` found
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0599]: no method named `struct_impl_method` found for struct `Box<dyn MyTrait>` in the current scope
2+
--> $DIR/trait-object-method-error.rs:19:9
3+
|
4+
LL | obj.struct_impl_method();
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
help: there is a method `trait_method` with a similar name
8+
|
9+
LL - obj.struct_impl_method();
10+
LL + obj.trait_method();
11+
|
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0599`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Trait impls must define all required methods.
2+
3+
trait MyTrait {
4+
fn trait_method(&self);
5+
}
6+
7+
struct ImplType;
8+
9+
impl MyTrait for ImplType {} //~ ERROR not all trait items implemented, missing: `trait_method`
10+
11+
fn main() {
12+
let _ = ImplType;
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0046]: not all trait items implemented, missing: `trait_method`
2+
--> $DIR/trait-impl-missing-method.rs:9:1
3+
|
4+
LL | fn trait_method(&self);
5+
| ----------------------- `trait_method` from trait
6+
...
7+
LL | impl MyTrait for ImplType {}
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `trait_method` in implementation
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)