Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5f27951

Browse files
committedFeb 13, 2024
blessings
1 parent 51228ea commit 5f27951

8 files changed

+27
-20
lines changed
 

‎tests/ui/cast/cast-rfc0401-vtable-kinds.rs

-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
#![feature(unsized_tuple_coercion)]
66

7-
trait Foo<T> {
8-
fn foo(&self, _: T) -> u32 { 42 }
9-
}
10-
117
trait Bar { //~ WARN trait `Bar` is never used
128
fn bar(&self) { println!("Bar!"); }
139
}
1410

15-
impl<T> Foo<T> for () {}
16-
impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } }
1711
impl Bar for () {}
1812

1913
#[repr(C)]

‎tests/ui/cast/cast-rfc0401-vtable-kinds.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: trait `Bar` is never used
2-
--> $DIR/cast-rfc0401-vtable-kinds.rs:11:7
2+
--> $DIR/cast-rfc0401-vtable-kinds.rs:7:7
33
|
44
LL | trait Bar {
55
| ^^^

‎tests/ui/cast/ptr-to-trait-obj-different-args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ trait Assocked {
3535

3636
fn change_assoc(x: *mut dyn Assocked<Assoc = u8>) -> *mut dyn Assocked<Assoc = u32> {
3737
x as _ //~ error: the trait bound `dyn Assocked<Assoc = u8>: Unsize<dyn Assocked<Assoc = u32>>` is not satisfied
38-
}
38+
}

‎tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
trait Trait {}
55

6-
fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) {
6+
fn assert_send() -> *mut (dyn Trait + Send) {
77
//~^ ERROR incorrect parentheses around trait bounds
8-
ptr as _
8+
loop {}
99
}
1010

1111
fn foo2(_: &(dyn Trait + Send)) {}

‎tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
trait Trait {}
55

6-
fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
6+
fn assert_send() -> *mut dyn (Trait + Send) {
77
//~^ ERROR incorrect parentheses around trait bounds
8-
ptr as _
8+
loop {}
99
}
1010

1111
fn foo2(_: &dyn (Trait + Send)) {}

‎tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: incorrect parentheses around trait bounds
2-
--> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:49
2+
--> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:30
33
|
4-
LL | fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
5-
| ^ ^
4+
LL | fn assert_send() -> *mut dyn (Trait + Send) {
5+
| ^ ^
66
|
77
help: fix the parentheses
88
|
9-
LL - fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
10-
LL + fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) {
9+
LL - fn assert_send() -> *mut dyn (Trait + Send) {
10+
LL + fn assert_send() -> *mut (dyn Trait + Send) {
1111
|
1212

1313
error: incorrect parentheses around trait bounds

‎tests/ui/traits/upcast_soundness_bug.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![feature(trait_upcasting)]
2-
// known-bug: #120222
3-
// check-pass
4-
//! This will segfault at runtime.
2+
// check-fail
3+
//
4+
// issue: <https://github.com/rust-lang/rust/pull/120222>
5+
//! This would segfault at runtime.
56
67
pub trait SupSupA {
78
fn method(&self) {}
@@ -56,6 +57,7 @@ pub fn user2() -> &'static dyn Trait<u8, u16> {
5657
fn main() {
5758
let p: *const dyn Trait<u8, u8> = &();
5859
let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
60+
//~^ error: the trait bound `dyn Trait<u8, u8>: Unsize<dyn Trait<u8, u16>>` is not satisfied
5961
let p = p as *const dyn Super<u16>; // <- this upcast accesses improper vtable entry
6062
// accessing from L__unnamed_2 the position for the 'Super<u16> vtable (pointer)',
6163
// thus reading 'null pointer for missing_method'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0277]: the trait bound `dyn Trait<u8, u8>: Unsize<dyn Trait<u8, u16>>` is not satisfied
2+
--> $DIR/upcast_soundness_bug.rs:59:13
3+
|
4+
LL | let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unsize<dyn Trait<u8, u16>>` is not implemented for `dyn Trait<u8, u8>`
6+
|
7+
= note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)
Failed to load comments.