Support pretty-printing dyn* trait objects
This commit is contained in:
parent
13170cd787
commit
1cc8289791
4 changed files with 11 additions and 10 deletions
|
@ -1204,8 +1204,10 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
ast::TyKind::Path(Some(qself), path) => self.print_qpath(path, qself, false),
|
ast::TyKind::Path(Some(qself), path) => self.print_qpath(path, qself, false),
|
||||||
ast::TyKind::TraitObject(bounds, syntax) => {
|
ast::TyKind::TraitObject(bounds, syntax) => {
|
||||||
if *syntax == ast::TraitObjectSyntax::Dyn {
|
match syntax {
|
||||||
self.word_nbsp("dyn");
|
ast::TraitObjectSyntax::Dyn => self.word_nbsp("dyn"),
|
||||||
|
ast::TraitObjectSyntax::DynStar => self.word_nbsp("dyn*"),
|
||||||
|
ast::TraitObjectSyntax::None => {}
|
||||||
}
|
}
|
||||||
self.print_type_bounds(bounds);
|
self.print_type_bounds(bounds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,8 +402,10 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
|
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
|
||||||
hir::TyKind::TraitObject(bounds, lifetime, syntax) => {
|
hir::TyKind::TraitObject(bounds, lifetime, syntax) => {
|
||||||
if syntax == ast::TraitObjectSyntax::Dyn {
|
match syntax {
|
||||||
self.word_space("dyn");
|
ast::TraitObjectSyntax::Dyn => self.word_nbsp("dyn"),
|
||||||
|
ast::TraitObjectSyntax::DynStar => self.word_nbsp("dyn*"),
|
||||||
|
ast::TraitObjectSyntax::None => {}
|
||||||
}
|
}
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
|
|
|
@ -129,10 +129,7 @@ static EXPRS: &[&str] = &[
|
||||||
"(0.).to_string()",
|
"(0.).to_string()",
|
||||||
"0. .. 1.",
|
"0. .. 1.",
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
// FIXME: pretty-printer loses the dyn*. `i as Trait`
|
|
||||||
"i as dyn* Trait",
|
"i as dyn* Trait",
|
||||||
*/
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Flatten the content of parenthesis nodes into their parent node. For example
|
// 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,
|
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
|
--> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:14:5
|
||||||
|
|
|
|
||||||
LL | Box::new(executor)
|
LL | Box::new(executor)
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
| |
|
||||||
| the parameter type `impl FnOnce(T) -> Future<Output = ()>` must be valid for the static lifetime...
|
| the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` must be valid for the static lifetime...
|
||||||
| ...so that the type `impl FnOnce(T) -> Future<Output = ()>` will meet its required lifetime bounds
|
| ...so that the type `impl FnOnce(T) -> dyn* Future<Output = ()>` will meet its required lifetime bounds
|
||||||
|
|
|
|
||||||
help: consider adding an explicit lifetime bound
|
help: consider adding an explicit lifetime bound
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue