From 40b99a9c79051b0e109efa429512309bbf36f8db Mon Sep 17 00:00:00 2001 From: long-long-float Date: Sun, 21 Apr 2024 23:58:12 +0900 Subject: [PATCH] Fix test case --- .../wrap-dyn-in-suggestion-issue-120223.rs | 12 ++++-- ...wrap-dyn-in-suggestion-issue-120223.stderr | 42 ++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs index a6c8fa55ebddf..6a273997ee630 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs @@ -14,9 +14,15 @@ pub fn dyn_star_func( Box::new(executor) //~ ERROR may not live long enough } -pub fn in_ty_param &'static dyn std::fmt::Debug>(f: F) { - f(); - f(); //~ ERROR use of moved value +trait Trait { + fn method(&self) {} +} + +impl Trait for fn() {} + +pub fn in_ty_param dyn std::fmt::Debug> (t: T) { + t.method(); + //~^ ERROR no method named `method` found for type parameter `T` } fn with_sized &'static (dyn std::fmt::Debug) + ?Sized>() { diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr index dd44c0cf847ae..f7fc17ea24f18 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr @@ -7,16 +7,30 @@ LL | #![feature(dyn_star)] = note: see issue #102425 for more information = note: `#[warn(incomplete_features)]` on by default +error[E0599]: no method named `method` found for type parameter `T` in the current scope + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:24:7 + | +LL | pub fn in_ty_param dyn std::fmt::Debug> (t: T) { + | - method `method` not found for this type parameter +LL | t.method(); + | ^^^^^^ method not found in `T` + | + = help: items from traits can only be used if the type parameter is bounded by the trait +help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it: + | +LL | pub fn in_ty_param (dyn std::fmt::Debug) + Trait> (t: T) { + | + +++++++++ + error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:23:21 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:29:21 | LL | fn with_sized &'static (dyn std::fmt::Debug) + ?Sized>() { | - this type parameter needs to be `Sized` -LL | without_sized::(); +LL | without_sized::(); | ^ doesn't have a size known at compile-time | note: required by an implicit `Sized` bound in `without_sized` - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:27:18 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:33:18 | LL | fn without_sized &'static dyn std::fmt::Debug>() {} | ^ required by the implicit `Sized` requirement on this type parameter in `without_sized` @@ -58,27 +72,7 @@ help: consider adding an explicit lifetime bound LL | executor: impl FnOnce(T) -> (dyn* Future) + 'static, | + +++++++++++ -error[E0382]: use of moved value: `f` - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:19:5 - | -LL | pub fn in_ty_param &'static dyn std::fmt::Debug>(f: F) { - | - move occurs because `f` has type `F`, which does not implement the `Copy` trait -LL | f(); - | --- `f` moved due to this call -LL | f(); - | ^ value used here after move - | -note: this value implements `FnOnce`, which causes it to be moved when called - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:18:5 - | -LL | f(); - | ^ -help: consider restricting type parameters - | -LL | pub fn in_ty_param &'static (dyn std::fmt::Debug) + Copy>(f: F) { - | + ++++++++ - error: aborting due to 4 previous errors; 1 warning emitted -Some errors have detailed explanations: E0277, E0310, E0382. +Some errors have detailed explanations: E0277, E0310, E0599. For more information about an error, try `rustc --explain E0277`.