Skip to content

Add missing dyn keywords to tests that do not test for them #141889

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 3, 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/allocator/auxiliary/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
extern crate alloc;
use alloc::fmt;

pub fn work_with(p: &fmt::Debug) {
pub fn work_with(p: &dyn fmt::Debug) {
drop(p);
}
8 changes: 4 additions & 4 deletions tests/ui/coercion/retslot-cast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(warnings)]

pub fn fail(x: Option<&(Iterator<Item=()>+Send)>)
-> Option<&Iterator<Item=()>> {
pub fn fail(x: Option<&(dyn Iterator<Item=()>+Send)>)
-> Option<&dyn Iterator<Item=()>> {
// This call used to trigger an LLVM assertion because the return
// slot had type "Option<&Iterator>"* instead of
// "Option<&(Iterator+Send)>"* -- but this now yields a
Expand All @@ -13,8 +13,8 @@ pub fn fail(x: Option<&(Iterator<Item=()>+Send)>)
inner(x) //~ ERROR mismatched types
}

pub fn inner(x: Option<&(Iterator<Item=()>+Send)>)
-> Option<&(Iterator<Item=()>+Send)> {
pub fn inner(x: Option<&(dyn Iterator<Item=()>+Send)>)
-> Option<&(dyn Iterator<Item=()>+Send)> {
x
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/coercion/retslot-cast.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/retslot-cast.rs:13:5
|
LL | -> Option<&Iterator<Item=()>> {
| -------------------------- expected `Option<&dyn Iterator<Item = ()>>` because of return type
LL | -> Option<&dyn Iterator<Item=()>> {
| ------------------------------ expected `Option<&dyn Iterator<Item = ()>>` because of return type
...
LL | inner(x)
| ^^^^^^^^ expected trait `Iterator<Item = ()>`, found trait `Iterator<Item = ()> + Send`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coroutine/auxiliary/xcrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> {
}
}

pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> {
pub fn bar<T: 'static>(t: T) -> Box<dyn Coroutine<(), Yield = T, Return = ()> + Unpin> {
Box::new(
#[coroutine]
|| {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/deprecation/deprecation-lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod cross_crate {
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
}

fn test_method_object(foo: &Trait) {
fn test_method_object(foo: &dyn Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
}
Expand Down Expand Up @@ -299,7 +299,7 @@ mod this_crate {
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
}

fn test_method_object(foo: &Trait) {
fn test_method_object(foo: &dyn Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
}
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/dyn-drop/dyn-drop.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![deny(dyn_drop)]
#![allow(bare_trait_objects)]
fn foo(_: Box<dyn Drop>) {} //~ ERROR
fn bar(_: &dyn Drop) {} //~ERROR
fn baz(_: *mut Drop) {} //~ ERROR
fn baz(_: *mut dyn Drop) {} //~ ERROR
struct Foo {
_x: Box<dyn Drop> //~ ERROR
}
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/dyn-drop/dyn-drop.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped
--> $DIR/dyn-drop.rs:3:19
--> $DIR/dyn-drop.rs:2:19
|
LL | fn foo(_: Box<dyn Drop>) {}
| ^^^^
Expand All @@ -11,25 +11,25 @@ LL | #![deny(dyn_drop)]
| ^^^^^^^^

error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped
--> $DIR/dyn-drop.rs:4:16
--> $DIR/dyn-drop.rs:3:16
|
LL | fn bar(_: &dyn Drop) {}
| ^^^^

error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped
--> $DIR/dyn-drop.rs:5:16
--> $DIR/dyn-drop.rs:4:20
|
LL | fn baz(_: *mut Drop) {}
| ^^^^
LL | fn baz(_: *mut dyn Drop) {}
| ^^^^

error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped
--> $DIR/dyn-drop.rs:7:15
--> $DIR/dyn-drop.rs:6:15
|
LL | _x: Box<dyn Drop>
| ^^^^

error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped
--> $DIR/dyn-drop.rs:14:16
--> $DIR/dyn-drop.rs:13:16
|
LL | type T = dyn Drop;
| ^^^^
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/error-codes/E0657.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl<'a> Lt<'a> for () {}
impl<T> Id<T> for T {}

fn free_fn_capture_hrtb_in_impl_trait()
-> Box<for<'a> Id<impl Lt<'a>>>
-> Box<dyn for<'a> Id<impl Lt<'a>>>
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
{
Box::new(())
Expand All @@ -16,7 +16,7 @@ fn free_fn_capture_hrtb_in_impl_trait()
struct Foo;
impl Foo {
fn impl_fn_capture_hrtb_in_impl_trait()
-> Box<for<'a> Id<impl Lt<'a>>>
-> Box<dyn for<'a> Id<impl Lt<'a>>>
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
{
Box::new(())
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/error-codes/E0657.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
--> $DIR/E0657.rs:10:31
--> $DIR/E0657.rs:10:35
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^
|
note: lifetime declared here
--> $DIR/E0657.rs:10:16
--> $DIR/E0657.rs:10:20
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^

error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
--> $DIR/E0657.rs:19:35
--> $DIR/E0657.rs:19:39
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^
|
note: lifetime declared here
--> $DIR/E0657.rs:19:20
--> $DIR/E0657.rs:19:24
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/intrinsics/non-integer-atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::intrinsics::{self, AtomicOrdering};

#[derive(Copy, Clone)]
pub struct Foo(i64);
pub type Bar = &'static Fn();
pub type Bar = &'static dyn Fn();
pub type Quux = [u8; 100];

pub unsafe fn test_bool_load(p: &mut bool, v: bool) {
Expand Down
Loading