diff options
| author | bors <bors@rust-lang.org> | 2024-06-18 09:30:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-18 09:30:38 +0000 |
| commit | c1f62a7c35349438ea9728abbe1bcf1cebd426b7 (patch) | |
| tree | 257f509fbdc6f8439505426b2f899b46960f662b /compiler/rustc_hir_pretty/src/lib.rs | |
| parent | f873ae029e3ee2bbb8bc70a7ef3f1a06c22b0eac (diff) | |
| parent | 227374714f3429e401c2c572a7eba00a4423ae09 (diff) | |
| download | rust-c1f62a7c35349438ea9728abbe1bcf1cebd426b7.tar.gz rust-c1f62a7c35349438ea9728abbe1bcf1cebd426b7.zip | |
Auto merge of #126049 - compiler-errors:rework-use, r=oli-obk
Rework `feature(precise_capturing)` to represent `use<...>` as a syntactical bound Reworks `precise_capturing` for a recent lang-team consensus. Specifically: > The conclusion of the team is that we'll make use<..> a bound. That is, we'll support impl use<..> + Trait, impl Trait + use<..>, etc. > For now, we will support at most one such bound in a list of bounds, and semantically we'll only support these bounds in the item bounds of RPIT-like impl Trait opaque types (i.e., in the places discussed in the RFC). Lang decision in favor of this approach: - https://github.com/rust-lang/rust/issues/125836#issuecomment-2151351849 Tracking: - https://github.com/rust-lang/rust/issues/123432
Diffstat (limited to 'compiler/rustc_hir_pretty/src/lib.rs')
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index d32d0183c4e..b21f1eadfb7 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust::{Comments, PrintState}; use rustc_hir as hir; use rustc_hir::{ BindingMode, ByRef, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId, - LifetimeParamKind, Node, PatKind, RangeEnd, Term, TraitBoundModifier, + LifetimeParamKind, Node, PatKind, PreciseCapturingArg, RangeEnd, Term, TraitBoundModifier, }; use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, Ident, Symbol}; @@ -2100,10 +2100,24 @@ impl<'a> State<'a> { GenericBound::Outlives(lt) => { self.print_lifetime(lt); } + GenericBound::Use(args, _) => { + self.word("use <"); + + self.commasep(Inconsistent, args, |s, arg| s.print_precise_capturing_arg(*arg)); + + self.word(">"); + } } } } + fn print_precise_capturing_arg(&mut self, arg: PreciseCapturingArg<'_>) { + match arg { + PreciseCapturingArg::Lifetime(lt) => self.print_lifetime(lt), + PreciseCapturingArg::Param(arg) => self.print_ident(arg.ident), + } + } + fn print_generic_params(&mut self, generic_params: &[GenericParam<'_>]) { if !generic_params.is_empty() { self.word("<"); |
