diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-10-16 11:41:13 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-16 11:41:13 +0900 |
| commit | d08f4a6464c29c081cb92f95d60fcb014bd039d6 (patch) | |
| tree | 09074248af7bc0b426f6c0f0359b5c5f01021d59 | |
| parent | 3c0ea4af8b3a7e455c983777888af61b639af3d9 (diff) | |
| parent | 7334526c3803d9d9a5a9b017618aa95d618f687a (diff) | |
| download | rust-d08f4a6464c29c081cb92f95d60fcb014bd039d6.tar.gz rust-d08f4a6464c29c081cb92f95d60fcb014bd039d6.zip | |
Rollup merge of #103080 - ohno418:fix-hir-pretty-print-lifetimes, r=cjgillot
pretty: fix to print some lifetimes on HIR pretty-print HIR pretty-printer doesn't seem to print some lifetimes in types. This PR fixes that. Closes https://github.com/rust-lang/rust/issues/85089
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 6 | ||||
| -rw-r--r-- | src/test/pretty/issue-85089.pp | 20 | ||||
| -rw-r--r-- | src/test/pretty/issue-85089.rs | 16 |
3 files changed, 41 insertions, 1 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 729139adc2d..da27554a229 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1687,7 +1687,11 @@ impl<'a> State<'a> { let mut nonelided_generic_args: bool = false; let elide_lifetimes = generic_args.args.iter().all(|arg| match arg { - GenericArg::Lifetime(lt) => lt.is_elided(), + GenericArg::Lifetime(lt) if lt.is_elided() => true, + GenericArg::Lifetime(_) => { + nonelided_generic_args = true; + false + } _ => { nonelided_generic_args = true; true diff --git a/src/test/pretty/issue-85089.pp b/src/test/pretty/issue-85089.pp new file mode 100644 index 00000000000..f84e9df04a2 --- /dev/null +++ b/src/test/pretty/issue-85089.pp @@ -0,0 +1,20 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// Test to print lifetimes on HIR pretty-printing. + +// pretty-compare-only +// pretty-mode:hir +// pp-exact:issue-85089.pp + +trait A<'x> { } +trait B<'x> { } + +struct Foo<'b> { + bar: &'b dyn for<'a> A<'a>, +} + +impl <'a> B<'a> for dyn for<'b> A<'b> { } + +impl <'a> A<'a> for Foo<'a> { } diff --git a/src/test/pretty/issue-85089.rs b/src/test/pretty/issue-85089.rs new file mode 100644 index 00000000000..eb45d473119 --- /dev/null +++ b/src/test/pretty/issue-85089.rs @@ -0,0 +1,16 @@ +// Test to print lifetimes on HIR pretty-printing. + +// pretty-compare-only +// pretty-mode:hir +// pp-exact:issue-85089.pp + +trait A<'x> {} +trait B<'x> {} + +struct Foo<'b> { + pub bar: &'b dyn for<'a> A<'a>, +} + +impl<'a> B<'a> for dyn for<'b> A<'b> {} + +impl<'a> A<'a> for Foo<'a> {} |
