Enable rustc_pass_by_value for Span
This commit is contained in:
parent
22c3a71de1
commit
76b13c9eea
8 changed files with 28 additions and 22 deletions
|
@ -162,6 +162,9 @@ macro_rules! make_mir_visitor {
|
||||||
self.super_constant(constant, location);
|
self.super_constant(constant, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The macro results in a false positive of sorts, where &mut Span
|
||||||
|
// is fine, but &Span is not; just allow the lint.
|
||||||
|
#[allow(rustc::pass_by_value)]
|
||||||
fn visit_span(&mut self,
|
fn visit_span(&mut self,
|
||||||
span: & $($mutability)? Span) {
|
span: & $($mutability)? Span) {
|
||||||
self.super_span(span);
|
self.super_span(span);
|
||||||
|
@ -869,6 +872,9 @@ macro_rules! make_mir_visitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The macro results in a false positive of sorts, where &mut Span
|
||||||
|
// is fine, but &Span is not; just allow the lint.
|
||||||
|
#[allow(rustc::pass_by_value)]
|
||||||
fn super_span(&mut self, _span: & $($mutability)? Span) {
|
fn super_span(&mut self, _span: & $($mutability)? Span) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -671,7 +671,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
// a Coverage code region can be generated, `continue` needs no `Assign`; but
|
// a Coverage code region can be generated, `continue` needs no `Assign`; but
|
||||||
// without one, the `InstrumentCoverage` MIR pass cannot generate a code region for
|
// without one, the `InstrumentCoverage` MIR pass cannot generate a code region for
|
||||||
// `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR.
|
// `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR.
|
||||||
self.add_dummy_assignment(&span, block, source_info);
|
self.add_dummy_assignment(span, block, source_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,8 +730,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
|
|
||||||
// Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
|
// Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
|
||||||
// statement.
|
// statement.
|
||||||
fn add_dummy_assignment(&mut self, span: &Span, block: BasicBlock, source_info: SourceInfo) {
|
fn add_dummy_assignment(&mut self, span: Span, block: BasicBlock, source_info: SourceInfo) {
|
||||||
let local_decl = LocalDecl::new(self.tcx.mk_unit(), *span).internal();
|
let local_decl = LocalDecl::new(self.tcx.mk_unit(), span).internal();
|
||||||
let temp_place = Place::from(self.local_decls.push(local_decl));
|
let temp_place = Place::from(self.local_decls.push(local_decl));
|
||||||
self.cfg.push_assign_unit(block, source_info, temp_place, self.tcx);
|
self.cfg.push_assign_unit(block, source_info, temp_place, self.tcx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ impl CoverageStatement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn span(&self) -> &Span {
|
pub fn span(&self) -> Span {
|
||||||
match self {
|
match self {
|
||||||
Self::Statement(_, span, _) | Self::Terminator(_, span) => span,
|
Self::Statement(_, span, _) | Self::Terminator(_, span) => *span,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#![feature(negative_impls)]
|
#![feature(negative_impls)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -61,8 +61,7 @@ use rustc_data_structures::fx::FxIndexSet;
|
||||||
/// using the callback `SPAN_TRACK` to access the query engine.
|
/// using the callback `SPAN_TRACK` to access the query engine.
|
||||||
///
|
///
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
||||||
// FIXME: Enable this in the bootstrap bump, but separate commit.
|
#[rustc_pass_by_value]
|
||||||
// #[rustc_pass_by_value]
|
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
base_or_index: u32,
|
base_or_index: u32,
|
||||||
len_or_tag: u16,
|
len_or_tag: u16,
|
||||||
|
|
|
@ -271,7 +271,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ExprKind::Box(subexpr) => self.check_expr_box(subexpr, expected),
|
ExprKind::Box(subexpr) => self.check_expr_box(subexpr, expected),
|
||||||
ExprKind::Lit(ref lit) => self.check_lit(&lit, expected),
|
ExprKind::Lit(ref lit) => self.check_lit(&lit, expected),
|
||||||
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs),
|
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs),
|
||||||
ExprKind::Assign(lhs, rhs, ref span) => {
|
ExprKind::Assign(lhs, rhs, span) => {
|
||||||
self.check_expr_assign(expr, expected, lhs, rhs, span)
|
self.check_expr_assign(expr, expected, lhs, rhs, span)
|
||||||
}
|
}
|
||||||
ExprKind::AssignOp(op, lhs, rhs) => self.check_binop_assign(expr, op, lhs, rhs),
|
ExprKind::AssignOp(op, lhs, rhs) => self.check_binop_assign(expr, op, lhs, rhs),
|
||||||
|
@ -982,7 +982,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
expected: Expectation<'tcx>,
|
expected: Expectation<'tcx>,
|
||||||
lhs: &'tcx hir::Expr<'tcx>,
|
lhs: &'tcx hir::Expr<'tcx>,
|
||||||
rhs: &'tcx hir::Expr<'tcx>,
|
rhs: &'tcx hir::Expr<'tcx>,
|
||||||
span: &Span,
|
span: Span,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let expected_ty = expected.coercion_target_type(self, expr.span);
|
let expected_ty = expected.coercion_target_type(self, expr.span);
|
||||||
if expected_ty == self.tcx.types.bool {
|
if expected_ty == self.tcx.types.bool {
|
||||||
|
@ -1014,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
if eq {
|
if eq {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
*span,
|
span,
|
||||||
"you might have meant to compare for equality",
|
"you might have meant to compare for equality",
|
||||||
"==".to_string(),
|
"==".to_string(),
|
||||||
applicability,
|
applicability,
|
||||||
|
@ -1031,7 +1031,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
return self.tcx.ty_error();
|
return self.tcx.ty_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_lhs_assignable(lhs, "E0070", *span);
|
self.check_lhs_assignable(lhs, "E0070", span);
|
||||||
|
|
||||||
let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace);
|
let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace);
|
||||||
let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty, Some(lhs));
|
let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty, Some(lhs));
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let ty =
|
let ty =
|
||||||
if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) {
|
if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) {
|
||||||
self.enforce_builtin_binop_types(&lhs.span, lhs_ty, &rhs.span, rhs_ty, op);
|
self.enforce_builtin_binop_types(lhs.span, lhs_ty, rhs.span, rhs_ty, op);
|
||||||
self.tcx.mk_unit()
|
self.tcx.mk_unit()
|
||||||
} else {
|
} else {
|
||||||
return_ty
|
return_ty
|
||||||
|
@ -98,9 +98,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
&& is_builtin_binop(lhs_ty, rhs_ty, op)
|
&& is_builtin_binop(lhs_ty, rhs_ty, op)
|
||||||
{
|
{
|
||||||
let builtin_return_ty = self.enforce_builtin_binop_types(
|
let builtin_return_ty = self.enforce_builtin_binop_types(
|
||||||
&lhs_expr.span,
|
lhs_expr.span,
|
||||||
lhs_ty,
|
lhs_ty,
|
||||||
&rhs_expr.span,
|
rhs_expr.span,
|
||||||
rhs_ty,
|
rhs_ty,
|
||||||
op,
|
op,
|
||||||
);
|
);
|
||||||
|
@ -114,9 +114,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
fn enforce_builtin_binop_types(
|
fn enforce_builtin_binop_types(
|
||||||
&self,
|
&self,
|
||||||
lhs_span: &Span,
|
lhs_span: Span,
|
||||||
lhs_ty: Ty<'tcx>,
|
lhs_ty: Ty<'tcx>,
|
||||||
rhs_span: &Span,
|
rhs_span: Span,
|
||||||
rhs_ty: Ty<'tcx>,
|
rhs_ty: Ty<'tcx>,
|
||||||
op: hir::BinOp,
|
op: hir::BinOp,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
|
@ -129,8 +129,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
match BinOpCategory::from(op) {
|
match BinOpCategory::from(op) {
|
||||||
BinOpCategory::Shortcircuit => {
|
BinOpCategory::Shortcircuit => {
|
||||||
self.demand_suptype(*lhs_span, tcx.types.bool, lhs_ty);
|
self.demand_suptype(lhs_span, tcx.types.bool, lhs_ty);
|
||||||
self.demand_suptype(*rhs_span, tcx.types.bool, rhs_ty);
|
self.demand_suptype(rhs_span, tcx.types.bool, rhs_ty);
|
||||||
tcx.types.bool
|
tcx.types.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,13 +141,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
BinOpCategory::Math | BinOpCategory::Bitwise => {
|
BinOpCategory::Math | BinOpCategory::Bitwise => {
|
||||||
// both LHS and RHS and result will have the same type
|
// both LHS and RHS and result will have the same type
|
||||||
self.demand_suptype(*rhs_span, lhs_ty, rhs_ty);
|
self.demand_suptype(rhs_span, lhs_ty, rhs_ty);
|
||||||
lhs_ty
|
lhs_ty
|
||||||
}
|
}
|
||||||
|
|
||||||
BinOpCategory::Comparison => {
|
BinOpCategory::Comparison => {
|
||||||
// both LHS and RHS and result will have the same type
|
// both LHS and RHS and result will have the same type
|
||||||
self.demand_suptype(*rhs_span, lhs_ty, rhs_ty);
|
self.demand_suptype(rhs_span, lhs_ty, rhs_ty);
|
||||||
tcx.types.bool
|
tcx.types.bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1533,7 +1533,7 @@ fn rewrite_struct_lit<'a>(
|
||||||
enum StructLitField<'a> {
|
enum StructLitField<'a> {
|
||||||
Regular(&'a ast::ExprField),
|
Regular(&'a ast::ExprField),
|
||||||
Base(&'a ast::Expr),
|
Base(&'a ast::Expr),
|
||||||
Rest(&'a Span),
|
Rest(Span),
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 = " {".len()
|
// 2 = " {".len()
|
||||||
|
@ -1568,7 +1568,7 @@ fn rewrite_struct_lit<'a>(
|
||||||
let field_iter = fields.iter().map(StructLitField::Regular).chain(
|
let field_iter = fields.iter().map(StructLitField::Regular).chain(
|
||||||
match struct_rest {
|
match struct_rest {
|
||||||
ast::StructRest::Base(expr) => Some(StructLitField::Base(&**expr)),
|
ast::StructRest::Base(expr) => Some(StructLitField::Base(&**expr)),
|
||||||
ast::StructRest::Rest(span) => Some(StructLitField::Rest(span)),
|
ast::StructRest::Rest(span) => Some(StructLitField::Rest(*span)),
|
||||||
ast::StructRest::None => None,
|
ast::StructRest::None => None,
|
||||||
}
|
}
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue