Skip to content

Commit 478763b

Browse files
committed
update object-safety ui test for new object-safety rules
1 parent e3b3167 commit 478763b

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/test/ui/arbitrary-self-types-not-object-safe.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@
1212
use std::rc::Rc;
1313

1414
trait Foo {
15-
fn foo(self: Rc<Self>) -> usize;
15+
fn foo(self: &Rc<Self>) -> usize;
1616
}
1717

1818
trait Bar {
19-
fn foo(self: Rc<Self>) -> usize where Self: Sized;
20-
fn bar(self: Box<Self>) -> usize;
19+
fn foo(self: &Rc<Self>) -> usize where Self: Sized;
20+
fn bar(self: Rc<Self>) -> usize;
2121
}
2222

2323
impl Foo for usize {
24-
fn foo(self: Rc<Self>) -> usize {
25-
*self
24+
fn foo(self: &Rc<Self>) -> usize {
25+
**self
2626
}
2727
}
2828

2929
impl Bar for usize {
30-
fn foo(self: Rc<Self>) -> usize {
31-
*self
30+
fn foo(self: &Rc<Self>) -> usize {
31+
**self
3232
}
3333

34-
fn bar(self: Box<Self>) -> usize {
34+
fn bar(self: Rc<Self>) -> usize {
3535
*self
3636
}
3737
}
3838

3939
fn make_foo() {
40-
let x = Box::new(5usize) as Box<Foo>;
40+
let x = Rc::new(5usize) as Rc<Foo>;
4141
//~^ ERROR E0038
4242
//~| ERROR E0038
4343
}
4444

4545
fn make_bar() {
46-
let x = Box::new(5usize) as Box<Bar>;
46+
let x = Rc::new(5usize) as Rc<Bar>;
4747
x.bar();
4848
}
4949

src/test/ui/arbitrary-self-types-not-object-safe.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/arbitrary-self-types-not-object-safe.rs:40:33
2+
--> $DIR/arbitrary-self-types-not-object-safe.rs:40:32
33
|
4-
LL | let x = Box::new(5usize) as Box<Foo>;
5-
| ^^^^^^^^ the trait `Foo` cannot be made into an object
4+
LL | let x = Rc::new(5usize) as Rc<Foo>;
5+
| ^^^^^^^ the trait `Foo` cannot be made into an object
66
|
7-
= note: method `foo` has a non-standard `self` type
7+
= note: method `foo` has an uncoercible receiver type
88

99
error[E0038]: the trait `Foo` cannot be made into an object
1010
--> $DIR/arbitrary-self-types-not-object-safe.rs:40:13
1111
|
12-
LL | let x = Box::new(5usize) as Box<Foo>;
13-
| ^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
12+
LL | let x = Rc::new(5usize) as Rc<Foo>;
13+
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
1414
|
15-
= note: method `foo` has a non-standard `self` type
16-
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<dyn Foo>>` for `std::boxed::Box<usize>`
15+
= note: method `foo` has an uncoercible receiver type
16+
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
1717

1818
error: aborting due to 2 previous errors
1919

0 commit comments

Comments
 (0)