Skip to content

Add missing dyn keywords to tests that do not test for them Part 2 #141957

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 4, 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
2 changes: 1 addition & 1 deletion tests/ui/issues/auxiliary/issue-11224.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ mod inner {
}

pub fn foo() {
let a = &1isize as &inner::Trait;
let a = &1isize as &dyn inner::Trait;
a.f();
}
2 changes: 1 addition & 1 deletion tests/ui/issues/auxiliary/issue-13507.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>()
]
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/issues/auxiliary/issue-17662.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
4 changes: 2 additions & 2 deletions tests/ui/issues/auxiliary/issue-2380.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
2 changes: 1 addition & 1 deletion tests/ui/issues/auxiliary/issue-25467.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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=()>>>;
2 changes: 1 addition & 1 deletion tests/ui/issues/auxiliary/issue-34796-aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/auxiliary/issue-38226-aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/issues/auxiliary/issue-8401.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-34373.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/issues/issue-34373.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>...
}
4 changes: 1 addition & 3 deletions tests/ui/parser/bounds-obj-parens.rs
Original file line number Diff line number Diff line change
@@ -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() {}
4 changes: 1 addition & 3 deletions tests/ui/parser/trailing-plus-in-bounds.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion tests/ui/regions/region-object-lifetime-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/regions/region-object-lifetime-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Loading