Skip to content

Commit 0895590

Browse files
committed
rustc: rename mir::LocalDecl's source_info to visibility_source_info.
1 parent b10c157 commit 0895590

File tree

20 files changed

+60
-59
lines changed

20 files changed

+60
-59
lines changed

src/librustc/ich/impls_mir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl_stable_hash_for!(struct mir::LocalDecl<'tcx> {
2525
mutability,
2626
ty,
2727
name,
28-
source_info,
2928
syntactic_source_info,
29+
visibility_source_info,
3030
internal,
3131
is_user_variable
3232
});

src/librustc/mir/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,6 @@ pub struct LocalDecl<'tcx> {
505505
/// to generate better debuginfo.
506506
pub name: Option<Name>,
507507

508-
/// Source info of the local. The `SourceScope` is the *visibility* one,
509-
/// not the the *syntactic* one (see `syntactic_source_info` for more details).
510-
pub source_info: SourceInfo,
511-
512508
/// The *syntactic* (i.e. not visibility) source scope the local is defined
513509
/// in. If the local was defined in a let-statement, this
514510
/// is *within* the let-statement, rather than outside
@@ -562,7 +558,7 @@ pub struct LocalDecl<'tcx> {
562558
/// To allow both uses to work, we need to have more than a single scope
563559
/// for a local. We have the `syntactic_source_info.scope` represent the
564560
/// "syntactic" lint scope (with a variable being under its let
565-
/// block) while the `source_info.scope` represents the "local variable"
561+
/// block) while the `visibility_source_info.scope` represents the "local variable"
566562
/// scope (where the "rest" of a block is under all prior let-statements).
567563
///
568564
/// The end result looks like this:
@@ -581,14 +577,18 @@ pub struct LocalDecl<'tcx> {
581577
/// │ │
582578
/// │ │ │{ let y: u32 }
583579
/// │ │ │
584-
/// │ │ │← y.source_info.scope
580+
/// │ │ │← y.visibility_source_info.scope
585581
/// │ │ │← `y + 2`
586582
/// │
587583
/// │ │{ let x: u32 }
588-
/// │ │← x.source_info.scope
584+
/// │ │← x.visibility_source_info.scope
589585
/// │ │← `drop(x)` // this accesses `x: u32`
590586
/// ```
591587
pub syntactic_source_info: SourceInfo,
588+
589+
/// Source info of the local. The `SourceScope` is the *visibility* one,
590+
/// not the the *syntactic* one (see `syntactic_source_info` for more details).
591+
pub visibility_source_info: SourceInfo,
592592
}
593593

594594
impl<'tcx> LocalDecl<'tcx> {
@@ -599,11 +599,11 @@ impl<'tcx> LocalDecl<'tcx> {
599599
mutability: Mutability::Mut,
600600
ty,
601601
name: None,
602-
source_info: SourceInfo {
602+
syntactic_source_info: SourceInfo {
603603
span,
604604
scope: OUTERMOST_SOURCE_SCOPE
605605
},
606-
syntactic_source_info: SourceInfo {
606+
visibility_source_info: SourceInfo {
607607
span,
608608
scope: OUTERMOST_SOURCE_SCOPE
609609
},
@@ -619,11 +619,11 @@ impl<'tcx> LocalDecl<'tcx> {
619619
mutability: Mutability::Mut,
620620
ty,
621621
name: None,
622-
source_info: SourceInfo {
622+
syntactic_source_info: SourceInfo {
623623
span,
624624
scope: OUTERMOST_SOURCE_SCOPE
625625
},
626-
syntactic_source_info: SourceInfo {
626+
visibility_source_info: SourceInfo {
627627
span,
628628
scope: OUTERMOST_SOURCE_SCOPE
629629
},
@@ -640,11 +640,11 @@ impl<'tcx> LocalDecl<'tcx> {
640640
LocalDecl {
641641
mutability: Mutability::Mut,
642642
ty: return_ty,
643-
source_info: SourceInfo {
643+
syntactic_source_info: SourceInfo {
644644
span,
645645
scope: OUTERMOST_SOURCE_SCOPE
646646
},
647-
syntactic_source_info: SourceInfo {
647+
visibility_source_info: SourceInfo {
648648
span,
649649
scope: OUTERMOST_SOURCE_SCOPE
650650
},
@@ -2200,8 +2200,8 @@ BraceStructTypeFoldableImpl! {
22002200
internal,
22012201
ty,
22022202
name,
2203-
source_info,
22042203
syntactic_source_info,
2204+
visibility_source_info,
22052205
}
22062206
}
22072207

src/librustc/mir/visit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,18 +714,18 @@ macro_rules! make_mir_visitor {
714714
mutability: _,
715715
ref $($mutability)* ty,
716716
name: _,
717-
ref $($mutability)* source_info,
718-
internal: _,
719717
ref $($mutability)* syntactic_source_info,
718+
ref $($mutability)* visibility_source_info,
719+
internal: _,
720720
is_user_variable: _,
721721
} = *local_decl;
722722

723723
self.visit_ty(ty, TyContext::LocalDecl {
724724
local,
725-
source_info: *source_info,
725+
source_info: *visibility_source_info,
726726
});
727727
self.visit_source_info(syntactic_source_info);
728-
self.visit_source_info(source_info);
728+
self.visit_source_info(visibility_source_info);
729729
}
730730

731731
fn super_source_scope(&mut self,

src/librustc_codegen_llvm/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu
6565
let mut has_variables = BitVector::new(mir.source_scopes.len());
6666
for var in mir.vars_iter() {
6767
let decl = &mir.local_decls[var];
68-
has_variables.insert(decl.source_info.scope.index());
68+
has_variables.insert(decl.visibility_source_info.scope.index());
6969
}
7070

7171
// Instantiate all scopes.

src/librustc_codegen_llvm/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
265265

266266
if let Some(name) = decl.name {
267267
// User variable
268-
let debug_scope = fx.scopes[decl.source_info.scope];
268+
let debug_scope = fx.scopes[decl.visibility_source_info.scope];
269269
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo;
270270

271271
if !memory_locals.contains(local.index()) && !dbg {
@@ -276,7 +276,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
276276
debug!("alloc: {:?} ({}) -> place", local, name);
277277
let place = PlaceRef::alloca(&bx, layout, &name.as_str());
278278
if dbg {
279-
let (scope, span) = fx.debug_loc(decl.source_info);
279+
let (scope, span) = fx.debug_loc(decl.visibility_source_info);
280280
declare_local(&bx, &fx.debug_context, name, layout.ty, scope,
281281
VariableAccess::DirectVariable { alloca: place.llval },
282282
VariableKind::LocalVariable, span);

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
398398

399399
let borrow_span = self.mir.source_info(borrow.reserve_location).span;
400400
let proper_span = match *root_place {
401-
Place::Local(local) => self.mir.local_decls[local].source_info.span,
401+
Place::Local(local) => self.mir.local_decls[local].visibility_source_info.span,
402402
_ => drop_span,
403403
};
404404

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
306306
None => continue,
307307
}
308308

309-
let source_info = local_decl.source_info;
309+
let source_info = local_decl.visibility_source_info;
310310
let mut_span = tcx.sess.codemap().span_until_non_whitespace(source_info.span);
311311

312312
tcx.struct_span_lint_node(

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
6767
}
6868
None => {
6969
err.span_label(
70-
mir.local_decls[local].source_info.span,
70+
mir.local_decls[local].visibility_source_info.span,
7171
"borrow may end up in a temporary, created here",
7272
);
7373

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
12011201
LocalKind::Var | LocalKind::Temp => {}
12021202
}
12031203

1204-
let span = local_decl.source_info.span;
1204+
let span = local_decl.visibility_source_info.span;
12051205
let ty = local_decl.ty;
12061206

12071207
// Erase the regions from `ty` to get a global type. The

src/librustc_mir/build/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
246246
mutability: Mutability::Mut,
247247
ty: ptr_ty,
248248
name: None,
249-
source_info,
250249
syntactic_source_info: source_info,
250+
visibility_source_info: source_info,
251251
internal: true,
252252
is_user_variable: false
253253
});

src/librustc_mir/build/matches/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,22 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
294294
block.unit()
295295
}
296296

297-
/// Declares the bindings of the given pattern and returns the source scope
297+
/// Declares the bindings of the given pattern and returns the visibility scope
298298
/// for the bindings in this patterns, if such a scope had to be created.
299299
/// NOTE: Declaring the bindings should always be done in their drop scope.
300300
pub fn declare_bindings(&mut self,
301-
mut var_scope: Option<SourceScope>,
301+
mut visibility_scope: Option<SourceScope>,
302302
scope_span: Span,
303303
lint_level: LintLevel,
304304
pattern: &Pattern<'tcx>,
305305
has_guard: ArmHasGuard)
306306
-> Option<SourceScope> {
307-
assert!(!(var_scope.is_some() && lint_level.is_explicit()),
308-
"can't have both a var and a lint scope at the same time");
307+
assert!(!(visibility_scope.is_some() && lint_level.is_explicit()),
308+
"can't have both a visibility and a lint scope at the same time");
309309
let mut syntactic_scope = self.source_scope;
310310
self.visit_bindings(pattern, &mut |this, mutability, name, var, span, ty| {
311-
if var_scope.is_none() {
312-
var_scope = Some(this.new_source_scope(scope_span,
311+
if visibility_scope.is_none() {
312+
visibility_scope = Some(this.new_source_scope(scope_span,
313313
LintLevel::Inherited,
314314
None));
315315
// If we have lints, create a new source scope
@@ -320,18 +320,18 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
320320
this.new_source_scope(scope_span, lint_level, None);
321321
}
322322
}
323-
let source_info = SourceInfo {
324-
span,
325-
scope: var_scope.unwrap()
326-
};
327323
let syntactic_source_info = SourceInfo {
328324
span,
329325
scope: syntactic_scope,
330326
};
331-
this.declare_binding(source_info, syntactic_source_info, mutability, name, var,
327+
let visibility_source_info = SourceInfo {
328+
span,
329+
scope: visibility_scope.unwrap()
330+
};
331+
this.declare_binding(syntactic_source_info, visibility_source_info, mutability, name, var,
332332
ty, has_guard);
333333
});
334-
var_scope
334+
visibility_scope
335335
}
336336

337337
pub fn storage_live_binding(&mut self,
@@ -1117,25 +1117,25 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
11171117
/// `&T`. The second local is a binding for occurrences of `var`
11181118
/// in the arm body, which will have type `T`.
11191119
fn declare_binding(&mut self,
1120-
source_info: SourceInfo,
11211120
syntactic_source_info: SourceInfo,
1121+
visibility_source_info: SourceInfo,
11221122
mutability: Mutability,
11231123
name: Name,
11241124
var_id: NodeId,
11251125
var_ty: Ty<'tcx>,
11261126
has_guard: ArmHasGuard)
11271127
{
1128-
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, source_info={:?}, \
1128+
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, visibility_source_info={:?}, \
11291129
syntactic_source_info={:?})",
1130-
var_id, name, var_ty, source_info, syntactic_source_info);
1130+
var_id, name, var_ty, visibility_source_info, syntactic_source_info);
11311131

11321132
let tcx = self.hir.tcx();
11331133
let local = LocalDecl::<'tcx> {
11341134
mutability,
11351135
ty: var_ty.clone(),
11361136
name: Some(name),
1137-
source_info,
11381137
syntactic_source_info,
1138+
visibility_source_info,
11391139
internal: false,
11401140
is_user_variable: true,
11411141
};
@@ -1146,8 +1146,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
11461146
mutability,
11471147
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
11481148
name: Some(name),
1149-
source_info,
11501149
syntactic_source_info,
1150+
visibility_source_info,
11511151
internal: false,
11521152
is_user_variable: true,
11531153
});

src/librustc_mir/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
664664
self.local_decls.push(LocalDecl {
665665
mutability: Mutability::Mut,
666666
ty,
667-
source_info,
668667
syntactic_source_info: source_info,
668+
visibility_source_info: source_info,
669669
name,
670670
internal: false,
671671
is_user_variable: false,

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
233233
fn gather_args(&mut self) {
234234
for arg in self.mir.args_iter() {
235235
let path = self.data.rev_lookup.locals[arg];
236-
let span = self.mir.local_decls[arg].source_info.span;
236+
let span = self.mir.local_decls[arg].visibility_source_info.span;
237237

238238
let init = self.data.inits.push(Init {
239239
path, span, kind: InitKind::Deep

src/librustc_mir/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl {
141141
let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span };
142142
LocalDecl {
143143
mutability, ty, name: None,
144-
source_info,
145144
syntactic_source_info: source_info,
145+
visibility_source_info: source_info,
146146
internal: false,
147147
is_user_variable: false
148148
}

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
166166
// Internal locals are used in the `move_val_init` desugaring.
167167
// We want to check unsafety against the source info of the
168168
// desugaring, rather than the source info of the RHS.
169-
self.source_info = self.mir.local_decls[local].source_info;
169+
self.source_info = self.mir.local_decls[local].visibility_source_info;
170170
}
171171
}
172172
let base_ty = base.ty(self.mir, self.tcx).to_ty(self.tcx);

src/librustc_mir/transform/generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ fn replace_result_variable<'tcx>(ret_ty: Ty<'tcx>,
300300
mutability: Mutability::Mut,
301301
ty: ret_ty,
302302
name: None,
303-
source_info,
304303
syntactic_source_info: source_info,
304+
visibility_source_info: source_info,
305305
internal: false,
306306
is_user_variable: false,
307307
};
@@ -641,8 +641,8 @@ fn create_generator_drop_shim<'a, 'tcx>(
641641
mutability: Mutability::Mut,
642642
ty: tcx.mk_nil(),
643643
name: None,
644-
source_info,
645644
syntactic_source_info: source_info,
645+
visibility_source_info: source_info,
646646
internal: false,
647647
is_user_variable: false,
648648
};
@@ -657,8 +657,8 @@ fn create_generator_drop_shim<'a, 'tcx>(
657657
mutbl: hir::Mutability::MutMutable,
658658
}),
659659
name: None,
660-
source_info,
661660
syntactic_source_info: source_info,
661+
visibility_source_info: source_info,
662662
internal: false,
663663
is_user_variable: false,
664664
};

src/librustc_mir/transform/inline.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,12 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
398398
for loc in callee_mir.vars_and_temps_iter() {
399399
let mut local = callee_mir.local_decls[loc].clone();
400400

401-
local.source_info.scope = scope_map[local.source_info.scope];
402-
local.source_info.span = callsite.location.span;
403401
local.syntactic_source_info.scope =
404402
scope_map[local.syntactic_source_info.scope];
405403
local.syntactic_source_info.span = callsite.location.span;
404+
local.visibility_source_info.scope =
405+
scope_map[local.visibility_source_info.scope];
406+
local.visibility_source_info.span = callsite.location.span;
406407

407408
let idx = caller_mir.local_decls.push(local);
408409
local_map.push(idx);

src/librustc_mir/transform/promote_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
210210
let no_stmts = self.source[loc.block].statements.len();
211211
let new_temp = self.promoted.local_decls.push(
212212
LocalDecl::new_temp(self.source.local_decls[temp].ty,
213-
self.source.local_decls[temp].source_info.span));
213+
self.source.local_decls[temp].visibility_source_info.span));
214214

215215
debug!("promote({:?} @ {:?}/{:?}, {:?})",
216216
temp, loc, no_stmts, self.keep_original);
@@ -334,8 +334,8 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
334334
// This is because `*r` requires `r` to be a local,
335335
// otherwise we would use the `promoted` directly.
336336
let mut promoted_ref = LocalDecl::new_temp(ref_ty, span);
337-
promoted_ref.source_info = statement.source_info;
338337
promoted_ref.syntactic_source_info = statement.source_info;
338+
promoted_ref.visibility_source_info = statement.source_info;
339339
let promoted_ref = local_decls.push(promoted_ref);
340340
assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);
341341
self.extra_statements.push((loc, Statement {

0 commit comments

Comments
 (0)