Skip to content

Commit bff8a2c

Browse files
authored
Rollup merge of rust-lang#98878 - lcnr:more-rustc_pass_by_value, r=oli-obk
add more `rustc_pass_by_value` r? ``@oli-obk`` cc rust-lang#98766
2 parents 250f636 + 658b7f3 commit bff8a2c

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

compiler/rustc_borrowck/src/constraint_generation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
149149
fn visit_ascribe_user_ty(
150150
&mut self,
151151
_place: &Place<'tcx>,
152-
_variance: &ty::Variance,
152+
_variance: ty::Variance,
153153
_user_ty: &UserTypeProjection,
154154
_location: Location,
155155
) {

compiler/rustc_middle/src/mir/syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ pub enum StatementKind<'tcx> {
311311

312312
/// Describes what kind of retag is to be performed.
313313
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, Hash, HashStable)]
314+
#[rustc_pass_by_value]
314315
pub enum RetagKind {
315316
/// The initial retag when entering a function.
316317
FnEntry,

compiler/rustc_middle/src/mir/visit.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ macro_rules! make_mir_visitor {
147147
fn visit_ascribe_user_ty(
148148
&mut self,
149149
place: & $($mutability)? Place<'tcx>,
150-
variance: & $($mutability)? ty::Variance,
150+
variance: $(& $mutability)? ty::Variance,
151151
user_ty: & $($mutability)? UserTypeProjection,
152152
location: Location,
153153
) {
@@ -164,7 +164,7 @@ macro_rules! make_mir_visitor {
164164

165165
fn visit_retag(
166166
&mut self,
167-
kind: & $($mutability)? RetagKind,
167+
kind: $(& $mutability)? RetagKind,
168168
place: & $($mutability)? Place<'tcx>,
169169
location: Location,
170170
) {
@@ -425,7 +425,7 @@ macro_rules! make_mir_visitor {
425425
self.visit_source_info(source_info);
426426
match kind {
427427
StatementKind::Assign(
428-
box(ref $($mutability)? place, ref $($mutability)? rvalue)
428+
box (place, rvalue)
429429
) => {
430430
self.visit_assign(place, rvalue, location);
431431
}
@@ -465,13 +465,13 @@ macro_rules! make_mir_visitor {
465465
);
466466
}
467467
StatementKind::Retag(kind, place) => {
468-
self.visit_retag(kind, place, location);
468+
self.visit_retag($(& $mutability)? *kind, place, location);
469469
}
470470
StatementKind::AscribeUserType(
471-
box(ref $($mutability)? place, ref $($mutability)? user_ty),
471+
box (place, user_ty),
472472
variance
473473
) => {
474-
self.visit_ascribe_user_ty(place, variance, user_ty, location);
474+
self.visit_ascribe_user_ty(place, $(& $mutability)? *variance, user_ty, location);
475475
}
476476
StatementKind::Coverage(coverage) => {
477477
self.visit_coverage(
@@ -480,9 +480,9 @@ macro_rules! make_mir_visitor {
480480
)
481481
}
482482
StatementKind::CopyNonOverlapping(box crate::mir::CopyNonOverlapping{
483-
ref $($mutability)? src,
484-
ref $($mutability)? dst,
485-
ref $($mutability)? count,
483+
src,
484+
dst,
485+
count,
486486
}) => {
487487
self.visit_operand(src, location);
488488
self.visit_operand(dst, location);
@@ -517,8 +517,7 @@ macro_rules! make_mir_visitor {
517517
TerminatorKind::GeneratorDrop |
518518
TerminatorKind::Unreachable |
519519
TerminatorKind::FalseEdge { .. } |
520-
TerminatorKind::FalseUnwind { .. } => {
521-
}
520+
TerminatorKind::FalseUnwind { .. } => {}
522521

523522
TerminatorKind::Return => {
524523
// `return` logically moves from the return place `_0`. Note that the place
@@ -830,7 +829,7 @@ macro_rules! make_mir_visitor {
830829

831830
fn super_ascribe_user_ty(&mut self,
832831
place: & $($mutability)? Place<'tcx>,
833-
_variance: & $($mutability)? ty::Variance,
832+
_variance: $(& $mutability)? ty::Variance,
834833
user_ty: & $($mutability)? UserTypeProjection,
835834
location: Location) {
836835
self.visit_place(
@@ -847,7 +846,7 @@ macro_rules! make_mir_visitor {
847846
}
848847

849848
fn super_retag(&mut self,
850-
_kind: & $($mutability)? RetagKind,
849+
_kind: $(& $mutability)? RetagKind,
851850
place: & $($mutability)? Place<'tcx>,
852851
location: Location) {
853852
self.visit_place(

compiler/rustc_type_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ impl UnifyKey for FloatVid {
599599
}
600600

601601
#[derive(Copy, Clone, PartialEq, Decodable, Encodable, Hash)]
602+
#[rustc_pass_by_value]
602603
pub enum Variance {
603604
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
604605
Invariant, // T<A> <: T<B> iff B == A -- e.g., type of mutable cell

0 commit comments

Comments
 (0)