Remove shorthand from HIR

This commit is contained in:
CoCo-Japan-pan
2026-04-04 16:53:30 +09:00
parent 159f1f24fa
commit 5863660b0d
5 changed files with 7 additions and 12 deletions
+2 -5
View File
@@ -1842,13 +1842,10 @@ pub(super) fn lower_impl_restriction(
) -> &'hir hir::ImplRestriction<'hir> {
let kind = match &r.kind {
RestrictionKind::Unrestricted => hir::RestrictionKind::Unrestricted,
RestrictionKind::Restricted { path, id, shorthand } => {
RestrictionKind::Restricted { path, id, shorthand: _ } => {
let res = self.resolver.get_partial_res(*id);
if let Some(did) = res.and_then(|res| res.expect_full_res().opt_def_id()) {
hir::RestrictionKind::Restricted {
path: self.lower_mod_path(did, path),
shorthand: *shorthand,
}
hir::RestrictionKind::Restricted(self.lower_mod_path(did, path))
} else {
self.dcx().span_delayed_bug(path.span, "should have errored in resolve");
hir::RestrictionKind::Unrestricted
+1 -1
View File
@@ -4416,7 +4416,7 @@ pub enum RestrictionKind<'hir> {
/// The restriction does not affect the item.
Unrestricted,
/// The restriction only applies outside of this path.
Restricted { path: &'hir ModPath<'hir>, shorthand: bool },
Restricted(&'hir ModPath<'hir>),
}
/// The actual safety specified in syntax. We may treat
+1 -1
View File
@@ -628,7 +628,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
bounds,
trait_item_refs,
) => {
if let RestrictionKind::Restricted { path, shorthand: _ } = &impl_restriction.kind {
if let RestrictionKind::Restricted(path) = &impl_restriction.kind {
walk_list!(visitor, visit_path_segment, path.segments);
}
try_visit!(visitor.visit_ident(ident));
+1 -1
View File
@@ -899,7 +899,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
false,
is_auto == hir::IsAuto::Yes,
safety,
if let hir::RestrictionKind::Restricted { path, shorthand: _ } = impl_restriction.kind {
if let hir::RestrictionKind::Restricted(path) = impl_restriction.kind {
ty::trait_def::ImplRestrictionKind::Restricted(path.res, impl_restriction.span)
} else {
ty::trait_def::ImplRestrictionKind::Unrestricted
+2 -4
View File
@@ -2651,11 +2651,9 @@ fn print_is_auto(&mut self, s: hir::IsAuto) {
fn print_impl_restriction(&mut self, r: &hir::ImplRestriction<'_>) {
match r.kind {
hir::RestrictionKind::Unrestricted => {}
hir::RestrictionKind::Restricted { path, shorthand } => {
hir::RestrictionKind::Restricted(path) => {
self.word("impl(");
if shorthand {
self.word_nbsp("in");
}
self.word_nbsp("in");
self.print_path(path, false);
self.word(")");
}