Skip to content

Commit

Permalink
Unrolled build for rust-lang#134601
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#134601 - dtolnay:dynstar, r=compiler-errors

Support pretty-printing `dyn*` trait objects

- Tracking issue: rust-lang#102425
  • Loading branch information
rust-timer authored Dec 22, 2024
2 parents c113247 + 23a2507 commit 8fa3942
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
6 changes: 4 additions & 2 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,10 @@ impl<'a> State<'a> {
}
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);
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,10 @@ impl<'a> State<'a> {
}
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 {
Expand Down
4 changes: 0 additions & 4 deletions tests/ui-fulldeps/pprust-parenthesis-insertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ static EXPRS: &[&str] = &[
"(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/unpretty/expanded-exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
#![feature(dyn_star)]
#![feature(explicit_tail_calls)]
#![feature(gen_blocks)]
#![feature(let_chains)]
Expand Down Expand Up @@ -800,6 +801,7 @@ mod types {
let _: dyn Send + 'static;
let _: dyn 'static + Send;
let _: dyn for<'a> Send;
let _: dyn* Send;
}

/// TyKind::ImplTrait
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/unpretty/expanded-exhaustive.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
#![feature(dyn_star)]
#![feature(explicit_tail_calls)]
#![feature(gen_blocks)]
#![feature(let_chains)]
Expand Down Expand Up @@ -647,6 +648,7 @@ mod types {
let _: dyn Send + 'static;
let _: dyn 'static + Send;
let _: dyn for<'a> Send;
let _: dyn* Send;
}
/// TyKind::ImplTrait
const fn ty_impl_trait() {
Expand Down

0 comments on commit 8fa3942

Please sign in to comment.