-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #120929 - long-long-float:wrap-dyn-in-suggestion, r=f…
…mease Wrap dyn type with parentheses in suggestion Close #120223 Fix wrong suggestion that is grammatically incorrect. Specifically, I added parentheses to dyn types that need lifetime bound. ``` help: consider adding an explicit lifetime bound | 4 | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ ```
- Loading branch information
Showing
10 changed files
with
286 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#![feature(dyn_star)] //~ WARNING the feature `dyn_star` is incomplete | ||
|
||
use std::future::Future; | ||
|
||
pub fn dyn_func<T>( | ||
executor: impl FnOnce(T) -> dyn Future<Output = ()>, | ||
) -> Box<dyn FnOnce(T) -> dyn Future<Output = ()>> { | ||
Box::new(executor) //~ ERROR may not live long enough | ||
} | ||
|
||
pub fn dyn_star_func<T>( | ||
executor: impl FnOnce(T) -> dyn* Future<Output = ()>, | ||
) -> Box<dyn FnOnce(T) -> dyn* Future<Output = ()>> { | ||
Box::new(executor) //~ ERROR may not live long enough | ||
} | ||
|
||
trait Trait { | ||
fn method(&self) {} | ||
} | ||
|
||
impl Trait for fn() {} | ||
|
||
pub fn in_ty_param<T: Fn() -> dyn std::fmt::Debug> (t: T) { | ||
t.method(); | ||
//~^ ERROR no method named `method` found for type parameter `T` | ||
} | ||
|
||
fn with_sized<T: Fn() -> &'static (dyn std::fmt::Debug) + ?Sized>() { | ||
without_sized::<T>(); | ||
//~^ ERROR the size for values of type `T` cannot be known at compilation time | ||
} | ||
|
||
fn without_sized<T: Fn() -> &'static dyn std::fmt::Debug>() {} | ||
|
||
fn main() {} |
Oops, something went wrong.