Skip to content

Commit 8138efa

Browse files
committed
Avoid two Symbol::as_str() calls.
1 parent 4fd18c9 commit 8138efa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/librustc_metadata/native_libs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_target::spec::abi::Abi;
88
use syntax::attr;
99
use syntax::source_map::Span;
1010
use syntax::feature_gate::{self, GateIssue};
11-
use syntax::symbol::{Symbol, sym};
11+
use syntax::symbol::{kw, sym, Symbol};
1212
use syntax::{span_err, struct_span_err};
1313

1414
pub fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
@@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
132132

133133
impl Collector<'tcx> {
134134
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
135-
if lib.name.as_ref().map(|s| s.as_str().is_empty()).unwrap_or(false) {
135+
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
136136
match span {
137137
Some(span) => {
138138
struct_span_err!(self.tcx.sess, span, E0454,

src/librustc_mir/const_eval.rs

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

0 commit comments

Comments
 (0)