-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
The Great Generics Generalisation: Ty Edition #48523
Conversation
☔ The latest upstream changes (presumably #48520) made this pull request unmergeable. Please resolve the merge conflicts. |
2a0b89e
to
b4dbc02
Compare
Ping from triage, @varkor ! You have some merge conflicts you need to address, will you be able to get to those soon? |
@shepmaster: the merge conflicts should all be fairly routine (this code has a reasonably high bitrot rate) — I should be able to fix them without issue after a review, so I'll wait for now to avoid repeatedly fixing new conflicts as they arise. |
Ping from triage, @eddyb ! |
src/librustc/ty/mod.rs
Outdated
pub fn own_count(&self) -> usize { | ||
self.regions.len() + self.types.len() | ||
self.params.len() | ||
} |
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 method can be inlined everywhere it's used.
src/librustc_typeck/collect.rs
Outdated
regions.into_iter().map(|lt| ty::GenericParam::Lifetime(lt)).collect(); | ||
let types: Vec<ty::GenericParam> = | ||
types.into_iter().map(|ty| ty::GenericParam::Type(ty)).collect(); | ||
let params = lifetimes.into_iter().chain(types.into_iter()).collect(); |
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 should ideally not allocate for "lifetimes" / "types".
src/librustc/ty/mod.rs
Outdated
if let Some(index) = param.index.checked_sub(self.parent_count() as u32) { | ||
&self.regions[index as usize - self.has_self as usize] | ||
if let Some(index) = param.index.checked_sub(self.parent_count as u32) { | ||
// We're currently assuming that lifetimes precede other generic parameters. |
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.
Self
should come before lifetimes, such that indexing is trivial.
src/librustc/ty/subst.rs
Outdated
} | ||
}; | ||
assert_eq!(def.index() as usize, substs.len()); | ||
substs.push(param.pack()); |
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.
Please do not call pack
outside of the From
impls.
☔ The latest upstream changes (presumably #48611) made this pull request unmergeable. Please resolve the merge conflicts. |
b4dbc02
to
d0b0eb7
Compare
☔ The latest upstream changes (presumably #46882) made this pull request unmergeable. Please resolve the merge conflicts. |
937afe9
to
689b927
Compare
@eddyb ping from triage! This PR has new commits that needs to be reviewed. |
8c72a03
to
5ea91ac
Compare
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 5be2bdb has been approved by |
☀️ Test successful - status-appveyor, status-travis |
📣 Toolstate changed by #48523! Tested on commit e44fc6c. 💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra). |
Tested on commit rust-lang/rust@e44fc6c. Direct link to PR: <rust-lang/rust#48523> 💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra). 💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
Part of the generic parameter refactoring effort, split off from #48149. Contains the
ty
-relative refactoring.r? @eddyb