mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Support pretty-printing dyn* trait objects
This commit is contained in:
@@ -1204,8 +1204,10 @@ pub fn print_type(&mut self, ty: &ast::Ty) {
|
||||
}
|
||||
ast::TyKind::Path(Some(qself), path) => self.print_qpath(path, qself, false),
|
||||
ast::TyKind::TraitObject(bounds, syntax) => {
|
||||
if *syntax == ast::TraitObjectSyntax::Dyn {
|
||||
self.word_nbsp("dyn");
|
||||
match syntax {
|
||||
ast::TraitObjectSyntax::Dyn => self.word_nbsp("dyn"),
|
||||
ast::TraitObjectSyntax::DynStar => self.word_nbsp("dyn*"),
|
||||
ast::TraitObjectSyntax::None => {}
|
||||
}
|
||||
self.print_type_bounds(bounds);
|
||||
}
|
||||
|
||||
@@ -402,8 +402,10 @@ fn print_type(&mut self, ty: &hir::Ty<'_>) {
|
||||
}
|
||||
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
|
||||
hir::TyKind::TraitObject(bounds, lifetime, syntax) => {
|
||||
if syntax == ast::TraitObjectSyntax::Dyn {
|
||||
self.word_space("dyn");
|
||||
match syntax {
|
||||
ast::TraitObjectSyntax::Dyn => self.word_nbsp("dyn"),
|
||||
ast::TraitObjectSyntax::DynStar => self.word_nbsp("dyn*"),
|
||||
ast::TraitObjectSyntax::None => {}
|
||||
}
|
||||
let mut first = true;
|
||||
for bound in bounds {
|
||||
|
||||
@@ -129,10 +129,7 @@
|
||||
"(0.).to_string()",
|
||||
"0. .. 1.",
|
||||
*/
|
||||
/*
|
||||
// FIXME: pretty-printer loses the dyn*. `i as Trait`
|
||||
"i as dyn* Trait",
|
||||
*/
|
||||
];
|
||||
|
||||
// Flatten the content of parenthesis nodes into their parent node. For example
|
||||
|
||||
@@ -58,14 +58,14 @@ help: consider adding an explicit lifetime bound
|
||||
LL | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static,
|
||||
| + +++++++++++
|
||||
|
||||
error[E0310]: the parameter type `impl FnOnce(T) -> Future<Output = ()>` may not live long enough
|
||||
error[E0310]: the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` may not live long enough
|
||||
--> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:14:5
|
||||
|
|
||||
LL | Box::new(executor)
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| the parameter type `impl FnOnce(T) -> Future<Output = ()>` must be valid for the static lifetime...
|
||||
| ...so that the type `impl FnOnce(T) -> Future<Output = ()>` will meet its required lifetime bounds
|
||||
| the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` must be valid for the static lifetime...
|
||||
| ...so that the type `impl FnOnce(T) -> dyn* Future<Output = ()>` will meet its required lifetime bounds
|
||||
|
|
||||
help: consider adding an explicit lifetime bound
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user