Skip to content

Commit d08f4a6

Browse files
authored
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 #85089
2 parents 3c0ea4a + 7334526 commit d08f4a6

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

compiler/rustc_hir_pretty/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,11 @@ impl<'a> State<'a> {
16871687

16881688
let mut nonelided_generic_args: bool = false;
16891689
let elide_lifetimes = generic_args.args.iter().all(|arg| match arg {
1690-
GenericArg::Lifetime(lt) => lt.is_elided(),
1690+
GenericArg::Lifetime(lt) if lt.is_elided() => true,
1691+
GenericArg::Lifetime(_) => {
1692+
nonelided_generic_args = true;
1693+
false
1694+
}
16911695
_ => {
16921696
nonelided_generic_args = true;
16931697
true

src/test/pretty/issue-85089.pp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#[prelude_import]
2+
use ::std::prelude::rust_2015::*;
3+
#[macro_use]
4+
extern crate std;
5+
// Test to print lifetimes on HIR pretty-printing.
6+
7+
// pretty-compare-only
8+
// pretty-mode:hir
9+
// pp-exact:issue-85089.pp
10+
11+
trait A<'x> { }
12+
trait B<'x> { }
13+
14+
struct Foo<'b> {
15+
bar: &'b dyn for<'a> A<'a>,
16+
}
17+
18+
impl <'a> B<'a> for dyn for<'b> A<'b> { }
19+
20+
impl <'a> A<'a> for Foo<'a> { }

src/test/pretty/issue-85089.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Test to print lifetimes on HIR pretty-printing.
2+
3+
// pretty-compare-only
4+
// pretty-mode:hir
5+
// pp-exact:issue-85089.pp
6+
7+
trait A<'x> {}
8+
trait B<'x> {}
9+
10+
struct Foo<'b> {
11+
pub bar: &'b dyn for<'a> A<'a>,
12+
}
13+
14+
impl<'a> B<'a> for dyn for<'b> A<'b> {}
15+
16+
impl<'a> A<'a> for Foo<'a> {}

0 commit comments

Comments
 (0)