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

This ensures that these tests can be run on editions other than 2015
This commit is contained in:
Lukas Wirth 2025-06-02 10:11:10 +02:00
parent 91fad92585
commit aba70e8f9d
10 changed files with 37 additions and 38 deletions

View file

@ -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);
}

View file

@ -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
@ -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
}

View file

@ -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`

View file

@ -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]
|| {

View file

@ -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
}
@ -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
}

View file

@ -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
}

View file

@ -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>) {}
| ^^^^
@ -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;
| ^^^^

View file

@ -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(())
@ -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(())

View file

@ -1,27 +1,27 @@
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>>>
| ^^
|
note: lifetime declared here
--> $DIR/E0657.rs:10:16
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
--> $DIR/E0657.rs:19: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:19:20
--> $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:39
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^
|
note: lifetime declared here
--> $DIR/E0657.rs:19:24
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
| ^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0657`.

View file

@ -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) {