Auto merge of #94737 - lcnr:pass-stuff-by-value, r=davidtwco
add `#[rustc_pass_by_value]` to more types the only interesting changes here should be to `TransitiveRelation`, but I believe to be highly unlikely that we will ever use a non `Copy` type with this type.
This commit is contained in:
commit
85ce7fdfa2
27 changed files with 165 additions and 152 deletions
|
@ -44,6 +44,7 @@
|
|||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(trusted_len)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(associated_type_bounds)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
@ -46,7 +46,7 @@ impl CounterValueReference {
|
|||
|
||||
/// Returns explicitly-requested zero-based version of the counter id, used
|
||||
/// during codegen. LLVM expects zero-based indexes.
|
||||
pub fn zero_based_index(&self) -> u32 {
|
||||
pub fn zero_based_index(self) -> u32 {
|
||||
let one_based_index = self.as_u32();
|
||||
debug_assert!(one_based_index > 0);
|
||||
one_based_index - 1
|
||||
|
|
|
@ -1292,6 +1292,8 @@ pub enum InlineAsmOperand<'tcx> {
|
|||
/// Type for MIR `Assert` terminator error messages.
|
||||
pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
|
||||
|
||||
// FIXME: Change `Successors` to `impl Iterator<Item = BasicBlock>`.
|
||||
#[allow(rustc::pass_by_value)]
|
||||
pub type Successors<'a> =
|
||||
iter::Chain<option::IntoIter<&'a BasicBlock>, slice::Iter<'a, BasicBlock>>;
|
||||
pub type SuccessorsMut<'a> =
|
||||
|
@ -1832,7 +1834,8 @@ impl<V, T> ProjectionElem<V, T> {
|
|||
/// and the index is a local.
|
||||
pub type PlaceElem<'tcx> = ProjectionElem<Local, Ty<'tcx>>;
|
||||
|
||||
// At least on 64 bit systems, `PlaceElem` should not be larger than two pointers.
|
||||
// This type is fairly frequently used, so we shouldn't unintentionally increase
|
||||
// its size.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
static_assert_size!(PlaceElem<'_>, 24);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
/// not carry a `Ty` for `T`.)
|
||||
///
|
||||
/// Note that the resulting type has not been normalized.
|
||||
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> {
|
||||
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: Field) -> Ty<'tcx> {
|
||||
let answer = match self.ty.kind() {
|
||||
ty::Adt(adt_def, substs) => {
|
||||
let variant_def = match self.variant_index {
|
||||
|
@ -57,7 +57,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
/// `PlaceElem`, where we can just use the `Ty` that is already
|
||||
/// stored inline on field projection elems.
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: PlaceElem<'tcx>) -> PlaceTy<'tcx> {
|
||||
self.projection_ty_core(tcx, ty::ParamEnv::empty(), &elem, |_, _, &ty| ty)
|
||||
self.projection_ty_core(tcx, ty::ParamEnv::empty(), &elem, |_, _, ty| ty)
|
||||
}
|
||||
|
||||
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
|
||||
|
@ -70,11 +70,11 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
elem: &ProjectionElem<V, T>,
|
||||
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>,
|
||||
mut handle_field: impl FnMut(&Self, Field, T) -> Ty<'tcx>,
|
||||
) -> PlaceTy<'tcx>
|
||||
where
|
||||
V: ::std::fmt::Debug,
|
||||
T: ::std::fmt::Debug,
|
||||
T: ::std::fmt::Debug + Copy,
|
||||
{
|
||||
let answer = match *elem {
|
||||
ProjectionElem::Deref => {
|
||||
|
@ -105,7 +105,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
ProjectionElem::Downcast(_name, index) => {
|
||||
PlaceTy { ty: self.ty, variant_index: Some(index) }
|
||||
}
|
||||
ProjectionElem::Field(ref f, ref fty) => PlaceTy::from_ty(handle_field(&self, f, fty)),
|
||||
ProjectionElem::Field(f, fty) => PlaceTy::from_ty(handle_field(&self, f, fty)),
|
||||
};
|
||||
debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer);
|
||||
answer
|
||||
|
|
|
@ -225,12 +225,14 @@ macro_rules! make_mir_visitor {
|
|||
self.super_var_debug_info(var_debug_info);
|
||||
}
|
||||
|
||||
#[allow(rustc::pass_by_value)]
|
||||
fn visit_local(&mut self,
|
||||
_local: & $($mutability)? Local,
|
||||
_context: PlaceContext,
|
||||
_location: Location) {
|
||||
}
|
||||
|
||||
#[allow(rustc::pass_by_value)]
|
||||
fn visit_source_scope(&mut self,
|
||||
scope: & $($mutability)? SourceScope) {
|
||||
self.super_source_scope(scope);
|
||||
|
@ -851,6 +853,7 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::pass_by_value)]
|
||||
fn super_source_scope(&mut self,
|
||||
_scope: & $($mutability)? SourceScope) {
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue