-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
remove interior mutability of type-flags #42015
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
Conversation
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
|
cc @arielb1 |
src/librustc/ty/mod.rs
Outdated
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.
Only two flags removed?
617ed25 to
aa511ce
Compare
Mark-Simulacrum
left a comment
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.
Just some minor nits, no need to bother if you don't want to.
src/librustc/infer/mod.rs
Outdated
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.
We could just use ty::ParameterEnvironment here and avoid adding the import.
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.
Speaking of which, renaming it to ParamEnv might be a good idea?
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.
I always go back and forth on the importing question. I tend to prefer the import, so as to avoid having to write modules everywhere, and comply more closely with the Rust style guidelines (which suggest importing types, but not fns) -- but it does mean more merge conflicts around use declarations, which is annoying.
src/librustc/ty/mod.rs
Outdated
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.
I think this is now small enough to be a u16 instead of a u32 bitflags!
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.
It was always wasteful, heh. And I think due to padding it ends up using a lot anyway.
src/librustc_trans/context.rs
Outdated
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.
Minor, but we could avoid the additional import with ty::ParamEnv. I think this occurs elsewhere, too.
src/librustc/ty/mod.rs
Outdated
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.
😻
src/librustc/ty/util.rs
Outdated
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.
I see you killed some of the shortcutting?
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.
I figured it'd fall out from the caching anyway.
eddyb
left a comment
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.
LGTM, modulo nits.
|
ok, I made some style changes (s/ParameterEnvironment/ParamEnv/, removed imports) -- I haven't finished building this locally yet though :) |
src/librustc/traits/README.md
Outdated
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 looks wrong, but is minor. Should ideally be "to the ParamEnv".
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.
fixed.
src/librustc/ty/util.rs
Outdated
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 again somewhat painful to me since we use both ty::ParamEnv and ParamEnv in this file. Don't bother fixing if you don't want to though.
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.
fixed.
4f431a4 to
3977ee7
Compare
|
☔ The latest upstream changes (presumably #41911) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@nikomatsakis looks like this is back in your court now, friendly ping! |
Use the trait-environment+type as the key. Note that these are only invoked on types that live for the entire compilation (no inference artifacts). We no longer need the various special-case bits and caches that were in place before.
e3435fb to
15abc19
Compare
Ideally, we'd have the `Ty` inserted directly in the dep-node, but since we can't do that yet, we extract the characteristic def-id of the type in question.
d9dab46 to
83641a9
Compare
|
@bors r=eddyb |
|
📌 Commit 83641a9 has been approved by |
remove interior mutability of type-flags We were previously using the flags on `Ty<'tcx>` instances to do some ad-hoc caching schemes around things like `is_sized()`, `is_freeze()`, and `moves_by_default()`. This PR replaces those schemes with a proper query; the query key is based on the pair of a `(ParameterEnvironment<'tcx>, Ty<'tcx>)` pair. This is also intended to be a preliminary template for what trait-selection and projection will eventually look like. I did some performance measurements. In the past, I observed a noticeable speedup (6%) for building rustc, but since I've rebased, the numbers appear to be more of a wash: | Crate | Before | After | Percentage | | --- | --- | --- | -- | | syntax | 167s | 166s | 0.6% faster | | rustc | 376s | 382s | 1.5% slower | Some advantages of this new scheme: - `is_sized` etc are proper queries - we get caching across generic fns, so long as trait environment is identical - dependency tracking is correct
|
☀️ Test successful - status-appveyor, status-travis |
We were previously using the flags on
Ty<'tcx>instances to do some ad-hoc caching schemes around things likeis_sized(),is_freeze(), andmoves_by_default(). This PR replaces those schemes with a proper query; the query key is based on the pair of a(ParameterEnvironment<'tcx>, Ty<'tcx>)pair. This is also intended to be a preliminary template for what trait-selection and projection will eventually look like.I did some performance measurements. In the past, I observed a noticeable speedup (6%) for building rustc, but since I've rebased, the numbers appear to be more of a wash:
Some advantages of this new scheme:
is_sizedetc are proper queries