rustc: remove Copy from Adjustment and Adjust.
This commit is contained in:
parent
e0cc22b4ba
commit
c6651ffd8e
@ -16,13 +16,13 @@ use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Adjustment<'tcx> {
|
||||
pub kind: Adjust<'tcx>,
|
||||
pub target: Ty<'tcx>
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub enum Adjust<'tcx> {
|
||||
/// Go from ! to any type.
|
||||
NeverToAny,
|
||||
|
@ -442,15 +442,15 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
|
||||
fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
|
||||
use rustc::ty::adjustment::*;
|
||||
|
||||
match v.tables.adjustments.get(&e.id).map(|adj| adj.kind) {
|
||||
match v.tables.adjustments.get(&e.id).map(|adj| &adj.kind) {
|
||||
None |
|
||||
Some(Adjust::NeverToAny) |
|
||||
Some(Adjust::ReifyFnPointer) |
|
||||
Some(Adjust::UnsafeFnPointer) |
|
||||
Some(Adjust::ClosureFnPointer) |
|
||||
Some(Adjust::MutToConstPointer) => {}
|
||||
Some(&Adjust::NeverToAny) |
|
||||
Some(&Adjust::ReifyFnPointer) |
|
||||
Some(&Adjust::UnsafeFnPointer) |
|
||||
Some(&Adjust::ClosureFnPointer) |
|
||||
Some(&Adjust::MutToConstPointer) => {}
|
||||
|
||||
Some(Adjust::DerefRef { autoderefs, .. }) => {
|
||||
Some(&Adjust::DerefRef { autoderefs, .. }) => {
|
||||
if (0..autoderefs as u32)
|
||||
.any(|autoderef| v.tables.is_overloaded_autoderef(e.id, autoderef)) {
|
||||
v.promotable = false;
|
||||
|
@ -800,8 +800,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
match result {
|
||||
Ok(ok) => {
|
||||
let adjustment = self.register_infer_ok_obligations(ok);
|
||||
let target = adjustment.target;
|
||||
self.apply_adjustment(new.id, adjustment);
|
||||
return Ok(adjustment.target);
|
||||
return Ok(target);
|
||||
}
|
||||
Err(e) => first_error = Some(e),
|
||||
}
|
||||
@ -812,8 +813,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// previous expressions, other than noop reborrows (ignoring lifetimes).
|
||||
for expr in exprs {
|
||||
let expr = expr.as_coercion_site();
|
||||
let noop = match self.tables.borrow().adjustments.get(&expr.id).map(|adj| adj.kind) {
|
||||
Some(Adjust::DerefRef {
|
||||
let noop = match self.tables.borrow().adjustments.get(&expr.id).map(|adj| &adj.kind) {
|
||||
Some(&Adjust::DerefRef {
|
||||
autoderefs: 1,
|
||||
autoref: Some(AutoBorrow::Ref(_, mutbl_adj)),
|
||||
unsize: false
|
||||
@ -828,7 +829,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
Some(Adjust::NeverToAny) => true,
|
||||
Some(&Adjust::NeverToAny) => true,
|
||||
Some(_) => false,
|
||||
None => true,
|
||||
};
|
||||
@ -857,7 +858,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
let adjustment = self.register_infer_ok_obligations(ok);
|
||||
for expr in exprs {
|
||||
let expr = expr.as_coercion_site();
|
||||
self.apply_adjustment(expr.id, adjustment);
|
||||
self.apply_adjustment(expr.id, adjustment.clone());
|
||||
}
|
||||
Ok(adjustment.target)
|
||||
}
|
||||
|
@ -1805,16 +1805,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
Entry::Vacant(entry) => { entry.insert(adj); },
|
||||
Entry::Occupied(mut entry) => {
|
||||
debug!(" - composing on top of {:?}", entry.get());
|
||||
let composed_kind = match (entry.get().kind, adj.kind) {
|
||||
let composed_kind = match (&entry.get().kind, &adj.kind) {
|
||||
// Applying any adjustment on top of a NeverToAny
|
||||
// is a valid NeverToAny adjustment, because it can't
|
||||
// be reached.
|
||||
(Adjust::NeverToAny, _) => Adjust::NeverToAny,
|
||||
(Adjust::DerefRef {
|
||||
(&Adjust::NeverToAny, _) => Adjust::NeverToAny,
|
||||
(&Adjust::DerefRef {
|
||||
autoderefs: 1,
|
||||
autoref: Some(AutoBorrow::Ref(..)),
|
||||
unsize: false
|
||||
}, Adjust::DerefRef { autoderefs, .. }) if autoderefs > 0 => {
|
||||
}, &Adjust::DerefRef { autoderefs, .. }) if autoderefs > 0 => {
|
||||
// A reborrow has no effect before a dereference.
|
||||
adj.kind
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user