Skip to content

Commit ee639de

Browse files
committed
Only guess span if absolutely necessary
1 parent d63b278 commit ee639de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_typeck/src/check/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,6 @@ pub(super) fn check_impl_items_against_trait<'tcx>(
894894
impl_trait_ref: ty::TraitRef<'tcx>,
895895
impl_item_refs: &[hir::ImplItemRef<'_>],
896896
) {
897-
let impl_span = tcx.sess.source_map().guess_head_span(full_impl_span);
898-
899897
// If the trait reference itself is erroneous (so the compilation is going
900898
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
901899
// isn't populated for such impls.
@@ -1011,6 +1009,8 @@ pub(super) fn check_impl_items_against_trait<'tcx>(
10111009
}
10121010

10131011
if let Ok(ancestors) = trait_def.ancestors(tcx, impl_id.to_def_id()) {
1012+
let impl_span = tcx.sess.source_map().guess_head_span(full_impl_span);
1013+
10141014
// Check for missing items from trait
10151015
let mut missing_items = Vec::new();
10161016
for trait_item in tcx.associated_items(impl_trait_ref.def_id).in_definition_order() {

0 commit comments

Comments
 (0)