1
Fork 0

rustc: rename mir::LocalDecl's syntactic_source_info to source_info.

This commit is contained in:
Eduard-Mihai Burtescu 2018-05-29 21:31:33 +03:00
parent 6c53972478
commit 06d88cda08
19 changed files with 47 additions and 47 deletions

View file

@ -25,7 +25,7 @@ impl_stable_hash_for!(struct mir::LocalDecl<'tcx> {
mutability, mutability,
ty, ty,
name, name,
syntactic_source_info, source_info,
visibility_scope, visibility_scope,
internal, internal,
is_user_variable is_user_variable

View file

@ -556,7 +556,7 @@ pub struct LocalDecl<'tcx> {
/// `drop(x)`, we want it to refer to `x: u32`. /// `drop(x)`, we want it to refer to `x: u32`.
/// ///
/// To allow both uses to work, we need to have more than a single scope /// To allow both uses to work, we need to have more than a single scope
/// for a local. We have the `syntactic_source_info.scope` represent the /// for a local. We have the `source_info.scope` represent the
/// "syntactic" lint scope (with a variable being under its let /// "syntactic" lint scope (with a variable being under its let
/// block) while the `visibility_scope` represents the "local variable" /// block) while the `visibility_scope` represents the "local variable"
/// scope (where the "rest" of a block is under all prior let-statements). /// scope (where the "rest" of a block is under all prior let-statements).
@ -570,10 +570,10 @@ pub struct LocalDecl<'tcx> {
/// │ │{ #[allow(unused_mut] } // this is actually split into 2 scopes /// │ │{ #[allow(unused_mut] } // this is actually split into 2 scopes
/// │ │ // in practice because I'm lazy. /// │ │ // in practice because I'm lazy.
/// │ │ /// │ │
/// │ │← x.syntactic_source_info.scope /// │ │← x.source_info.scope
/// │ │← `x.parse().unwrap()` /// │ │← `x.parse().unwrap()`
/// │ │ /// │ │
/// │ │ │← y.syntactic_source_info.scope /// │ │ │← y.source_info.scope
/// │ │ /// │ │
/// │ │ │{ let y: u32 } /// │ │ │{ let y: u32 }
/// │ │ │ /// │ │ │
@ -584,10 +584,10 @@ pub struct LocalDecl<'tcx> {
/// │ │← x.visibility_scope /// │ │← x.visibility_scope
/// │ │← `drop(x)` // this accesses `x: u32` /// │ │← `drop(x)` // this accesses `x: u32`
/// ``` /// ```
pub syntactic_source_info: SourceInfo, pub source_info: SourceInfo,
/// Source scope within which the local is visible (for debuginfo) /// Source scope within which the local is visible (for debuginfo)
/// (see `syntactic_source_info` for more details). /// (see `source_info` for more details).
pub visibility_scope: SourceScope, pub visibility_scope: SourceScope,
} }
@ -599,7 +599,7 @@ impl<'tcx> LocalDecl<'tcx> {
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty, ty,
name: None, name: None,
syntactic_source_info: SourceInfo { source_info: SourceInfo {
span, span,
scope: OUTERMOST_SOURCE_SCOPE scope: OUTERMOST_SOURCE_SCOPE
}, },
@ -616,7 +616,7 @@ impl<'tcx> LocalDecl<'tcx> {
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty, ty,
name: None, name: None,
syntactic_source_info: SourceInfo { source_info: SourceInfo {
span, span,
scope: OUTERMOST_SOURCE_SCOPE scope: OUTERMOST_SOURCE_SCOPE
}, },
@ -634,7 +634,7 @@ impl<'tcx> LocalDecl<'tcx> {
LocalDecl { LocalDecl {
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty: return_ty, ty: return_ty,
syntactic_source_info: SourceInfo { source_info: SourceInfo {
span, span,
scope: OUTERMOST_SOURCE_SCOPE scope: OUTERMOST_SOURCE_SCOPE
}, },
@ -2191,7 +2191,7 @@ BraceStructTypeFoldableImpl! {
internal, internal,
ty, ty,
name, name,
syntactic_source_info, source_info,
visibility_scope, visibility_scope,
} }
} }

View file

@ -714,7 +714,7 @@ macro_rules! make_mir_visitor {
mutability: _, mutability: _,
ref $($mutability)* ty, ref $($mutability)* ty,
name: _, name: _,
ref $($mutability)* syntactic_source_info, ref $($mutability)* source_info,
ref $($mutability)* visibility_scope, ref $($mutability)* visibility_scope,
internal: _, internal: _,
is_user_variable: _, is_user_variable: _,
@ -722,9 +722,9 @@ macro_rules! make_mir_visitor {
self.visit_ty(ty, TyContext::LocalDecl { self.visit_ty(ty, TyContext::LocalDecl {
local, local,
source_info: *syntactic_source_info, source_info: *source_info,
}); });
self.visit_source_info(syntactic_source_info); self.visit_source_info(source_info);
self.visit_source_scope(visibility_scope); self.visit_source_scope(visibility_scope);
} }

View file

@ -277,7 +277,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
let place = PlaceRef::alloca(&bx, layout, &name.as_str()); let place = PlaceRef::alloca(&bx, layout, &name.as_str());
if dbg { if dbg {
let (scope, span) = fx.debug_loc(mir::SourceInfo { let (scope, span) = fx.debug_loc(mir::SourceInfo {
span: decl.syntactic_source_info.span, span: decl.source_info.span,
scope: decl.visibility_scope, scope: decl.visibility_scope,
}); });
declare_local(&bx, &fx.debug_context, name, layout.ty, scope, declare_local(&bx, &fx.debug_context, name, layout.ty, scope,

View file

@ -398,7 +398,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let borrow_span = self.mir.source_info(borrow.reserve_location).span; let borrow_span = self.mir.source_info(borrow.reserve_location).span;
let proper_span = match *root_place { let proper_span = match *root_place {
Place::Local(local) => self.mir.local_decls[local].syntactic_source_info.span, Place::Local(local) => self.mir.local_decls[local].source_info.span,
_ => drop_span, _ => drop_span,
}; };

View file

@ -306,12 +306,12 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
None => continue, None => continue,
} }
let span = local_decl.syntactic_source_info.span; let span = local_decl.source_info.span;
let mut_span = tcx.sess.codemap().span_until_non_whitespace(span); let mut_span = tcx.sess.codemap().span_until_non_whitespace(span);
tcx.struct_span_lint_node( tcx.struct_span_lint_node(
UNUSED_MUT, UNUSED_MUT,
vsi[local_decl.syntactic_source_info.scope].lint_root, vsi[local_decl.source_info.scope].lint_root,
span, span,
"variable does not need to be mutable" "variable does not need to be mutable"
) )

View file

@ -67,7 +67,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
} }
None => { None => {
err.span_label( err.span_label(
mir.local_decls[local].syntactic_source_info.span, mir.local_decls[local].source_info.span,
"borrow may end up in a temporary, created here", "borrow may end up in a temporary, created here",
); );

View file

@ -1201,7 +1201,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
LocalKind::Var | LocalKind::Temp => {} LocalKind::Var | LocalKind::Temp => {}
} }
let span = local_decl.syntactic_source_info.span; let span = local_decl.source_info.span;
let ty = local_decl.ty; let ty = local_decl.ty;
// Erase the regions from `ty` to get a global type. The // Erase the regions from `ty` to get a global type. The

View file

@ -246,7 +246,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty: ptr_ty, ty: ptr_ty,
name: None, name: None,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
internal: true, internal: true,
is_user_variable: false is_user_variable: false

View file

@ -306,7 +306,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
-> Option<SourceScope> { -> Option<SourceScope> {
assert!(!(visibility_scope.is_some() && lint_level.is_explicit()), assert!(!(visibility_scope.is_some() && lint_level.is_explicit()),
"can't have both a visibility and a lint scope at the same time"); "can't have both a visibility and a lint scope at the same time");
let mut syntactic_scope = self.source_scope; let mut scope = self.source_scope;
self.visit_bindings(pattern, &mut |this, mutability, name, var, span, ty| { self.visit_bindings(pattern, &mut |this, mutability, name, var, span, ty| {
if visibility_scope.is_none() { if visibility_scope.is_none() {
visibility_scope = Some(this.new_source_scope(scope_span, visibility_scope = Some(this.new_source_scope(scope_span,
@ -314,18 +314,18 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
None)); None));
// If we have lints, create a new source scope // If we have lints, create a new source scope
// that marks the lints for the locals. See the comment // that marks the lints for the locals. See the comment
// on the `syntactic_source_info` field for why this is needed. // on the `source_info` field for why this is needed.
if lint_level.is_explicit() { if lint_level.is_explicit() {
syntactic_scope = scope =
this.new_source_scope(scope_span, lint_level, None); this.new_source_scope(scope_span, lint_level, None);
} }
} }
let syntactic_source_info = SourceInfo { let source_info = SourceInfo {
span, span,
scope: syntactic_scope, scope,
}; };
let visibility_scope = visibility_scope.unwrap(); let visibility_scope = visibility_scope.unwrap();
this.declare_binding(syntactic_source_info, visibility_scope, mutability, name, var, this.declare_binding(source_info, visibility_scope, mutability, name, var,
ty, has_guard); ty, has_guard);
}); });
visibility_scope visibility_scope
@ -1114,7 +1114,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
/// `&T`. The second local is a binding for occurrences of `var` /// `&T`. The second local is a binding for occurrences of `var`
/// in the arm body, which will have type `T`. /// in the arm body, which will have type `T`.
fn declare_binding(&mut self, fn declare_binding(&mut self,
syntactic_source_info: SourceInfo, source_info: SourceInfo,
visibility_scope: SourceScope, visibility_scope: SourceScope,
mutability: Mutability, mutability: Mutability,
name: Name, name: Name,
@ -1123,15 +1123,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
has_guard: ArmHasGuard) has_guard: ArmHasGuard)
{ {
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, visibility_scope={:?}, \ debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, visibility_scope={:?}, \
syntactic_source_info={:?})", source_info={:?})",
var_id, name, var_ty, visibility_scope, syntactic_source_info); var_id, name, var_ty, visibility_scope, source_info);
let tcx = self.hir.tcx(); let tcx = self.hir.tcx();
let local = LocalDecl::<'tcx> { let local = LocalDecl::<'tcx> {
mutability, mutability,
ty: var_ty.clone(), ty: var_ty.clone(),
name: Some(name), name: Some(name),
syntactic_source_info, source_info,
visibility_scope, visibility_scope,
internal: false, internal: false,
is_user_variable: true, is_user_variable: true,
@ -1143,7 +1143,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
mutability, mutability,
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty), ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
name: Some(name), name: Some(name),
syntactic_source_info, source_info,
visibility_scope, visibility_scope,
internal: false, internal: false,
is_user_variable: true, is_user_variable: true,

View file

@ -664,7 +664,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
self.local_decls.push(LocalDecl { self.local_decls.push(LocalDecl {
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty, ty,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
name, name,
internal: false, internal: false,

View file

@ -233,7 +233,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
fn gather_args(&mut self) { fn gather_args(&mut self) {
for arg in self.mir.args_iter() { for arg in self.mir.args_iter() {
let path = self.data.rev_lookup.locals[arg]; let path = self.data.rev_lookup.locals[arg];
let span = self.mir.local_decls[arg].syntactic_source_info.span; let span = self.mir.local_decls[arg].source_info.span;
let init = self.data.inits.push(Init { let init = self.data.inits.push(Init {
path, span, kind: InitKind::Deep path, span, kind: InitKind::Deep

View file

@ -141,7 +141,7 @@ fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl {
let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span }; let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span };
LocalDecl { LocalDecl {
mutability, ty, name: None, mutability, ty, name: None,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
internal: false, internal: false,
is_user_variable: false is_user_variable: false

View file

@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
// Internal locals are used in the `move_val_init` desugaring. // Internal locals are used in the `move_val_init` desugaring.
// We want to check unsafety against the source info of the // We want to check unsafety against the source info of the
// desugaring, rather than the source info of the RHS. // desugaring, rather than the source info of the RHS.
self.source_info = self.mir.local_decls[local].syntactic_source_info; self.source_info = self.mir.local_decls[local].source_info;
} }
} }
let base_ty = base.ty(self.mir, self.tcx).to_ty(self.tcx); let base_ty = base.ty(self.mir, self.tcx).to_ty(self.tcx);

View file

@ -300,7 +300,7 @@ fn replace_result_variable<'tcx>(ret_ty: Ty<'tcx>,
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty: ret_ty, ty: ret_ty,
name: None, name: None,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
internal: false, internal: false,
is_user_variable: false, is_user_variable: false,
@ -641,7 +641,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
mutability: Mutability::Mut, mutability: Mutability::Mut,
ty: tcx.mk_nil(), ty: tcx.mk_nil(),
name: None, name: None,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
internal: false, internal: false,
is_user_variable: false, is_user_variable: false,
@ -657,7 +657,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
mutbl: hir::Mutability::MutMutable, mutbl: hir::Mutability::MutMutable,
}), }),
name: None, name: None,
syntactic_source_info: source_info, source_info,
visibility_scope: source_info.scope, visibility_scope: source_info.scope,
internal: false, internal: false,
is_user_variable: false, is_user_variable: false,

View file

@ -398,9 +398,9 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
for loc in callee_mir.vars_and_temps_iter() { for loc in callee_mir.vars_and_temps_iter() {
let mut local = callee_mir.local_decls[loc].clone(); let mut local = callee_mir.local_decls[loc].clone();
local.syntactic_source_info.scope = local.source_info.scope =
scope_map[local.syntactic_source_info.scope]; scope_map[local.source_info.scope];
local.syntactic_source_info.span = callsite.location.span; local.source_info.span = callsite.location.span;
local.visibility_scope = scope_map[local.visibility_scope]; local.visibility_scope = scope_map[local.visibility_scope];
let idx = caller_mir.local_decls.push(local); let idx = caller_mir.local_decls.push(local);

View file

@ -210,7 +210,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let no_stmts = self.source[loc.block].statements.len(); let no_stmts = self.source[loc.block].statements.len();
let new_temp = self.promoted.local_decls.push( let new_temp = self.promoted.local_decls.push(
LocalDecl::new_temp(self.source.local_decls[temp].ty, LocalDecl::new_temp(self.source.local_decls[temp].ty,
self.source.local_decls[temp].syntactic_source_info.span)); self.source.local_decls[temp].source_info.span));
debug!("promote({:?} @ {:?}/{:?}, {:?})", debug!("promote({:?} @ {:?}/{:?}, {:?})",
temp, loc, no_stmts, self.keep_original); temp, loc, no_stmts, self.keep_original);
@ -334,7 +334,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
// This is because `*r` requires `r` to be a local, // This is because `*r` requires `r` to be a local,
// otherwise we would use the `promoted` directly. // otherwise we would use the `promoted` directly.
let mut promoted_ref = LocalDecl::new_temp(ref_ty, span); let mut promoted_ref = LocalDecl::new_temp(ref_ty, span);
promoted_ref.syntactic_source_info = statement.source_info; promoted_ref.source_info = statement.source_info;
promoted_ref.visibility_scope = statement.source_info.scope; promoted_ref.visibility_scope = statement.source_info.scope;
let promoted_ref = local_decls.push(promoted_ref); let promoted_ref = local_decls.push(promoted_ref);
assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref); assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);

View file

@ -1046,7 +1046,7 @@ This does not pose a problem by itself because they can't be accessed directly."
// conservatively, that drop elaboration will do. // conservatively, that drop elaboration will do.
let needs_drop = if let Place::Local(local) = *place { let needs_drop = if let Place::Local(local) = *place {
if self.local_qualif[local].map_or(true, |q| q.intersects(Qualif::NEEDS_DROP)) { if self.local_qualif[local].map_or(true, |q| q.intersects(Qualif::NEEDS_DROP)) {
Some(self.mir.local_decls[local].syntactic_source_info.span) Some(self.mir.local_decls[local].source_info.span)
} else { } else {
None None
} }
@ -1102,7 +1102,7 @@ This does not pose a problem by itself because they can't be accessed directly."
let mut err = feature_err( let mut err = feature_err(
&self.tcx.sess.parse_sess, &self.tcx.sess.parse_sess,
"const_let", "const_let",
decl.syntactic_source_info.span, decl.source_info.span,
GateIssue::Language, GateIssue::Language,
"arguments of constant functions can only be immutable by-value bindings" "arguments of constant functions can only be immutable by-value bindings"
); );

View file

@ -467,8 +467,8 @@ fn write_scope_tree(
// User variable types (including the user's name in a comment). // User variable types (including the user's name in a comment).
for local in mir.vars_iter() { for local in mir.vars_iter() {
let var = &mir.local_decls[local]; let var = &mir.local_decls[local];
let (name, source_info) = if var.syntactic_source_info.scope == child { let (name, source_info) = if var.source_info.scope == child {
(var.name.unwrap(), var.syntactic_source_info) (var.name.unwrap(), var.source_info)
} else { } else {
// Not a variable or not declared in this scope. // Not a variable or not declared in this scope.
continue; continue;