Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Nov 21, 2019
1 parent 025630d commit bccc59a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/librustc/mir/mod.rs
Expand Up @@ -689,13 +689,6 @@ pub struct LocalDecl<'tcx> {
/// Temporaries and the return place are always mutable.
pub mutability: Mutability,

/// `Some(binding_mode)` if this corresponds to a user-declared local variable.
///
/// This is solely used for local diagnostics when generating
/// warnings/errors when compiling the current crate, and
/// therefore it need not be visible across crates. pnkfelix
/// currently hypothesized we *need* to wrap this in a
/// `ClearCrossCrate` as long as it carries as `HirId`.
// FIXME(matthewjasper) Don't store in this in `Body`
pub local_info: LocalInfo<'tcx>,

Expand Down Expand Up @@ -831,6 +824,10 @@ pub struct LocalDecl<'tcx> {
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub enum LocalInfo<'tcx> {
/// A user-defined local variable or function parameter
///
/// The `BindingForm` is solely used for local diagnostics when generating
/// warnings/errors when compiling the current crate, and therefore it need
/// not be visible across crates.
User(ClearCrossCrate<BindingForm<'tcx>>),
/// A temporary created that references the static with the given `DefId`.
StaticRef { def_id: DefId, is_thread_local: bool },
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/build/expr/as_temp.rs
Expand Up @@ -65,8 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
local_decl = local_decl.block_tail(tail_info);
}
if let ExprKind::StaticRef { def_id, .. } = expr.kind {
let attrs = this.hir.tcx().get_attrs(def_id);
let is_thread_local = attrs.iter().any(|attr| attr.check_name(sym::thread_local));
let is_thread_local = this.hir.tcx().has_attr(def_id, sym::thread_local);
local_decl.local_info = LocalInfo::StaticRef {def_id, is_thread_local };
}
this.local_decls.push(local_decl)
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_mir/hair/mod.rs
Expand Up @@ -264,7 +264,10 @@ pub enum ExprKind<'tcx> {
literal: &'tcx Const<'tcx>,
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
},
/// A literal containing the address of a `static`
/// A literal containing the address of a `static`.
///
/// This is only distinguished from `Literal` so that we can register some
/// info for diagnostics.
StaticRef {
literal: &'tcx Const<'tcx>,
def_id: DefId,
Expand Down

0 comments on commit bccc59a

Please sign in to comment.