Skip to content

Commit c6651ff

Browse files
committed
rustc: remove Copy from Adjustment and Adjust.
1 parent e0cc22b commit c6651ff

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/librustc/ty/adjustment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use syntax_pos::Span;
1616

1717
use hir;
1818

19-
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
19+
#[derive(Clone, RustcEncodable, RustcDecodable)]
2020
pub struct Adjustment<'tcx> {
2121
pub kind: Adjust<'tcx>,
2222
pub target: Ty<'tcx>
2323
}
2424

25-
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
25+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
2626
pub enum Adjust<'tcx> {
2727
/// Go from ! to any type.
2828
NeverToAny,

src/librustc_passes/consts.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,15 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
442442
fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
443443
use rustc::ty::adjustment::*;
444444

445-
match v.tables.adjustments.get(&e.id).map(|adj| adj.kind) {
445+
match v.tables.adjustments.get(&e.id).map(|adj| &adj.kind) {
446446
None |
447-
Some(Adjust::NeverToAny) |
448-
Some(Adjust::ReifyFnPointer) |
449-
Some(Adjust::UnsafeFnPointer) |
450-
Some(Adjust::ClosureFnPointer) |
451-
Some(Adjust::MutToConstPointer) => {}
447+
Some(&Adjust::NeverToAny) |
448+
Some(&Adjust::ReifyFnPointer) |
449+
Some(&Adjust::UnsafeFnPointer) |
450+
Some(&Adjust::ClosureFnPointer) |
451+
Some(&Adjust::MutToConstPointer) => {}
452452

453-
Some(Adjust::DerefRef { autoderefs, .. }) => {
453+
Some(&Adjust::DerefRef { autoderefs, .. }) => {
454454
if (0..autoderefs as u32)
455455
.any(|autoderef| v.tables.is_overloaded_autoderef(e.id, autoderef)) {
456456
v.promotable = false;

src/librustc_typeck/check/coercion.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
800800
match result {
801801
Ok(ok) => {
802802
let adjustment = self.register_infer_ok_obligations(ok);
803+
let target = adjustment.target;
803804
self.apply_adjustment(new.id, adjustment);
804-
return Ok(adjustment.target);
805+
return Ok(target);
805806
}
806807
Err(e) => first_error = Some(e),
807808
}
@@ -812,8 +813,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
812813
// previous expressions, other than noop reborrows (ignoring lifetimes).
813814
for expr in exprs {
814815
let expr = expr.as_coercion_site();
815-
let noop = match self.tables.borrow().adjustments.get(&expr.id).map(|adj| adj.kind) {
816-
Some(Adjust::DerefRef {
816+
let noop = match self.tables.borrow().adjustments.get(&expr.id).map(|adj| &adj.kind) {
817+
Some(&Adjust::DerefRef {
817818
autoderefs: 1,
818819
autoref: Some(AutoBorrow::Ref(_, mutbl_adj)),
819820
unsize: false
@@ -828,7 +829,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
828829
_ => false,
829830
}
830831
}
831-
Some(Adjust::NeverToAny) => true,
832+
Some(&Adjust::NeverToAny) => true,
832833
Some(_) => false,
833834
None => true,
834835
};
@@ -857,7 +858,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
857858
let adjustment = self.register_infer_ok_obligations(ok);
858859
for expr in exprs {
859860
let expr = expr.as_coercion_site();
860-
self.apply_adjustment(expr.id, adjustment);
861+
self.apply_adjustment(expr.id, adjustment.clone());
861862
}
862863
Ok(adjustment.target)
863864
}

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,16 +1805,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
18051805
Entry::Vacant(entry) => { entry.insert(adj); },
18061806
Entry::Occupied(mut entry) => {
18071807
debug!(" - composing on top of {:?}", entry.get());
1808-
let composed_kind = match (entry.get().kind, adj.kind) {
1808+
let composed_kind = match (&entry.get().kind, &adj.kind) {
18091809
// Applying any adjustment on top of a NeverToAny
18101810
// is a valid NeverToAny adjustment, because it can't
18111811
// be reached.
1812-
(Adjust::NeverToAny, _) => Adjust::NeverToAny,
1813-
(Adjust::DerefRef {
1812+
(&Adjust::NeverToAny, _) => Adjust::NeverToAny,
1813+
(&Adjust::DerefRef {
18141814
autoderefs: 1,
18151815
autoref: Some(AutoBorrow::Ref(..)),
18161816
unsize: false
1817-
}, Adjust::DerefRef { autoderefs, .. }) if autoderefs > 0 => {
1817+
}, &Adjust::DerefRef { autoderefs, .. }) if autoderefs > 0 => {
18181818
// A reborrow has no effect before a dereference.
18191819
adj.kind
18201820
}

0 commit comments

Comments
 (0)