pretty: fix to print some lifetimes on HIR pretty-print

This commit is contained in:
Yutaro Ohno 2022-10-14 17:53:09 +09:00
parent 46244f335b
commit 7334526c38
3 changed files with 41 additions and 1 deletions

View File

@ -1687,7 +1687,11 @@ fn print_generic_args(
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

View File

@ -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> { }

View File

@ -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> {}