Skip to content

Commit

Permalink
add spans to require_lang_items
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed May 13, 2020
1 parent 5f93bc7 commit 9001a64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/librustc_mir/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
let tcx = self.tcx();
let trait_ref = ty::TraitRef {
def_id: tcx.require_lang_item(CopyTraitLangItem, None),
def_id: tcx.require_lang_item(CopyTraitLangItem, Some(self.last_span)),
substs: tcx.mk_substs_trait(place_ty.ty, &[]),
};

Expand Down Expand Up @@ -1469,7 +1469,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.check_rvalue(body, rv, location);
if !self.tcx().features().unsized_locals {
let trait_ref = ty::TraitRef {
def_id: tcx.require_lang_item(SizedTraitLangItem, None),
def_id: tcx.require_lang_item(SizedTraitLangItem, Some(self.last_span)),
substs: tcx.mk_substs_trait(place_ty, &[]),
};
self.prove_trait_ref(
Expand Down Expand Up @@ -2014,8 +2014,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
ty::Predicate::Trait(
ty::Binder::bind(ty::TraitPredicate {
trait_ref: ty::TraitRef::new(
self.tcx()
.require_lang_item(CopyTraitLangItem, None),
self.tcx().require_lang_item(
CopyTraitLangItem,
Some(self.last_span),
),
tcx.mk_substs_trait(ty, &[]),
),
}),
Expand All @@ -2039,7 +2041,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}

let trait_ref = ty::TraitRef {
def_id: tcx.require_lang_item(SizedTraitLangItem, None),
def_id: tcx.require_lang_item(SizedTraitLangItem, Some(self.last_span)),
substs: tcx.mk_substs_trait(ty, &[]),
};

Expand Down Expand Up @@ -2137,7 +2139,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
CastKind::Pointer(PointerCast::Unsize) => {
let &ty = ty;
let trait_ref = ty::TraitRef {
def_id: tcx.require_lang_item(CoerceUnsizedTraitLangItem, None),
def_id: tcx.require_lang_item(
CoerceUnsizedTraitLangItem,
Some(self.last_span),
),
substs: tcx.mk_substs_trait(op.ty(body, tcx), &[ty.into()]),
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fn make_generator_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
fn make_generator_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let ref_gen_ty = body.local_decls.raw[1].ty;

let pin_did = tcx.require_lang_item(PinTypeLangItem, None);
let pin_did = tcx.require_lang_item(PinTypeLangItem, Some(body.span));
let pin_adt_ref = tcx.adt_def(pin_did);
let substs = tcx.intern_substs(&[ref_gen_ty.into()]);
let pin_ref_gen_ty = tcx.mk_adt(pin_adt_ref, substs);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_trait_selection::traits::{self, ObligationCause};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::lang_items::DerefTraitLangItem;
use rustc_hir::{is_range_literal, Node};
use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut};
Expand Down Expand Up @@ -634,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ if sp == expr.span && !is_macro => {
// Check for `Deref` implementations by constructing a predicate to
// prove: `<T as Deref>::Output == U`
let deref_trait = self.tcx.lang_items().deref_trait().unwrap();
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(expr.span));
let item_def_id = self
.tcx
.associated_items(deref_trait)
Expand Down

0 comments on commit 9001a64

Please sign in to comment.