-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Retire hir::*ItemRef. #143357
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
Open
cjgillot
wants to merge
8
commits into
rust-lang:master
Choose a base branch
from
cjgillot:no-assoc-item-kind
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+663
−898
Open
Retire hir::*ItemRef. #143357
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad6e587
Remove usused depth.
cjgillot 50ca0c6
Delegation: self parameter must be named exactly `self`.
cjgillot 3ecd03b
Move trait_item_def_id from ImplItemRef to ImplItem.
cjgillot 277b0ec
Remove hir::AssocItemKind.
cjgillot 36bc094
Generalize TyCtxt::item_name.
cjgillot 5bd3841
Retire hir::ForeignItemRef.
cjgillot 21fd82a
Retire hir::*ItemRef.
cjgillot 27127e3
Bless incremental tests.
cjgillot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,11 +393,9 @@ impl<'hir> LoweringContext<'_, 'hir> { | |
(trait_ref, lowered_ty) | ||
}); | ||
|
||
let new_impl_items = self.arena.alloc_from_iter( | ||
impl_items | ||
.iter() | ||
.map(|item| self.lower_impl_item_ref(item, trait_ref.is_some())), | ||
); | ||
let new_impl_items = self | ||
.arena | ||
.alloc_from_iter(impl_items.iter().map(|item| self.lower_impl_item_ref(item))); | ||
|
||
// `defaultness.has_value()` is never called for an `impl`, always `true` in order | ||
// to not cause an assertion failure inside the `lower_defaultness` function. | ||
|
@@ -706,14 +704,8 @@ impl<'hir> LoweringContext<'_, 'hir> { | |
self.arena.alloc(item) | ||
} | ||
|
||
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef { | ||
hir::ForeignItemRef { | ||
id: hir::ForeignItemId { owner_id: self.owner_id(i.id) }, | ||
// `unwrap` is safe because `ForeignItemKind::MacCall` is the only foreign item kind | ||
// without an identifier and it cannot reach here. | ||
ident: self.lower_ident(i.kind.ident().unwrap()), | ||
span: self.lower_span(i.span), | ||
} | ||
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemId { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise naming |
||
hir::ForeignItemId { owner_id: self.owner_id(i.id) } | ||
} | ||
|
||
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> { | ||
|
@@ -972,32 +964,8 @@ impl<'hir> LoweringContext<'_, 'hir> { | |
self.arena.alloc(item) | ||
} | ||
|
||
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef { | ||
let (ident, kind) = match &i.kind { | ||
AssocItemKind::Const(box ConstItem { ident, .. }) => { | ||
(*ident, hir::AssocItemKind::Const) | ||
} | ||
AssocItemKind::Type(box TyAlias { ident, .. }) => (*ident, hir::AssocItemKind::Type), | ||
AssocItemKind::Fn(box Fn { ident, sig, .. }) => { | ||
(*ident, hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }) | ||
} | ||
AssocItemKind::Delegation(box delegation) => ( | ||
delegation.ident, | ||
hir::AssocItemKind::Fn { | ||
has_self: self.delegatee_is_method(i.id, delegation.id, i.span, false), | ||
}, | ||
), | ||
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => { | ||
panic!("macros should have been expanded by now") | ||
} | ||
}; | ||
let id = hir::TraitItemId { owner_id: self.owner_id(i.id) }; | ||
hir::TraitItemRef { | ||
id, | ||
ident: self.lower_ident(ident), | ||
span: self.lower_span(i.span), | ||
kind, | ||
} | ||
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemId { | ||
hir::TraitItemId { owner_id: self.owner_id(i.id) } | ||
} | ||
|
||
/// Construct `ExprKind::Err` for the given `span`. | ||
|
@@ -1128,41 +1096,17 @@ impl<'hir> LoweringContext<'_, 'hir> { | |
span: self.lower_span(i.span), | ||
defaultness, | ||
has_delayed_lints: !self.delayed_lints.is_empty(), | ||
}; | ||
self.arena.alloc(item) | ||
} | ||
|
||
fn lower_impl_item_ref(&mut self, i: &AssocItem, is_in_trait_impl: bool) -> hir::ImplItemRef { | ||
hir::ImplItemRef { | ||
id: hir::ImplItemId { owner_id: self.owner_id(i.id) }, | ||
// `unwrap` is safe because `AssocItemKind::{MacCall,DelegationMac}` are the only | ||
// assoc item kinds without an identifier and they cannot reach here. | ||
ident: self.lower_ident(i.kind.ident().unwrap()), | ||
span: self.lower_span(i.span), | ||
kind: match &i.kind { | ||
AssocItemKind::Const(..) => hir::AssocItemKind::Const, | ||
AssocItemKind::Type(..) => hir::AssocItemKind::Type, | ||
AssocItemKind::Fn(box Fn { sig, .. }) => { | ||
hir::AssocItemKind::Fn { has_self: sig.decl.has_self() } | ||
} | ||
AssocItemKind::Delegation(box delegation) => hir::AssocItemKind::Fn { | ||
has_self: self.delegatee_is_method( | ||
i.id, | ||
delegation.id, | ||
i.span, | ||
is_in_trait_impl, | ||
), | ||
}, | ||
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => { | ||
panic!("macros should have been expanded by now") | ||
} | ||
}, | ||
trait_item_def_id: self | ||
.resolver | ||
.get_partial_res(i.id) | ||
.map(|r| r.expect_full_res().opt_def_id()) | ||
.unwrap_or(None), | ||
} | ||
}; | ||
self.arena.alloc(item) | ||
} | ||
|
||
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemId { | ||
hir::ImplItemId { owner_id: self.owner_id(i.id) } | ||
} | ||
|
||
fn lower_defaultness( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is it still called
visit_trait_item_ref
? Should we give this a better name?