Pass a Symbol to check_name, emit_feature_err, and related functions.

This commit is contained in:
Nicholas Nethercote
2019-05-08 13:21:18 +10:00
parent 79602c87b5
commit fb084a48e2
114 changed files with 671 additions and 621 deletions
+2 -1
View File
@@ -23,6 +23,7 @@
use rustc::ty::TyCtxt;
use rustc::hir::def_id::LOCAL_CRATE;
use syntax::symbol::sym;
pub mod link;
pub mod codegen_backend;
@@ -35,7 +36,7 @@
/// reporting an error.
pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_, '_, '_>) {
if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
if tcx.has_attr(def_id, "rustc_error") {
if tcx.has_attr(def_id, sym::rustc_error) {
tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
}
}
+2 -1
View File
@@ -2,6 +2,7 @@
use rustc::session::Session;
use std::path::{Path, PathBuf};
use syntax::{ast, attr};
use syntax::symbol::sym;
use syntax_pos::Span;
pub fn out_filename(sess: &Session,
@@ -49,7 +50,7 @@ pub fn find_crate_name(sess: Option<&Session>,
// as used. After doing this, however, we still prioritize a crate name from
// the command line over one found in the #[crate_name] attribute. If we
// find both we ensure that they're the same later on as well.
let attr_crate_name = attr::find_by_name(attrs, "crate_name")
let attr_crate_name = attr::find_by_name(attrs, sym::crate_name)
.and_then(|at| at.value_str().map(|s| (at, s)));
if let Some(sess) = sess {
@@ -6,11 +6,11 @@
use rustc::hir;
use rustc::ty::TyCtxt;
use rustc_mir::monomorphize::Instance;
use syntax::symbol::{Symbol, sym};
const SYMBOL_NAME: &'static str = "rustc_symbol_name";
const DEF_PATH: &'static str = "rustc_def_path";
const SYMBOL_NAME: Symbol = sym::rustc_symbol_name;
const DEF_PATH: Symbol = sym::rustc_def_path;
pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
// if the `rustc_attrs` feature is not enabled, then the