Remove unused tcx and mir params
This commit is contained in:
parent
4dbc7f96d6
commit
acaf284e55
1 changed files with 18 additions and 22 deletions
|
@ -136,10 +136,10 @@ fn check_rvalue(
|
||||||
) -> McfResult {
|
) -> McfResult {
|
||||||
match rvalue {
|
match rvalue {
|
||||||
Rvalue::Repeat(operand, _) | Rvalue::Use(operand) => {
|
Rvalue::Repeat(operand, _) | Rvalue::Use(operand) => {
|
||||||
check_operand(tcx, mir, operand, span)
|
check_operand(operand, span)
|
||||||
}
|
}
|
||||||
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) => {
|
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) => {
|
||||||
check_place(tcx, mir, place, span)
|
check_place(place, span)
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Misc, operand, cast_ty) => {
|
Rvalue::Cast(CastKind::Misc, operand, cast_ty) => {
|
||||||
use rustc::ty::cast::CastTy;
|
use rustc::ty::cast::CastTy;
|
||||||
|
@ -153,11 +153,11 @@ fn check_rvalue(
|
||||||
(CastTy::RPtr(_), CastTy::Float) => bug!(),
|
(CastTy::RPtr(_), CastTy::Float) => bug!(),
|
||||||
(CastTy::RPtr(_), CastTy::Int(_)) => bug!(),
|
(CastTy::RPtr(_), CastTy::Int(_)) => bug!(),
|
||||||
(CastTy::Ptr(_), CastTy::RPtr(_)) => bug!(),
|
(CastTy::Ptr(_), CastTy::RPtr(_)) => bug!(),
|
||||||
_ => check_operand(tcx, mir, operand, span),
|
_ => check_operand(operand, span),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, _) => {
|
Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, _) => {
|
||||||
check_operand(tcx, mir, operand, span)
|
check_operand(operand, span)
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), _, _) |
|
Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), _, _) |
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), _, _) |
|
Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), _, _) |
|
||||||
|
@ -171,8 +171,8 @@ fn check_rvalue(
|
||||||
)),
|
)),
|
||||||
// binops are fine on integers
|
// binops are fine on integers
|
||||||
Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
|
Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
|
||||||
check_operand(tcx, mir, lhs, span)?;
|
check_operand(lhs, span)?;
|
||||||
check_operand(tcx, mir, rhs, span)?;
|
check_operand(rhs, span)?;
|
||||||
let ty = lhs.ty(mir, tcx);
|
let ty = lhs.ty(mir, tcx);
|
||||||
if ty.is_integral() || ty.is_bool() || ty.is_char() {
|
if ty.is_integral() || ty.is_bool() || ty.is_char() {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -191,7 +191,7 @@ fn check_rvalue(
|
||||||
Rvalue::UnaryOp(_, operand) => {
|
Rvalue::UnaryOp(_, operand) => {
|
||||||
let ty = operand.ty(mir, tcx);
|
let ty = operand.ty(mir, tcx);
|
||||||
if ty.is_integral() || ty.is_bool() {
|
if ty.is_integral() || ty.is_bool() {
|
||||||
check_operand(tcx, mir, operand, span)
|
check_operand(operand, span)
|
||||||
} else {
|
} else {
|
||||||
Err((
|
Err((
|
||||||
span,
|
span,
|
||||||
|
@ -201,7 +201,7 @@ fn check_rvalue(
|
||||||
}
|
}
|
||||||
Rvalue::Aggregate(_, operands) => {
|
Rvalue::Aggregate(_, operands) => {
|
||||||
for operand in operands {
|
for operand in operands {
|
||||||
check_operand(tcx, mir, operand, span)?;
|
check_operand(operand, span)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -216,11 +216,11 @@ fn check_statement(
|
||||||
let span = statement.source_info.span;
|
let span = statement.source_info.span;
|
||||||
match &statement.kind {
|
match &statement.kind {
|
||||||
StatementKind::Assign(place, rval) => {
|
StatementKind::Assign(place, rval) => {
|
||||||
check_place(tcx, mir, place, span)?;
|
check_place(place, span)?;
|
||||||
check_rvalue(tcx, mir, rval, span)
|
check_rvalue(tcx, mir, rval, span)
|
||||||
}
|
}
|
||||||
|
|
||||||
StatementKind::FakeRead(_, place) => check_place(tcx, mir, place, span),
|
StatementKind::FakeRead(_, place) => check_place(place, span),
|
||||||
|
|
||||||
// just an assignment
|
// just an assignment
|
||||||
StatementKind::SetDiscriminant { .. } => Ok(()),
|
StatementKind::SetDiscriminant { .. } => Ok(()),
|
||||||
|
@ -239,22 +239,18 @@ fn check_statement(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_operand(
|
fn check_operand(
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|
||||||
mir: &'a Mir<'tcx>,
|
|
||||||
operand: &Operand<'tcx>,
|
operand: &Operand<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> McfResult {
|
) -> McfResult {
|
||||||
match operand {
|
match operand {
|
||||||
Operand::Move(place) | Operand::Copy(place) => {
|
Operand::Move(place) | Operand::Copy(place) => {
|
||||||
check_place(tcx, mir, place, span)
|
check_place(place, span)
|
||||||
}
|
}
|
||||||
Operand::Constant(_) => Ok(()),
|
Operand::Constant(_) => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_place(
|
fn check_place(
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|
||||||
mir: &'a Mir<'tcx>,
|
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> McfResult {
|
) -> McfResult {
|
||||||
|
@ -268,7 +264,7 @@ fn check_place(
|
||||||
match proj.elem {
|
match proj.elem {
|
||||||
| ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. }
|
| ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. }
|
||||||
| ProjectionElem::Deref | ProjectionElem::Field(..) | ProjectionElem::Index(_) => {
|
| ProjectionElem::Deref | ProjectionElem::Field(..) | ProjectionElem::Index(_) => {
|
||||||
check_place(tcx, mir, &proj.base, span)
|
check_place(&proj.base, span)
|
||||||
}
|
}
|
||||||
| ProjectionElem::Downcast(..) => {
|
| ProjectionElem::Downcast(..) => {
|
||||||
Err((span, "`match` or `if let` in `const fn` is unstable".into()))
|
Err((span, "`match` or `if let` in `const fn` is unstable".into()))
|
||||||
|
@ -290,11 +286,11 @@ fn check_terminator(
|
||||||
| TerminatorKind::Resume => Ok(()),
|
| TerminatorKind::Resume => Ok(()),
|
||||||
|
|
||||||
TerminatorKind::Drop { location, .. } => {
|
TerminatorKind::Drop { location, .. } => {
|
||||||
check_place(tcx, mir, location, span)
|
check_place(location, span)
|
||||||
}
|
}
|
||||||
TerminatorKind::DropAndReplace { location, value, .. } => {
|
TerminatorKind::DropAndReplace { location, value, .. } => {
|
||||||
check_place(tcx, mir, location, span)?;
|
check_place(location, span)?;
|
||||||
check_operand(tcx, mir, value, span)
|
check_operand(value, span)
|
||||||
},
|
},
|
||||||
|
|
||||||
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
|
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
|
||||||
|
@ -346,10 +342,10 @@ fn check_terminator(
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
||||||
check_operand(tcx, mir, func, span)?;
|
check_operand(func, span)?;
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
check_operand(tcx, mir, arg, span)?;
|
check_operand(arg, span)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
@ -363,7 +359,7 @@ fn check_terminator(
|
||||||
msg: _,
|
msg: _,
|
||||||
target: _,
|
target: _,
|
||||||
cleanup: _,
|
cleanup: _,
|
||||||
} => check_operand(tcx, mir, cond, span),
|
} => check_operand(cond, span),
|
||||||
|
|
||||||
TerminatorKind::FalseUnwind { .. } => {
|
TerminatorKind::FalseUnwind { .. } => {
|
||||||
Err((span, "loops are not allowed in const fn".into()))
|
Err((span, "loops are not allowed in const fn".into()))
|
||||||
|
|
Loading…
Reference in a new issue