mutability,
ty,
name,
- syntactic_source_info,
+ source_info,
visibility_scope,
internal,
is_user_variable
/// `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
- /// 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
/// block) while the `visibility_scope` represents the "local variable"
/// scope (where the "rest" of a block is under all prior let-statements).
/// │ │{ #[allow(unused_mut] } // this is actually split into 2 scopes
/// │ │ // in practice because I'm lazy.
/// │ │
- /// │ │← x.syntactic_source_info.scope
+ /// │ │← x.source_info.scope
/// │ │← `x.parse().unwrap()`
/// │ │
- /// │ │ │← y.syntactic_source_info.scope
+ /// │ │ │← y.source_info.scope
/// │ │
/// │ │ │{ let y: u32 }
/// │ │ │
/// │ │← x.visibility_scope
/// │ │← `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)
- /// (see `syntactic_source_info` for more details).
+ /// (see `source_info` for more details).
pub visibility_scope: SourceScope,
}
mutability: Mutability::Mut,
ty,
name: None,
- syntactic_source_info: SourceInfo {
+ source_info: SourceInfo {
span,
scope: OUTERMOST_SOURCE_SCOPE
},
mutability: Mutability::Mut,
ty,
name: None,
- syntactic_source_info: SourceInfo {
+ source_info: SourceInfo {
span,
scope: OUTERMOST_SOURCE_SCOPE
},
LocalDecl {
mutability: Mutability::Mut,
ty: return_ty,
- syntactic_source_info: SourceInfo {
+ source_info: SourceInfo {
span,
scope: OUTERMOST_SOURCE_SCOPE
},
internal,
ty,
name,
- syntactic_source_info,
+ source_info,
visibility_scope,
}
}
mutability: _,
ref $($mutability)* ty,
name: _,
- ref $($mutability)* syntactic_source_info,
+ ref $($mutability)* source_info,
ref $($mutability)* visibility_scope,
internal: _,
is_user_variable: _,
self.visit_ty(ty, TyContext::LocalDecl {
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);
}
let place = PlaceRef::alloca(&bx, layout, &name.as_str());
if dbg {
let (scope, span) = fx.debug_loc(mir::SourceInfo {
- span: decl.syntactic_source_info.span,
+ span: decl.source_info.span,
scope: decl.visibility_scope,
});
declare_local(&bx, &fx.debug_context, name, layout.ty, scope,
let borrow_span = self.mir.source_info(borrow.reserve_location).span;
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,
};
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);
tcx.struct_span_lint_node(
UNUSED_MUT,
- vsi[local_decl.syntactic_source_info.scope].lint_root,
+ vsi[local_decl.source_info.scope].lint_root,
span,
"variable does not need to be mutable"
)
}
None => {
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",
);
LocalKind::Var | LocalKind::Temp => {}
}
- let span = local_decl.syntactic_source_info.span;
+ let span = local_decl.source_info.span;
let ty = local_decl.ty;
// Erase the regions from `ty` to get a global type. The
mutability: Mutability::Mut,
ty: ptr_ty,
name: None,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
internal: true,
is_user_variable: false
-> Option<SourceScope> {
assert!(!(visibility_scope.is_some() && lint_level.is_explicit()),
"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| {
if visibility_scope.is_none() {
visibility_scope = Some(this.new_source_scope(scope_span,
None));
// If we have lints, create a new source scope
// 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() {
- syntactic_scope =
+ scope =
this.new_source_scope(scope_span, lint_level, None);
}
}
- let syntactic_source_info = SourceInfo {
+ let source_info = SourceInfo {
span,
- scope: syntactic_scope,
+ scope,
};
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);
});
visibility_scope
/// `&T`. The second local is a binding for occurrences of `var`
/// in the arm body, which will have type `T`.
fn declare_binding(&mut self,
- syntactic_source_info: SourceInfo,
+ source_info: SourceInfo,
visibility_scope: SourceScope,
mutability: Mutability,
name: Name,
has_guard: ArmHasGuard)
{
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, visibility_scope={:?}, \
- syntactic_source_info={:?})",
- var_id, name, var_ty, visibility_scope, syntactic_source_info);
+ source_info={:?})",
+ var_id, name, var_ty, visibility_scope, source_info);
let tcx = self.hir.tcx();
let local = LocalDecl::<'tcx> {
mutability,
ty: var_ty.clone(),
name: Some(name),
- syntactic_source_info,
+ source_info,
visibility_scope,
internal: false,
is_user_variable: true,
mutability,
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
name: Some(name),
- syntactic_source_info,
+ source_info,
visibility_scope,
internal: false,
is_user_variable: true,
self.local_decls.push(LocalDecl {
mutability: Mutability::Mut,
ty,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
name,
internal: false,
fn gather_args(&mut self) {
for arg in self.mir.args_iter() {
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 {
path, span, kind: InitKind::Deep
let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span };
LocalDecl {
mutability, ty, name: None,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
internal: false,
is_user_variable: false
// Internal locals are used in the `move_val_init` desugaring.
// We want to check unsafety against the source info of the
// 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);
mutability: Mutability::Mut,
ty: ret_ty,
name: None,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
internal: false,
is_user_variable: false,
mutability: Mutability::Mut,
ty: tcx.mk_nil(),
name: None,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
internal: false,
is_user_variable: false,
mutbl: hir::Mutability::MutMutable,
}),
name: None,
- syntactic_source_info: source_info,
+ source_info,
visibility_scope: source_info.scope,
internal: false,
is_user_variable: false,
for loc in callee_mir.vars_and_temps_iter() {
let mut local = callee_mir.local_decls[loc].clone();
- local.syntactic_source_info.scope =
- scope_map[local.syntactic_source_info.scope];
- local.syntactic_source_info.span = callsite.location.span;
+ local.source_info.scope =
+ scope_map[local.source_info.scope];
+ local.source_info.span = callsite.location.span;
local.visibility_scope = scope_map[local.visibility_scope];
let idx = caller_mir.local_decls.push(local);
let no_stmts = self.source[loc.block].statements.len();
let new_temp = self.promoted.local_decls.push(
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({:?} @ {:?}/{:?}, {:?})",
temp, loc, no_stmts, self.keep_original);
// This is because `*r` requires `r` to be a local,
// otherwise we would use the `promoted` directly.
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;
let promoted_ref = local_decls.push(promoted_ref);
assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);
// conservatively, that drop elaboration will do.
let needs_drop = if let Place::Local(local) = *place {
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 {
None
}
let mut err = feature_err(
&self.tcx.sess.parse_sess,
"const_let",
- decl.syntactic_source_info.span,
+ decl.source_info.span,
GateIssue::Language,
"arguments of constant functions can only be immutable by-value bindings"
);
// User variable types (including the user's name in a comment).
for local in mir.vars_iter() {
let var = &mir.local_decls[local];
- let (name, source_info) = if var.syntactic_source_info.scope == child {
- (var.name.unwrap(), var.syntactic_source_info)
+ let (name, source_info) = if var.source_info.scope == child {
+ (var.name.unwrap(), var.source_info)
} else {
// Not a variable or not declared in this scope.
continue;