Skip to content

Commit 5a19fbb

Browse files
committed
Box ItemKind::Impl
This brings the size of ItemKind down from 128 to 88 bytes. Hopefully this will have perf improvements.
1 parent 84ee982 commit 5a19fbb

File tree

54 files changed

+101
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+101
-78
lines changed

compiler/rustc_ast_lowering/src/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
134134
let old_len = self.in_scope_lifetimes.len();
135135

136136
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind {
137-
hir::ItemKind::Impl(hir::Impl { ref generics, .. })
137+
hir::ItemKind::Impl(box hir::Impl { ref generics, .. })
138138
| hir::ItemKind::Trait(_, _, ref generics, ..) => &generics.params[..],
139139
_ => &[],
140140
};
@@ -431,7 +431,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
431431
// to not cause an assertion failure inside the `lower_defaultness` function.
432432
let has_val = true;
433433
let (defaultness, defaultness_span) = self.lower_defaultness(defaultness, has_val);
434-
hir::ItemKind::Impl(hir::Impl {
434+
hir::ItemKind::Impl(box hir::Impl {
435435
unsafety: self.lower_unsafety(unsafety),
436436
polarity,
437437
defaultness,

compiler/rustc_ast_lowering/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
//! in the HIR, especially for multiple identifiers.
3232
3333
#![feature(array_value_iter)]
34+
#![feature(box_patterns)]
35+
#![feature(box_syntax)]
3436
#![feature(crate_visibility_modifier)]
3537
#![feature(or_patterns)]
3638
#![recursion_limit = "256"]

compiler/rustc_hir/src/hir.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2562,9 +2562,12 @@ pub enum ItemKind<'hir> {
25622562
TraitAlias(Generics<'hir>, GenericBounds<'hir>),
25632563

25642564
/// An implementation, e.g., `impl<A> Trait for Foo { .. }`.
2565-
Impl(Impl<'hir>),
2565+
Impl(Box<Impl<'hir>>),
25662566
}
25672567

2568+
#[cfg(target_arch = "x86_64")]
2569+
static_assert_size!(ItemKind<'_>, 88);
2570+
25682571
#[derive(Debug, HashStable_Generic)]
25692572
pub struct Impl<'hir> {
25702573
pub unsafety: Unsafety,
@@ -2593,7 +2596,7 @@ impl ItemKind<'_> {
25932596
| ItemKind::Struct(_, ref generics)
25942597
| ItemKind::Union(_, ref generics)
25952598
| ItemKind::Trait(_, _, ref generics, _, _)
2596-
| ItemKind::Impl(Impl { ref generics, .. }) => generics,
2599+
| ItemKind::Impl(box Impl { ref generics, .. }) => generics,
25972600
_ => return None,
25982601
})
25992602
}

compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
611611
// `visit_enum_def()` takes care of visiting the `Item`'s `HirId`.
612612
visitor.visit_enum_def(enum_definition, generics, item.hir_id, item.span)
613613
}
614-
ItemKind::Impl(Impl {
614+
ItemKind::Impl(box Impl {
615615
unsafety: _,
616616
defaultness: _,
617617
polarity: _,

compiler/rustc_hir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
44
55
#![feature(array_value_iter)]
6+
#![feature(box_patterns)]
67
#![feature(crate_visibility_modifier)]
78
#![feature(const_fn)] // For the unsizing cast on `&[]`
89
#![feature(const_panic)]

compiler/rustc_hir_pretty/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(box_patterns)]
12
#![feature(or_patterns)]
23
#![recursion_limit = "256"]
34

@@ -684,7 +685,7 @@ impl<'a> State<'a> {
684685
self.head(visibility_qualified(&item.vis, "union"));
685686
self.print_struct(struct_def, generics, item.ident.name, item.span, true);
686687
}
687-
hir::ItemKind::Impl(hir::Impl {
688+
hir::ItemKind::Impl(box hir::Impl {
688689
unsafety,
689690
polarity,
690691
defaultness,

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
346346
Some(Node::ImplItem(ImplItem { ident, hir_id, .. })) => {
347347
match tcx.hir().find(tcx.hir().get_parent_item(*hir_id)) {
348348
Some(Node::Item(Item {
349-
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
349+
kind: ItemKind::Impl(box hir::Impl { self_ty, .. }),
350350
..
351351
})) => Some((*ident, self_ty)),
352352
_ => None,
@@ -368,7 +368,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
368368
let impl_did = tcx.hir().local_def_id(*impl_node);
369369
match tcx.hir().get_if_local(impl_did.to_def_id()) {
370370
Some(Node::Item(Item {
371-
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
371+
kind: ItemKind::Impl(box hir::Impl { self_ty, .. }),
372372
..
373373
})) if trait_objects.iter().all(|did| {
374374
// FIXME: we should check `self_ty` against the receiver

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
542542
return;
543543
}
544544
}
545-
hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref trait_ref), items, .. }) => {
545+
hir::ItemKind::Impl(box hir::Impl { of_trait: Some(ref trait_ref), items, .. }) => {
546546
// If the trait is private, add the impl items to `private_traits` so they don't get
547547
// reported for missing docs.
548548
let real_trait = trait_ref.path.res.def_id();

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![cfg_attr(test, feature(test))]
3030
#![feature(array_windows)]
3131
#![feature(bool_to_option)]
32+
#![feature(box_patterns)]
3233
#![feature(box_syntax)]
3334
#![feature(crate_visibility_modifier)]
3435
#![feature(iter_order_by)]

compiler/rustc_metadata/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![feature(box_patterns)]
23
#![feature(core_intrinsics)]
34
#![feature(crate_visibility_modifier)]
45
#![feature(drain_filter)]

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ impl EncodeContext<'a, 'tcx> {
12831283
is_non_exhaustive: variant.is_field_list_non_exhaustive(),
12841284
}), adt_def.repr)
12851285
}
1286-
hir::ItemKind::Impl(hir::Impl { defaultness, .. }) => {
1286+
hir::ItemKind::Impl(box hir::Impl { defaultness, .. }) => {
12871287
let trait_ref = self.tcx.impl_trait_ref(def_id);
12881288
let polarity = self.tcx.impl_polarity(def_id);
12891289
let parent = if let Some(trait_ref) = trait_ref {

compiler/rustc_middle/src/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'hir> Map<'hir> {
505505
| ItemKind::Union(_, generics)
506506
| ItemKind::Trait(_, _, generics, ..)
507507
| ItemKind::TraitAlias(generics, _)
508-
| ItemKind::Impl(Impl { generics, .. }),
508+
| ItemKind::Impl(box Impl { generics, .. }),
509509
..
510510
}) => Some(generics),
511511
_ => None,

compiler/rustc_middle/src/ty/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ fn foo(&self) -> Self::T { String::new() }
829829
}
830830
}
831831
Some(hir::Node::Item(hir::Item {
832-
kind: hir::ItemKind::Impl(hir::Impl { items, .. }),
832+
kind: hir::ItemKind::Impl(box hir::Impl { items, .. }),
833833
..
834834
})) => {
835835
for item in &items[..] {

compiler/rustc_mir/src/const_eval/fn_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn is_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
126126
matches!(
127127
node,
128128
hir::Node::Item(hir::Item {
129-
kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }),
129+
kind: hir::ItemKind::Impl(box hir::Impl { constness: hir::Constness::Const, .. }),
130130
..
131131
})
132132
)

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl CheckAttrVisitor<'tcx> {
343343
// We can't link to trait impl's consts.
344344
let err = "associated constant in trait implementation block";
345345
match containing_item.kind {
346-
ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) => Some(err),
346+
ItemKind::Impl(box hir::Impl { of_trait: Some(_), .. }) => Some(err),
347347
_ => None,
348348
}
349349
}

compiler/rustc_passes/src/dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
396396
}
397397
}
398398
}
399-
hir::ItemKind::Impl(hir::Impl { ref of_trait, items, .. }) => {
399+
hir::ItemKind::Impl(box hir::Impl { ref of_trait, items, .. }) => {
400400
if of_trait.is_some() {
401401
self.worklist.push(item.hir_id);
402402
}

compiler/rustc_passes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![feature(box_patterns)]
89
#![feature(const_fn)]
910
#![feature(const_panic)]
1011
#![feature(crate_visibility_modifier)]

compiler/rustc_passes/src/reachable.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
349349
}
350350

351351
// We need only trait impls here, not inherent impls, and only non-exported ones
352-
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref trait_ref), ref items, .. }) =
353-
item.kind
352+
if let hir::ItemKind::Impl(box hir::Impl {
353+
of_trait: Some(ref trait_ref), ref items, ..
354+
}) = item.kind
354355
{
355356
if !self.access_levels.is_reachable(item.hir_id) {
356357
// FIXME(#53488) remove `let`

compiler/rustc_passes/src/stability.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
330330
// they don't have their own stability. They still can be annotated as unstable
331331
// and propagate this unstability to children, but this annotation is completely
332332
// optional. They inherit stability from their parents when unannotated.
333-
hir::ItemKind::Impl(hir::Impl { of_trait: None, .. })
333+
hir::ItemKind::Impl(box hir::Impl { of_trait: None, .. })
334334
| hir::ItemKind::ForeignMod { .. } => {
335335
self.in_trait_impl = false;
336336
kind = AnnotationKind::Container;
337337
}
338-
hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) => {
338+
hir::ItemKind::Impl(box hir::Impl { of_trait: Some(_), .. }) => {
339339
self.in_trait_impl = true;
340340
kind = AnnotationKind::DeprecationProhibited;
341341
}
@@ -504,7 +504,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
504504
// optional. They inherit stability from their parents when unannotated.
505505
if !matches!(
506506
i.kind,
507-
hir::ItemKind::Impl(hir::Impl { of_trait: None, .. }) | hir::ItemKind::ForeignMod { .. }
507+
hir::ItemKind::Impl(box hir::Impl { of_trait: None, .. }) | hir::ItemKind::ForeignMod { .. }
508508
) {
509509
self.check_missing_stability(i.hir_id, i.span);
510510
}
@@ -673,7 +673,9 @@ impl Visitor<'tcx> for Checker<'tcx> {
673673
// For implementations of traits, check the stability of each item
674674
// individually as it's possible to have a stable trait with unstable
675675
// items.
676-
hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref t), self_ty, items, .. }) => {
676+
hir::ItemKind::Impl(box hir::Impl {
677+
of_trait: Some(ref t), self_ty, items, ..
678+
}) => {
677679
if self.tcx.features().staged_api {
678680
// If this impl block has an #[unstable] attribute, give an
679681
// error if all involved types and traits are stable, because

compiler/rustc_privacy/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![feature(box_patterns)]
23
#![feature(in_band_lifetimes)]
34
#![feature(nll)]
45
#![feature(or_patterns)]
@@ -2032,7 +2033,7 @@ fn visibility(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Visibility {
20322033
Node::ImplItem(impl_item) => {
20332034
match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {
20342035
Node::Item(hir::Item {
2035-
kind: hir::ItemKind::Impl(hir::Impl { of_trait: Some(tr), .. }),
2036+
kind: hir::ItemKind::Impl(box hir::Impl { of_trait: Some(tr), .. }),
20362037
..
20372038
}) => tr.path.res.opt_def_id().map_or_else(
20382039
|| {

compiler/rustc_resolve/src/late/lifetimes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
409409
| hir::ItemKind::Union(_, ref generics)
410410
| hir::ItemKind::Trait(_, _, ref generics, ..)
411411
| hir::ItemKind::TraitAlias(ref generics, ..)
412-
| hir::ItemKind::Impl(hir::Impl { ref generics, .. }) => {
412+
| hir::ItemKind::Impl(box hir::Impl { ref generics, .. }) => {
413413
self.missing_named_lifetime_spots.push(generics.into());
414414

415415
// Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name".
@@ -1677,7 +1677,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16771677
}
16781678
match parent.kind {
16791679
hir::ItemKind::Trait(_, _, ref generics, ..)
1680-
| hir::ItemKind::Impl(hir::Impl { ref generics, .. }) => {
1680+
| hir::ItemKind::Impl(box hir::Impl { ref generics, .. }) => {
16811681
index += generics.params.len() as u32;
16821682
}
16831683
_ => {}
@@ -2102,7 +2102,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21022102
}
21032103

21042104
Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(_, body), .. }) => {
2105-
if let hir::ItemKind::Impl(hir::Impl { ref self_ty, ref items, .. }) =
2105+
if let hir::ItemKind::Impl(box hir::Impl { ref self_ty, ref items, .. }) =
21062106
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
21072107
{
21082108
impl_self = Some(self_ty);

compiler/rustc_resolve/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//! Type-relative name resolution (methods, fields, associated items) happens in `librustc_typeck`.
1010
1111
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
12+
#![feature(box_patterns)]
1213
#![feature(bool_to_option)]
1314
#![feature(crate_visibility_modifier)]
1415
#![feature(format_args_capture)]

compiler/rustc_save_analysis/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![feature(box_patterns)]
23
#![feature(nll)]
34
#![feature(or_patterns)]
45
#![recursion_limit = "256"]
@@ -318,7 +319,7 @@ impl<'tcx> SaveContext<'tcx> {
318319
attributes: lower_attributes(item.attrs.to_vec(), self),
319320
}))
320321
}
321-
hir::ItemKind::Impl(hir::Impl { ref of_trait, ref self_ty, ref items, .. }) => {
322+
hir::ItemKind::Impl(box hir::Impl { ref of_trait, ref self_ty, ref items, .. }) => {
322323
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = self_ty.kind {
323324
// Common case impl for a struct or something basic.
324325
if generated_code(path.span) {
@@ -410,7 +411,7 @@ impl<'tcx> SaveContext<'tcx> {
410411
match self.tcx.impl_of_method(def_id) {
411412
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
412413
Some(Node::Item(item)) => match item.kind {
413-
hir::ItemKind::Impl(hir::Impl { ref self_ty, .. }) => {
414+
hir::ItemKind::Impl(box hir::Impl { ref self_ty, .. }) => {
414415
let hir = self.tcx.hir();
415416

416417
let mut qualname = String::from("<");

compiler/rustc_save_analysis/src/sig.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'hir> Sig for hir::Item<'hir> {
501501

502502
Ok(sig)
503503
}
504-
hir::ItemKind::Impl(hir::Impl {
504+
hir::ItemKind::Impl(box hir::Impl {
505505
unsafety,
506506
polarity,
507507
defaultness,

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
393393
hir::Node::Item(hir::Item {
394394
kind:
395395
hir::ItemKind::Trait(_, _, generics, _, _)
396-
| hir::ItemKind::Impl(hir::Impl { generics, .. }),
396+
| hir::ItemKind::Impl(box hir::Impl { generics, .. }),
397397
..
398398
}) if projection.is_some() => {
399399
// Missing restriction on associated type of type parameter (unmet projection).
@@ -416,7 +416,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
416416
| hir::ItemKind::Enum(_, generics)
417417
| hir::ItemKind::Union(_, generics)
418418
| hir::ItemKind::Trait(_, _, generics, ..)
419-
| hir::ItemKind::Impl(hir::Impl { generics, .. })
419+
| hir::ItemKind::Impl(box hir::Impl { generics, .. })
420420
| hir::ItemKind::Fn(_, generics, _)
421421
| hir::ItemKind::TyAlias(_, generics)
422422
| hir::ItemKind::TraitAlias(generics, _)

compiler/rustc_trait_selection/src/traits/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
333333
let mut new_cause = cause.clone();
334334
// The first subst is the self ty - use the correct span for it.
335335
if i == 0 {
336-
if let Some(hir::ItemKind::Impl(hir::Impl { self_ty, .. })) =
336+
if let Some(hir::ItemKind::Impl(box hir::Impl { self_ty, .. })) =
337337
item.map(|i| &i.kind)
338338
{
339339
new_cause.make_mut().span = self_ty.span;

compiler/rustc_ty_utils/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![feature(box_patterns)]
89
#![feature(nll)]
910
#![recursion_limit = "256"]
1011

compiler/rustc_ty_utils/src/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ fn well_formed_types_in_env<'tcx>(
324324
},
325325

326326
Node::Item(item) => match item.kind {
327-
ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) => NodeKind::TraitImpl,
328-
ItemKind::Impl(hir::Impl { of_trait: None, .. }) => NodeKind::InherentImpl,
327+
ItemKind::Impl(box hir::Impl { of_trait: Some(_), .. }) => NodeKind::TraitImpl,
328+
ItemKind::Impl(box hir::Impl { of_trait: None, .. }) => NodeKind::InherentImpl,
329329
ItemKind::Fn(..) => NodeKind::Fn,
330330
_ => NodeKind::Other,
331331
},

compiler/rustc_typeck/src/coherence/builtin.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
8080
Ok(()) => {}
8181
Err(CopyImplementationError::InfrigingFields(fields)) => {
8282
let item = tcx.hir().expect_item(impl_hir_id);
83-
let span = if let ItemKind::Impl(hir::Impl { of_trait: Some(ref tr), .. }) = item.kind {
84-
tr.path.span
85-
} else {
86-
span
87-
};
83+
let span =
84+
if let ItemKind::Impl(box hir::Impl { of_trait: Some(ref tr), .. }) = item.kind {
85+
tr.path.span
86+
} else {
87+
span
88+
};
8889

8990
let mut err = struct_span_err!(
9091
tcx.sess,
@@ -453,13 +454,14 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI
453454
return err_info;
454455
} else if diff_fields.len() > 1 {
455456
let item = tcx.hir().expect_item(impl_hir_id);
456-
let span = if let ItemKind::Impl(hir::Impl { of_trait: Some(ref t), .. }) =
457-
item.kind
458-
{
459-
t.path.span
460-
} else {
461-
tcx.hir().span(impl_hir_id)
462-
};
457+
let span =
458+
if let ItemKind::Impl(box hir::Impl { of_trait: Some(ref t), .. }) =
459+
item.kind
460+
{
461+
t.path.span
462+
} else {
463+
tcx.hir().span(impl_hir_id)
464+
};
463465

464466
struct_span_err!(
465467
tcx.sess,

0 commit comments

Comments
 (0)