Auto merge of #64303 - nnethercote:avoid-more-Symbol-to-string-operations, r=petrochenkov
Avoid more `Symbol`-to-string operations These commits avoid various `Symbol`-to-string conversions, by doing more operations directly on `Symbol`s. This requires adding a few more static `Symbol`s to the binary. r? @petrochenkov
This commit is contained in:
commit
f71826e8f2
13 changed files with 93 additions and 81 deletions
|
@ -116,8 +116,8 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Context<'a, 'tcx> {
|
||||
fn register(&mut self, name: &str, span: Span) {
|
||||
$(if name == stringify!($name) {
|
||||
fn register(&mut self, name: Symbol, span: Span) {
|
||||
$(if name == sym::$name {
|
||||
if self.items.$name().is_none() {
|
||||
self.items.missing.push(lang_items::$item);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
|||
|
||||
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
|
||||
if let Some((lang_item, _)) = lang_items::extract(&i.attrs) {
|
||||
self.register(&lang_item.as_str(), i.span);
|
||||
self.register(lang_item, i.span);
|
||||
}
|
||||
intravisit::walk_foreign_item(self, i)
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use crate::llvm::{self, ArchiveKind};
|
|||
use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION};
|
||||
use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library};
|
||||
use rustc::session::Session;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
struct ArchiveConfig<'a> {
|
||||
pub sess: &'a Session,
|
||||
|
@ -109,7 +110,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
|
|||
|
||||
/// Adds all of the contents of a native library to this archive. This will
|
||||
/// search in the relevant locations for a library named `name`.
|
||||
fn add_native_library(&mut self, name: &str) {
|
||||
fn add_native_library(&mut self, name: Symbol) {
|
||||
let location = find_library(name, &self.config.lib_search_paths,
|
||||
self.config.sess);
|
||||
self.add_archive(&location, |_| false).unwrap_or_else(|e| {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use rustc::session::Session;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn find_library(name: &str, search_paths: &[PathBuf], sess: &Session)
|
||||
pub fn find_library(name: Symbol, search_paths: &[PathBuf], sess: &Session)
|
||||
-> PathBuf {
|
||||
// On Windows, static libraries sometimes show up as libfoo.a and other
|
||||
// times show up as foo.lib
|
||||
|
@ -40,7 +41,7 @@ pub trait ArchiveBuilder<'a> {
|
|||
lto: bool,
|
||||
skip_objects: bool,
|
||||
) -> io::Result<()>;
|
||||
fn add_native_library(&mut self, name: &str);
|
||||
fn add_native_library(&mut self, name: Symbol);
|
||||
fn update_symbols(&mut self);
|
||||
|
||||
fn build(self);
|
||||
|
|
|
@ -8,6 +8,7 @@ use std::mem;
|
|||
use std::process::{self, Output};
|
||||
|
||||
use rustc_target::spec::LldFlavor;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Command {
|
||||
|
@ -49,6 +50,11 @@ impl Command {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
|
||||
self.arg(&arg.as_str());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn args<I>(&mut self, args: I) -> &mut Command
|
||||
where
|
||||
I: IntoIterator<Item: AsRef<OsStr>>,
|
||||
|
|
|
@ -13,6 +13,7 @@ use rustc::hir::def_id::CrateNum;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||
use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use crate::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION, CrateInfo, CodegenResults};
|
||||
use super::archive::ArchiveBuilder;
|
||||
|
@ -316,7 +317,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
|
|||
NativeLibraryKind::NativeUnknown => continue,
|
||||
}
|
||||
if let Some(name) = lib.name {
|
||||
ab.add_native_library(&name.as_str());
|
||||
ab.add_native_library(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1273,15 +1274,14 @@ pub fn add_local_native_libraries(cmd: &mut dyn Linker,
|
|||
let search_path = archive_search_paths(sess);
|
||||
for lib in relevant_libs {
|
||||
let name = match lib.name {
|
||||
Some(ref l) => l,
|
||||
Some(l) => l,
|
||||
None => continue,
|
||||
};
|
||||
match lib.kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
|
||||
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()),
|
||||
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(),
|
||||
&search_path)
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
|
||||
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(name),
|
||||
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(name, &search_path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1594,7 +1594,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
|
|||
cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
|
||||
}
|
||||
let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
|
||||
cmd.link_rust_dylib(&unlib(&sess.target, filestem),
|
||||
cmd.link_rust_dylib(Symbol::intern(&unlib(&sess.target, filestem)),
|
||||
parent.unwrap_or(Path::new("")));
|
||||
}
|
||||
}
|
||||
|
@ -1637,22 +1637,22 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
|
|||
for &(cnum, _) in crates {
|
||||
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
|
||||
let name = match lib.name {
|
||||
Some(ref l) => l,
|
||||
Some(l) => l,
|
||||
None => continue,
|
||||
};
|
||||
if !relevant_lib(sess, &lib) {
|
||||
continue
|
||||
}
|
||||
match lib.kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
|
||||
NativeLibraryKind::NativeStaticNobundle => {
|
||||
// Link "static-nobundle" native libs only if the crate they originate from
|
||||
// is being linked statically to the current crate. If it's linked dynamically
|
||||
// or is an rlib already included via some other dylib crate, the symbols from
|
||||
// native libs will have already been included in that dylib.
|
||||
if data[cnum.as_usize() - 1] == Linkage::Static {
|
||||
cmd.link_staticlib(&name.as_str())
|
||||
cmd.link_staticlib(name)
|
||||
}
|
||||
},
|
||||
// ignore statically included native libraries here as we've
|
||||
|
|
|
@ -17,6 +17,7 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
|
|||
use rustc::ty::TyCtxt;
|
||||
use rustc_target::spec::{LinkerFlavor, LldFlavor};
|
||||
use rustc_serialize::{json, Encoder};
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
/// For all the linkers we support, and information they might
|
||||
/// need out of the shared crate context before we get rid of it.
|
||||
|
@ -99,13 +100,13 @@ impl LinkerInfo {
|
|||
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
|
||||
/// MSVC linker (e.g., `link.exe`) is being used.
|
||||
pub trait Linker {
|
||||
fn link_dylib(&mut self, lib: &str);
|
||||
fn link_rust_dylib(&mut self, lib: &str, path: &Path);
|
||||
fn link_framework(&mut self, framework: &str);
|
||||
fn link_staticlib(&mut self, lib: &str);
|
||||
fn link_dylib(&mut self, lib: Symbol);
|
||||
fn link_rust_dylib(&mut self, lib: Symbol, path: &Path);
|
||||
fn link_framework(&mut self, framework: Symbol);
|
||||
fn link_staticlib(&mut self, lib: Symbol);
|
||||
fn link_rlib(&mut self, lib: &Path);
|
||||
fn link_whole_rlib(&mut self, lib: &Path);
|
||||
fn link_whole_staticlib(&mut self, lib: &str, search_path: &[PathBuf]);
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, search_path: &[PathBuf]);
|
||||
fn include_path(&mut self, path: &Path);
|
||||
fn framework_path(&mut self, path: &Path);
|
||||
fn output_filename(&mut self, path: &Path);
|
||||
|
@ -215,9 +216,13 @@ impl<'a> GccLinker<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Linker for GccLinker<'a> {
|
||||
fn link_dylib(&mut self, lib: &str) { self.hint_dynamic(); self.cmd.arg(format!("-l{}", lib)); }
|
||||
fn link_staticlib(&mut self, lib: &str) {
|
||||
self.hint_static(); self.cmd.arg(format!("-l{}", lib));
|
||||
fn link_dylib(&mut self, lib: Symbol) {
|
||||
self.hint_dynamic();
|
||||
self.cmd.arg(format!("-l{}", lib));
|
||||
}
|
||||
fn link_staticlib(&mut self, lib: Symbol) {
|
||||
self.hint_static();
|
||||
self.cmd.arg(format!("-l{}", lib));
|
||||
}
|
||||
fn link_rlib(&mut self, lib: &Path) { self.hint_static(); self.cmd.arg(lib); }
|
||||
fn include_path(&mut self, path: &Path) { self.cmd.arg("-L").arg(path); }
|
||||
|
@ -232,14 +237,14 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
fn build_static_executable(&mut self) { self.cmd.arg("-static"); }
|
||||
fn args(&mut self, args: &[String]) { self.cmd.args(args); }
|
||||
|
||||
fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
|
||||
fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
|
||||
self.hint_dynamic();
|
||||
self.cmd.arg(format!("-l{}", lib));
|
||||
}
|
||||
|
||||
fn link_framework(&mut self, framework: &str) {
|
||||
fn link_framework(&mut self, framework: Symbol) {
|
||||
self.hint_dynamic();
|
||||
self.cmd.arg("-framework").arg(framework);
|
||||
self.cmd.arg("-framework").sym_arg(framework);
|
||||
}
|
||||
|
||||
// Here we explicitly ask that the entire archive is included into the
|
||||
|
@ -248,7 +253,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
// don't otherwise explicitly reference them. This can occur for
|
||||
// libraries which are just providing bindings, libraries with generic
|
||||
// functions, etc.
|
||||
fn link_whole_staticlib(&mut self, lib: &str, search_path: &[PathBuf]) {
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, search_path: &[PathBuf]) {
|
||||
self.hint_static();
|
||||
let target = &self.sess.target.target;
|
||||
if !target.options.is_like_osx {
|
||||
|
@ -539,11 +544,11 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn link_dylib(&mut self, lib: &str) {
|
||||
fn link_dylib(&mut self, lib: Symbol) {
|
||||
self.cmd.arg(&format!("{}.lib", lib));
|
||||
}
|
||||
|
||||
fn link_rust_dylib(&mut self, lib: &str, path: &Path) {
|
||||
fn link_rust_dylib(&mut self, lib: Symbol, path: &Path) {
|
||||
// When producing a dll, the MSVC linker may not actually emit a
|
||||
// `foo.lib` file if the dll doesn't actually export any symbols, so we
|
||||
// check to see if the file is there and just omit linking to it if it's
|
||||
|
@ -554,7 +559,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn link_staticlib(&mut self, lib: &str) {
|
||||
fn link_staticlib(&mut self, lib: Symbol) {
|
||||
self.cmd.arg(&format!("{}.lib", lib));
|
||||
}
|
||||
|
||||
|
@ -605,11 +610,11 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
fn framework_path(&mut self, _path: &Path) {
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
fn link_framework(&mut self, _framework: Symbol) {
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) {
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, _search_path: &[PathBuf]) {
|
||||
// not supported?
|
||||
self.link_staticlib(lib);
|
||||
}
|
||||
|
@ -740,8 +745,8 @@ impl<'a> Linker for EmLinker<'a> {
|
|||
self.cmd.arg("-L").arg(path);
|
||||
}
|
||||
|
||||
fn link_staticlib(&mut self, lib: &str) {
|
||||
self.cmd.arg("-l").arg(lib);
|
||||
fn link_staticlib(&mut self, lib: Symbol) {
|
||||
self.cmd.arg("-l").sym_arg(lib);
|
||||
}
|
||||
|
||||
fn output_filename(&mut self, path: &Path) {
|
||||
|
@ -752,12 +757,12 @@ impl<'a> Linker for EmLinker<'a> {
|
|||
self.cmd.arg(path);
|
||||
}
|
||||
|
||||
fn link_dylib(&mut self, lib: &str) {
|
||||
fn link_dylib(&mut self, lib: Symbol) {
|
||||
// Emscripten always links statically
|
||||
self.link_staticlib(lib);
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) {
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, _search_path: &[PathBuf]) {
|
||||
// not supported?
|
||||
self.link_staticlib(lib);
|
||||
}
|
||||
|
@ -767,7 +772,7 @@ impl<'a> Linker for EmLinker<'a> {
|
|||
self.link_rlib(lib);
|
||||
}
|
||||
|
||||
fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
|
||||
fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
|
||||
self.link_dylib(lib);
|
||||
}
|
||||
|
||||
|
@ -803,7 +808,7 @@ impl<'a> Linker for EmLinker<'a> {
|
|||
bug!("frameworks are not supported on Emscripten")
|
||||
}
|
||||
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
fn link_framework(&mut self, _framework: Symbol) {
|
||||
bug!("frameworks are not supported on Emscripten")
|
||||
}
|
||||
|
||||
|
@ -948,12 +953,12 @@ impl<'a> WasmLd<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Linker for WasmLd<'a> {
|
||||
fn link_dylib(&mut self, lib: &str) {
|
||||
self.cmd.arg("-l").arg(lib);
|
||||
fn link_dylib(&mut self, lib: Symbol) {
|
||||
self.cmd.arg("-l").sym_arg(lib);
|
||||
}
|
||||
|
||||
fn link_staticlib(&mut self, lib: &str) {
|
||||
self.cmd.arg("-l").arg(lib);
|
||||
fn link_staticlib(&mut self, lib: Symbol) {
|
||||
self.cmd.arg("-l").sym_arg(lib);
|
||||
}
|
||||
|
||||
fn link_rlib(&mut self, lib: &Path) {
|
||||
|
@ -995,16 +1000,16 @@ impl<'a> Linker for WasmLd<'a> {
|
|||
self.cmd.args(args);
|
||||
}
|
||||
|
||||
fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
|
||||
self.cmd.arg("-l").arg(lib);
|
||||
fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
|
||||
self.cmd.arg("-l").sym_arg(lib);
|
||||
}
|
||||
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
fn link_framework(&mut self, _framework: Symbol) {
|
||||
panic!("frameworks not supported")
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) {
|
||||
self.cmd.arg("-l").arg(lib);
|
||||
fn link_whole_staticlib(&mut self, lib: Symbol, _search_path: &[PathBuf]) {
|
||||
self.cmd.arg("-l").sym_arg(lib);
|
||||
}
|
||||
|
||||
fn link_whole_rlib(&mut self, lib: &Path) {
|
||||
|
@ -1162,19 +1167,19 @@ impl<'a> Linker for PtxLinker<'a> {
|
|||
::std::mem::replace(&mut self.cmd, Command::new(""))
|
||||
}
|
||||
|
||||
fn link_dylib(&mut self, _lib: &str) {
|
||||
fn link_dylib(&mut self, _lib: Symbol) {
|
||||
panic!("external dylibs not supported")
|
||||
}
|
||||
|
||||
fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) {
|
||||
fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) {
|
||||
panic!("external dylibs not supported")
|
||||
}
|
||||
|
||||
fn link_staticlib(&mut self, _lib: &str) {
|
||||
fn link_staticlib(&mut self, _lib: Symbol) {
|
||||
panic!("staticlibs not supported")
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, _lib: &str, _search_path: &[PathBuf]) {
|
||||
fn link_whole_staticlib(&mut self, _lib: Symbol, _search_path: &[PathBuf]) {
|
||||
panic!("staticlibs not supported")
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1187,7 @@ impl<'a> Linker for PtxLinker<'a> {
|
|||
panic!("frameworks not supported")
|
||||
}
|
||||
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
fn link_framework(&mut self, _framework: Symbol) {
|
||||
panic!("frameworks not supported")
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ use rustc::mir::mono::CodegenUnitNameBuilder;
|
|||
use rustc::ty::TyCtxt;
|
||||
use std::collections::BTreeSet;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Symbol, sym};
|
||||
use syntax::symbol::{InternedString, Symbol, sym};
|
||||
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
|
||||
ATTR_EXPECTED_CGU_REUSE};
|
||||
|
||||
|
@ -45,8 +45,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
|||
.collect_and_partition_mono_items(LOCAL_CRATE)
|
||||
.1
|
||||
.iter()
|
||||
.map(|cgu| format!("{}", cgu.name()))
|
||||
.collect::<BTreeSet<String>>();
|
||||
.map(|cgu| *cgu.name())
|
||||
.collect::<BTreeSet<InternedString>>();
|
||||
|
||||
let ams = AssertModuleSource {
|
||||
tcx,
|
||||
|
@ -61,7 +61,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
|||
|
||||
struct AssertModuleSource<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
available_cgus: BTreeSet<String>,
|
||||
available_cgus: BTreeSet<InternedString>,
|
||||
}
|
||||
|
||||
impl AssertModuleSource<'tcx> {
|
||||
|
@ -127,7 +127,7 @@ impl AssertModuleSource<'tcx> {
|
|||
|
||||
debug!("mapping '{}' to cgu name '{}'", self.field(attr, MODULE), cgu_name);
|
||||
|
||||
if !self.available_cgus.contains(&cgu_name.as_str()[..]) {
|
||||
if !self.available_cgus.contains(&cgu_name) {
|
||||
self.tcx.sess.span_err(attr.span,
|
||||
&format!("no module named `{}` (mangled: {}). \
|
||||
Available modules: {}",
|
||||
|
@ -135,7 +135,7 @@ impl AssertModuleSource<'tcx> {
|
|||
cgu_name,
|
||||
self.available_cgus
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|cgu| cgu.as_str().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")));
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
|
|
|
@ -1462,7 +1462,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
span: Span,
|
||||
type_str: &str,
|
||||
trait_str: &str,
|
||||
name: &str,
|
||||
name: ast::Name,
|
||||
) {
|
||||
let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type");
|
||||
if let (Some(_), Ok(snippet)) = (
|
||||
|
@ -1689,7 +1689,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
span,
|
||||
&qself_ty.to_string(),
|
||||
"Trait",
|
||||
&assoc_ident.as_str(),
|
||||
assoc_ident.name,
|
||||
);
|
||||
}
|
||||
return Err(ErrorReported);
|
||||
|
@ -1762,7 +1762,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
span,
|
||||
"Type",
|
||||
&path_str,
|
||||
&item_segment.ident.as_str(),
|
||||
item_segment.ident.name,
|
||||
);
|
||||
return tcx.types.err;
|
||||
};
|
||||
|
|
|
@ -81,10 +81,10 @@ impl Cfg {
|
|||
},
|
||||
MetaItemKind::List(ref items) => {
|
||||
let mut sub_cfgs = items.iter().map(Cfg::parse_nested);
|
||||
match &*name.as_str() {
|
||||
"all" => sub_cfgs.fold(Ok(Cfg::True), |x, y| Ok(x? & y?)),
|
||||
"any" => sub_cfgs.fold(Ok(Cfg::False), |x, y| Ok(x? | y?)),
|
||||
"not" => if sub_cfgs.len() == 1 {
|
||||
match name {
|
||||
sym::all => sub_cfgs.fold(Ok(Cfg::True), |x, y| Ok(x? & y?)),
|
||||
sym::any => sub_cfgs.fold(Ok(Cfg::False), |x, y| Ok(x? | y?)),
|
||||
sym::not => if sub_cfgs.len() == 1 {
|
||||
Ok(!sub_cfgs.next().unwrap()?)
|
||||
} else {
|
||||
Err(InvalidCfgError {
|
||||
|
|
|
@ -1039,7 +1039,7 @@ impl GenericBound {
|
|||
fn maybe_sized(cx: &DocContext<'_>) -> GenericBound {
|
||||
let did = cx.tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
|
||||
let empty = cx.tcx.intern_substs(&[]);
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
|
||||
let path = external_path(cx, cx.tcx.item_name(did),
|
||||
Some(did), false, vec![], empty);
|
||||
inline::record_extern_fqn(cx, did, TypeKind::Trait);
|
||||
GenericBound::TraitBound(PolyTrait {
|
||||
|
@ -1138,13 +1138,13 @@ fn external_generic_args(
|
|||
|
||||
// trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar
|
||||
// from Fn<(A, B,), C> to Fn(A, B) -> C
|
||||
fn external_path(cx: &DocContext<'_>, name: &str, trait_did: Option<DefId>, has_self: bool,
|
||||
fn external_path(cx: &DocContext<'_>, name: Symbol, trait_did: Option<DefId>, has_self: bool,
|
||||
bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> Path {
|
||||
Path {
|
||||
global: false,
|
||||
res: Res::Err,
|
||||
segments: vec![PathSegment {
|
||||
name: name.to_string(),
|
||||
name: name.as_str().to_string(),
|
||||
args: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
||||
}],
|
||||
}
|
||||
|
@ -1154,7 +1154,7 @@ impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
|
|||
fn clean(&self, cx: &DocContext<'_>) -> GenericBound {
|
||||
let (trait_ref, ref bounds) = *self;
|
||||
inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait);
|
||||
let path = external_path(cx, &cx.tcx.item_name(trait_ref.def_id).as_str(),
|
||||
let path = external_path(cx, cx.tcx.item_name(trait_ref.def_id),
|
||||
Some(trait_ref.def_id), true, bounds.clone(), trait_ref.substs);
|
||||
|
||||
debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
|
||||
|
@ -3089,8 +3089,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
AdtKind::Enum => TypeKind::Enum,
|
||||
};
|
||||
inline::record_extern_fqn(cx, did, kind);
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
|
||||
None, false, vec![], substs);
|
||||
let path = external_path(cx, cx.tcx.item_name(did), None, false, vec![], substs);
|
||||
ResolvedPath {
|
||||
path,
|
||||
param_names: None,
|
||||
|
@ -3100,7 +3099,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
}
|
||||
ty::Foreign(did) => {
|
||||
inline::record_extern_fqn(cx, did, TypeKind::Foreign);
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
|
||||
let path = external_path(cx, cx.tcx.item_name(did),
|
||||
None, false, vec![], InternalSubsts::empty());
|
||||
ResolvedPath {
|
||||
path: path,
|
||||
|
@ -3129,7 +3128,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
reg.clean(cx).map(|b| param_names.push(GenericBound::Outlives(b)));
|
||||
for did in dids {
|
||||
let empty = cx.tcx.intern_substs(&[]);
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
|
||||
let path = external_path(cx, cx.tcx.item_name(did),
|
||||
Some(did), false, vec![], empty);
|
||||
inline::record_extern_fqn(cx, did, TypeKind::Trait);
|
||||
let bound = GenericBound::TraitBound(PolyTrait {
|
||||
|
@ -3154,7 +3153,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
});
|
||||
}
|
||||
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(), Some(did),
|
||||
let path = external_path(cx, cx.tcx.item_name(did), Some(did),
|
||||
false, bindings, substs);
|
||||
ResolvedPath {
|
||||
path,
|
||||
|
|
|
@ -423,7 +423,7 @@ pub fn make_test(s: &str,
|
|||
Ok(Some(item)) => {
|
||||
if !found_main {
|
||||
if let ast::ItemKind::Fn(..) = item.node {
|
||||
if item.ident.as_str() == "main" {
|
||||
if item.ident.name == sym::main {
|
||||
found_main = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue