Skip to content

Commit 9001a64

Browse files
committed
add spans to require_lang_items
1 parent 5f93bc7 commit 9001a64

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/librustc_mir/borrow_check/type_check/mod.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
503503
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
504504
let tcx = self.tcx();
505505
let trait_ref = ty::TraitRef {
506-
def_id: tcx.require_lang_item(CopyTraitLangItem, None),
506+
def_id: tcx.require_lang_item(CopyTraitLangItem, Some(self.last_span)),
507507
substs: tcx.mk_substs_trait(place_ty.ty, &[]),
508508
};
509509

@@ -1469,7 +1469,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14691469
self.check_rvalue(body, rv, location);
14701470
if !self.tcx().features().unsized_locals {
14711471
let trait_ref = ty::TraitRef {
1472-
def_id: tcx.require_lang_item(SizedTraitLangItem, None),
1472+
def_id: tcx.require_lang_item(SizedTraitLangItem, Some(self.last_span)),
14731473
substs: tcx.mk_substs_trait(place_ty, &[]),
14741474
};
14751475
self.prove_trait_ref(
@@ -2014,8 +2014,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20142014
ty::Predicate::Trait(
20152015
ty::Binder::bind(ty::TraitPredicate {
20162016
trait_ref: ty::TraitRef::new(
2017-
self.tcx()
2018-
.require_lang_item(CopyTraitLangItem, None),
2017+
self.tcx().require_lang_item(
2018+
CopyTraitLangItem,
2019+
Some(self.last_span),
2020+
),
20192021
tcx.mk_substs_trait(ty, &[]),
20202022
),
20212023
}),
@@ -2039,7 +2041,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20392041
}
20402042

20412043
let trait_ref = ty::TraitRef {
2042-
def_id: tcx.require_lang_item(SizedTraitLangItem, None),
2044+
def_id: tcx.require_lang_item(SizedTraitLangItem, Some(self.last_span)),
20432045
substs: tcx.mk_substs_trait(ty, &[]),
20442046
};
20452047

@@ -2137,7 +2139,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21372139
CastKind::Pointer(PointerCast::Unsize) => {
21382140
let &ty = ty;
21392141
let trait_ref = ty::TraitRef {
2140-
def_id: tcx.require_lang_item(CoerceUnsizedTraitLangItem, None),
2142+
def_id: tcx.require_lang_item(
2143+
CoerceUnsizedTraitLangItem,
2144+
Some(self.last_span),
2145+
),
21412146
substs: tcx.mk_substs_trait(op.ty(body, tcx), &[ty.into()]),
21422147
};
21432148

src/librustc_mir/transform/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn make_generator_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
382382
fn make_generator_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
383383
let ref_gen_ty = body.local_decls.raw[1].ty;
384384

385-
let pin_did = tcx.require_lang_item(PinTypeLangItem, None);
385+
let pin_did = tcx.require_lang_item(PinTypeLangItem, Some(body.span));
386386
let pin_adt_ref = tcx.adt_def(pin_did);
387387
let substs = tcx.intern_substs(&[ref_gen_ty.into()]);
388388
let pin_ref_gen_ty = tcx.mk_adt(pin_adt_ref, substs);

src/librustc_typeck/check/demand.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_trait_selection::traits::{self, ObligationCause};
77
use rustc_ast::util::parser::PREC_POSTFIX;
88
use rustc_errors::{Applicability, DiagnosticBuilder};
99
use rustc_hir as hir;
10+
use rustc_hir::lang_items::DerefTraitLangItem;
1011
use rustc_hir::{is_range_literal, Node};
1112
use rustc_middle::ty::adjustment::AllowTwoPhase;
1213
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut};
@@ -634,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
634635
_ if sp == expr.span && !is_macro => {
635636
// Check for `Deref` implementations by constructing a predicate to
636637
// prove: `<T as Deref>::Output == U`
637-
let deref_trait = self.tcx.lang_items().deref_trait().unwrap();
638+
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(expr.span));
638639
let item_def_id = self
639640
.tcx
640641
.associated_items(deref_trait)

0 commit comments

Comments
 (0)