Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #103105

Merged
merged 16 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pretty: fix to print some lifetimes on HIR pretty-print
  • Loading branch information
ohno418 committed Oct 15, 2022
commit 7334526c3803d9d9a5a9b017618aa95d618f687a
6 changes: 5 additions & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/test/pretty/issue-85089.pp
Original file line number Diff line number Diff line change
@@ -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> { }
16 changes: 16 additions & 0 deletions src/test/pretty/issue-85089.rs
Original file line number Diff line number Diff line change
@@ -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> {}