Avoid two Symbol::as_str() calls.

This commit is contained in:
Nicholas Nethercote 2019-09-05 11:54:01 +10:00
parent 4fd18c9c06
commit 8138efae16
2 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ use rustc_target::spec::abi::Abi;
use syntax::attr;
use syntax::source_map::Span;
use syntax::feature_gate::{self, GateIssue};
use syntax::symbol::{Symbol, sym};
use syntax::symbol::{kw, sym, Symbol};
use syntax::{span_err, struct_span_err};
pub fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
impl Collector<'tcx> {
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
if lib.name.as_ref().map(|s| s.as_str().is_empty()).unwrap_or(false) {
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
match span {
Some(span) => {
struct_span_err!(self.tcx.sess, span, E0454,

View File

@ -383,7 +383,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
return Ok(());
}
// An intrinsic that we do not support
let intrinsic_name = &ecx.tcx.item_name(instance.def_id()).as_str()[..];
let intrinsic_name = ecx.tcx.item_name(instance.def_id());
Err(
ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", intrinsic_name)).into()
)