mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-17 02:56:25 +00:00
Rollup merge of #141957 - ferrocene:lw/missing-dyn-kw2, r=compiler-errors
Add missing `dyn` keywords to tests that do not test for them Part 2 Some more tests that were found
This commit is contained in:
commit
a2b6f14af3
@ -11,6 +11,6 @@ mod inner {
|
||||
}
|
||||
|
||||
pub fn foo() {
|
||||
let a = &1isize as &inner::Trait;
|
||||
let a = &1isize as &dyn inner::Trait;
|
||||
a.f();
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ pub mod testtypes {
|
||||
TypeId::of::<FooFnPtr>(),
|
||||
TypeId::of::<FooNil>(),
|
||||
TypeId::of::<FooTuple>(),
|
||||
TypeId::of::<FooTrait>(),
|
||||
TypeId::of::<dyn FooTrait>(),
|
||||
TypeId::of::<FooStruct>(),
|
||||
TypeId::of::<FooEnum>()
|
||||
]
|
||||
|
||||
@ -4,9 +4,9 @@ pub trait Foo<'a, T> {
|
||||
fn foo(&'a self) -> T;
|
||||
}
|
||||
|
||||
pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T {
|
||||
let x: &'a Foo<T> = x;
|
||||
// ^ the lifetime parameter of Foo is left to be inferred.
|
||||
pub fn foo<'a, T>(x: &'a dyn Foo<'a, T>) -> T {
|
||||
let x: &'a dyn Foo<T> = x;
|
||||
// ^ the lifetime parameter of Foo is left to be inferred.
|
||||
x.foo()
|
||||
// ^ encoding this method call in metadata triggers an ICE.
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ pub trait i<T>
|
||||
fn dummy(&self, t: T) -> T { panic!() }
|
||||
}
|
||||
|
||||
pub fn f<T>() -> Box<i<T>+'static> {
|
||||
pub fn f<T>() -> Box<dyn i<T>+'static> {
|
||||
impl<T> i<T> for () { }
|
||||
|
||||
Box::new(()) as Box<i<T>+'static>
|
||||
Box::new(()) as Box<dyn i<T>+'static>
|
||||
}
|
||||
|
||||
@ -7,4 +7,4 @@ pub trait Trait {
|
||||
type Issue25467BarT;
|
||||
}
|
||||
|
||||
pub type Object = Option<Box<Trait<Issue25467FooT=(),Issue25467BarT=()>>>;
|
||||
pub type Object = Option<Box<dyn Trait<Issue25467FooT=(),Issue25467BarT=()>>>;
|
||||
|
||||
@ -9,7 +9,7 @@ impl Future for u32 {
|
||||
type Error = Box<()>;
|
||||
}
|
||||
|
||||
fn foo() -> Box<Future<Item=(), Error=Box<()>>> {
|
||||
fn foo() -> Box<dyn Future<Item=(), Error=Box<()>>> {
|
||||
Box::new(0u32)
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#[inline(never)]
|
||||
pub fn foo<T>() {
|
||||
let _: Box<SomeTrait> = Box::new(SomeTraitImpl);
|
||||
let _: Box<dyn SomeTrait> = Box::new(SomeTraitImpl);
|
||||
}
|
||||
|
||||
pub fn bar() {
|
||||
|
||||
@ -8,9 +8,9 @@ trait A {
|
||||
struct B;
|
||||
impl A for B {}
|
||||
|
||||
fn bar<T>(_: &mut A, _: &T) {}
|
||||
fn bar<T>(_: &mut dyn A, _: &T) {}
|
||||
|
||||
fn foo<T>(t: &T) {
|
||||
let mut b = B;
|
||||
bar(&mut b as &mut A, t)
|
||||
bar(&mut b as &mut dyn A, t)
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ trait Trait<T> {
|
||||
fn foo(_: T) {}
|
||||
}
|
||||
|
||||
pub struct Foo<T = Box<Trait<DefaultFoo>>>; //~ ERROR cycle detected
|
||||
pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; //~ ERROR cycle detected
|
||||
//~^ ERROR `T` is never used
|
||||
type DefaultFoo = Foo;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
error[E0391]: cycle detected when computing type of `Foo::T`
|
||||
--> $DIR/issue-34373.rs:7:30
|
||||
--> $DIR/issue-34373.rs:7:34
|
||||
|
|
||||
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^
|
||||
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires expanding type alias `DefaultFoo`...
|
||||
--> $DIR/issue-34373.rs:9:19
|
||||
@ -13,15 +13,15 @@ LL | type DefaultFoo = Foo;
|
||||
note: cycle used when checking that `Foo` is well-formed
|
||||
--> $DIR/issue-34373.rs:7:1
|
||||
|
|
||||
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
--> $DIR/issue-34373.rs:7:16
|
||||
|
|
||||
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter
|
||||
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
// Helper for testing that we get suitable warnings when lifetime
|
||||
// bound change will cause breakage.
|
||||
|
||||
pub fn just_ref(x: &Fn()) {
|
||||
}
|
||||
pub fn just_ref(x: &dyn Fn()) {}
|
||||
|
||||
pub fn ref_obj(x: &Box<Fn()>) {
|
||||
pub fn ref_obj(x: &Box<dyn Fn()>) {
|
||||
// this will change to &Box<Fn()+'static>...
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
//@ check-pass
|
||||
|
||||
#![allow(bare_trait_objects)]
|
||||
|
||||
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
|
||||
type A = Box<dyn (Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
|
||||
|
||||
fn main() {}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
//@ check-pass
|
||||
|
||||
#![allow(bare_trait_objects)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {
|
||||
let x: Box<Debug+> = Box::new(3) as Box<Debug+>; // Trailing `+` is OK
|
||||
let x: Box<dyn Debug+> = Box::new(3) as Box<dyn Debug+>; // Trailing `+` is OK
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ trait Foo {
|
||||
|
||||
// Here the receiver and return value all have the same lifetime,
|
||||
// so no error results.
|
||||
fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () {
|
||||
fn borrowed_receiver_same_lifetime<'a>(x: &'a dyn Foo) -> &'a () {
|
||||
x.borrowed()
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ trait Foo {
|
||||
|
||||
// Borrowed receiver with two distinct lifetimes, but we know that
|
||||
// 'b:'a, hence &'a () is permitted.
|
||||
fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () {
|
||||
fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (dyn Foo+'b)) -> &'a () {
|
||||
x.borrowed()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user