diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-17 11:21:39 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-21 20:31:59 +0000 |
| commit | 6f77c97b386f05083f039f0130146addf99eefd9 (patch) | |
| tree | 4bebb22479b94e1134ee458f5f45efaea839ca26 /compiler/rustc_borrowck | |
| parent | d9a02b0fb728ac994883845b1c53630c2dec4657 (diff) | |
| download | rust-6f77c97b386f05083f039f0130146addf99eefd9.tar.gz rust-6f77c97b386f05083f039f0130146addf99eefd9.zip | |
Assert that various types have the right amount of generic args and fix the sites that used the wrong amount
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 9b6c7d27c79..e63c0699d40 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -547,10 +547,11 @@ 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(LangItem::Copy, Some(self.last_span)), - substs: tcx.mk_substs_trait(place_ty.ty, &[]), - }; + let trait_ref = tcx.mk_trait_ref( + tcx.require_lang_item(LangItem::Copy, Some(self.last_span)), + place_ty.ty, + &[], + ); // To have a `Copy` operand, the type `T` of the // value must be `Copy`. Note that we prove that `T: Copy`, @@ -1273,10 +1274,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.check_rvalue(body, rv, location); if !self.unsized_feature_enabled() { - let trait_ref = ty::TraitRef { - def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), - substs: tcx.mk_substs_trait(place_ty, &[]), - }; + let trait_ref = tcx.mk_trait_ref( + tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), + place_ty, + &[], + ); self.prove_trait_ref( trait_ref, location.to_locations(), @@ -1865,9 +1867,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // Make sure that repeated elements implement `Copy`. let span = body.source_info(location).span; let ty = place.ty(body, tcx).ty; - let trait_ref = ty::TraitRef::new( + let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::Copy, Some(span)), - tcx.mk_substs_trait(ty, &[]), + ty, + &[], ); self.prove_trait_ref( @@ -1881,10 +1884,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } &Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => { - let trait_ref = ty::TraitRef { - def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), - substs: tcx.mk_substs_trait(ty, &[]), - }; + let trait_ref = tcx.mk_trait_ref( + tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), + ty, + &[], + ); self.prove_trait_ref( trait_ref, @@ -1896,10 +1900,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { Rvalue::ShallowInitBox(operand, ty) => { self.check_operand(operand, location); - let trait_ref = ty::TraitRef { - def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), - substs: tcx.mk_substs_trait(*ty, &[]), - }; + let trait_ref = tcx.mk_trait_ref( + tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), + *ty, + &[], + ); self.prove_trait_ref( trait_ref, @@ -1996,11 +2001,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { CastKind::Pointer(PointerCast::Unsize) => { let &ty = ty; - let trait_ref = ty::TraitRef { - def_id: tcx - .require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)), - substs: tcx.mk_substs_trait(op.ty(body, tcx), &[ty.into()]), - }; + let trait_ref = tcx.mk_trait_ref( + tcx.require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)), + op.ty(body, tcx), + &[ty.into()], + ); self.prove_trait_ref( trait_ref, |
