Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors

Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions

Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`

This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3

r? `@compiler-errors`
This commit is contained in:
Guillaume Gomez 2022-10-29 14:18:03 +02:00 committed by GitHub
commit 2414a4c31a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 191 additions and 172 deletions

View file

@ -4,7 +4,7 @@ use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::traits::CodegenObligationError;
use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitable};
use rustc_span::{sym, DUMMY_SP};
use rustc_span::sym;
use rustc_trait_selection::traits;
use traits::{translate_substs, Reveal};
@ -236,7 +236,7 @@ fn resolve_associated_item<'tcx>(
if name == sym::clone {
let self_ty = trait_ref.self_ty();
let is_copy = self_ty.is_copy_modulo_regions(tcx.at(DUMMY_SP), param_env);
let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env);
match self_ty.kind() {
_ if is_copy => (),
ty::Generator(..)

View file

@ -399,7 +399,7 @@ fn layout_of_uncached<'tcx>(
}
let pointee = tcx.normalize_erasing_regions(param_env, pointee);
if pointee.is_sized(tcx.at(DUMMY_SP), param_env) {
if pointee.is_sized(tcx, param_env) {
return Ok(tcx.intern_layout(LayoutS::scalar(cx, data_ptr)));
}
@ -755,8 +755,7 @@ fn layout_of_uncached<'tcx>(
} else {
let param_env = tcx.param_env(def.did());
let last_field = def.variant(v).fields.last().unwrap();
let always_sized =
tcx.type_of(last_field.did).is_sized(tcx.at(DUMMY_SP), param_env);
let always_sized = tcx.type_of(last_field.did).is_sized(tcx, param_env);
if !always_sized { StructKind::MaybeUnsized } else { StructKind::AlwaysSized }
};

View file

@ -109,7 +109,7 @@ where
for component in components {
match *component.kind() {
_ if component.is_copy_modulo_regions(tcx.at(DUMMY_SP), self.param_env) => (),
_ if component.is_copy_modulo_regions(tcx, self.param_env) => (),
ty::Closure(_, substs) => {
queue_type(self, substs.as_closure().tupled_upvars_ty());