提交 bccc59a8 编写于 作者: M Matthew Jasper

Address review comments

上级 025630d1
......@@ -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>,
......@@ -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 },
......
......@@ -65,8 +65,7 @@ fn expr_as_temp(
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)
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册