-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Refactor fmt::Display and fmt::Debug impls in ppaux #44888
Conversation
src/librustc/ty/context.rs
Outdated
@@ -882,6 +882,10 @@ pub struct GlobalCtxt<'tcx> { | |||
/// Maps Expr NodeId's to `true` iff `&expr` can have 'static lifetime. | |||
pub rvalue_promotable_to_static: RefCell<NodeMap<bool>>, | |||
|
|||
pub display_used_late_bound_region_names: RefCell<Option<FxHashSet<Name>>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely to cause problems with incremental compilation. I think the amount of globals ppaux is depending on is getting far out of hand, and we should stop using Display
& Debug
and start using our own trait.
88ced5d
to
257bf32
Compare
257bf32
to
ba022e0
Compare
I've refactored ppaux, and I think it's halfway done. I believe we can make this better, especially those macros; they are very rough. I defined macros because I can't just write r? @arielb1 |
|
src/librustc/util/ppaux.rs
Outdated
}; | ||
default impl<T> DefaultWith<T> for PrintContext {} | ||
|
||
impl<'tcx, T> DefaultWith<T> for PrintContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an... ok use of specialization. I suppose we can avoid it if we have to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I've missed your review -- what do you mean by that? I can't quite get it...
d83914d
to
5a2bcca
Compare
still same test needs updating |
Nice cleanup with the macros. There were a few directions I wanted to go there, but they can be in a separate PRs. LGTM, r=me after this passes travis. |
5a2bcca
to
512603b
Compare
I haven't fully tested this, I'll let travis do necessary tests. |
512603b
to
b9b45ed
Compare
}) | ||
} | ||
fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Binder<T>) | ||
where T: TypeFoldable<'tcx> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation, should be
fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Binder<T>)
where T: TypeFoldable<'tcx>
nah you don't have to fix the indentation @bors r+ |
📌 Commit b9b45ed has been approved by |
Thanks for the PR! That's a very cool use of macros. |
⌛ Testing commit b9b45ed1a4f1168906f2725a2696e79b07843ef6 with merge c914972d622e7c4f44a62adf06fbba4c30fb5084... |
💔 Test failed - status-travis |
b9b45ed
to
c11eeb3
Compare
☔ The latest upstream changes (presumably #45100) made this pull request unmergeable. Please resolve the merge conflicts. |
Now they don't shadow other lifetimes.
c11eeb3
to
e46bf1c
Compare
e46bf1c
to
84cb90f
Compare
@bors r+ |
📌 Commit 84cb90f has been approved by |
Refactor fmt::Display and fmt::Debug impls in ppaux Also fixes #44887. There was a problem that unnamed late-bound regions are *always* named `'r` while they are displayed using `std::fmt::Display`. --- ```rust fn main() { f(|_: (), _: ()| {}); } fn f<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} ``` Before (incorrectly shadows lifetime, `for<'r>` omitted for the second argument): ``` error[E0631]: type mismatch in closure arguments --> test.rs:2:5 | 2 | f(|_: (), _: ()| {}); | ^ ----------------- found signature of `fn((), ()) -> _` | | | expected signature of `for<'r> fn(&'r (), fn(&'r ())) -> _` | = note: required by `f` ``` After: ``` error[E0631]: type mismatch in closure arguments --> test.rs:2:5 | 2 | f(|_: (), _: ()| {}); | ^ ----------------- found signature of `fn((), ()) -> _` | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | = note: required by `f` ``` r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Also fixes #44887.
There was a problem that unnamed late-bound regions are always named
'r
while they are displayed usingstd::fmt::Display
.Before (incorrectly shadows lifetime,
for<'r>
omitted for the second argument):After:
r? @nikomatsakis