diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-22 03:49:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-22 03:49:43 +0100 |
| commit | bcdde4ea5b86e364108e41ee7baa27ce5c13c6b0 (patch) | |
| tree | 080696ad7e1da425577fcf57fde5ecd705562c03 | |
| parent | 3a94f4c60feaa27e0b80766b940d815a504ff61e (diff) | |
| parent | 23a250738b6dbba043a4722d18561c0629cfa453 (diff) | |
| download | rust-bcdde4ea5b86e364108e41ee7baa27ce5c13c6b0.tar.gz rust-bcdde4ea5b86e364108e41ee7baa27ce5c13c6b0.zip | |
Rollup merge of #134601 - dtolnay:dynstar, r=compiler-errors
Support pretty-printing `dyn*` trait objects - Tracking issue: https://github.com/rust-lang/rust/issues/102425
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 6 | ||||
| -rw-r--r-- | tests/ui-fulldeps/pprust-parenthesis-insertion.rs | 4 | ||||
| -rw-r--r-- | tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr | 6 | ||||
| -rw-r--r-- | tests/ui/unpretty/expanded-exhaustive.rs | 2 | ||||
| -rw-r--r-- | tests/ui/unpretty/expanded-exhaustive.stdout | 2 |
6 files changed, 15 insertions, 11 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 24c1c0f221e..172df102929 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -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); } diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index de2a7726e9b..5c1c5892190 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -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 { diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index 258a1fdb1d3..d6021b559d6 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -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 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 f7fc17ea24f..1fb3e7d211e 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr @@ -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 | diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs index 98fe05cf7c8..e052627e71c 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -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)] @@ -800,6 +801,7 @@ mod types { let _: dyn Send + 'static; let _: dyn 'static + Send; let _: dyn for<'a> Send; + let _: dyn* Send; } /// TyKind::ImplTrait diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout index 452c06dd7e4..132d00cd8ed 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -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)] @@ -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() { |
