mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Auto merge of #66143 - Centril:rollup-qmzuex0, r=Centril
Rollup of 9 pull requests Successful merges: - #65776 (Rename `LocalInternedString` and more) - #65973 (caller_location: point to macro invocation sites, like file!/line!, and use in core::panic!.) - #66015 (librustc_lexer: Refactor the module) - #66062 (Configure LLVM module PIC level) - #66086 (bump smallvec to 1.0) - #66092 (Use KERN_ARND syscall for random numbers on NetBSD, same as FreeBSD.) - #66103 (Add target thumbv7neon-unknown-linux-musleabihf) - #66133 (Update the bundled `wasi-libc` repository) - #66139 (use American spelling for `pluralize!`) Failed merges: r? @ghost
This commit is contained in:
+31
-25
@@ -68,7 +68,7 @@ name = "arena"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"rustc_data_structures",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -487,7 +487,7 @@ dependencies = [
|
||||
"regex-syntax",
|
||||
"semver",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
"toml",
|
||||
"unicode-normalization",
|
||||
"url 2.1.0",
|
||||
@@ -655,7 +655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b"
|
||||
dependencies = [
|
||||
"crossbeam-utils 0.6.5",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2392,7 +2392,7 @@ dependencies = [
|
||||
"libc",
|
||||
"rand 0.6.1",
|
||||
"rustc_version",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
"winapi 0.3.6",
|
||||
]
|
||||
|
||||
@@ -2407,7 +2407,7 @@ dependencies = [
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"rustc_version",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
"winapi 0.3.6",
|
||||
]
|
||||
|
||||
@@ -3135,7 +3135,7 @@ dependencies = [
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
]
|
||||
@@ -3147,7 +3147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a623fd4805842e9bd0bb6e6dace63efede0ee22de4522a0b03b7c3d15a22f009"
|
||||
dependencies = [
|
||||
"rustc-ap-rustc_data_structures",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3176,7 +3176,7 @@ dependencies = [
|
||||
"rustc-hash",
|
||||
"rustc-rayon 0.2.0",
|
||||
"rustc-rayon-core 0.2.0",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
@@ -3204,7 +3204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "457a5c204ae2fdaa5bdb5b196e58ca59896870d80445fe423063c9453496e3ea"
|
||||
dependencies = [
|
||||
"rustc-ap-serialize",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3250,7 +3250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92679240e86f4583cc05f8dcf6439bdab87bac9e6555718469176de9bd52ba20"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3270,7 +3270,7 @@ dependencies = [
|
||||
"rustc-ap-serialize",
|
||||
"rustc-ap-syntax_pos",
|
||||
"scoped-tls",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3393,7 +3393,7 @@ dependencies = [
|
||||
"crossbeam-utils 0.6.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smallvec",
|
||||
"smallvec 0.6.10",
|
||||
"syn 0.15.35",
|
||||
"url 2.1.0",
|
||||
"winapi 0.3.6",
|
||||
@@ -3404,7 +3404,7 @@ name = "rustc_apfloat"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3484,7 +3484,7 @@ dependencies = [
|
||||
"rustc-rayon-core 0.3.0",
|
||||
"rustc_index",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
@@ -3552,7 +3552,7 @@ name = "rustc_index"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3579,7 +3579,7 @@ dependencies = [
|
||||
"rustc_traits",
|
||||
"rustc_typeck",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_expand",
|
||||
"syntax_ext",
|
||||
@@ -3650,7 +3650,7 @@ dependencies = [
|
||||
"rustc_index",
|
||||
"rustc_target",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"stable_deref_trait",
|
||||
"syntax",
|
||||
"syntax_expand",
|
||||
@@ -3675,7 +3675,7 @@ dependencies = [
|
||||
"rustc_lexer",
|
||||
"rustc_target",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
]
|
||||
@@ -3746,7 +3746,7 @@ dependencies = [
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_metadata",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_expand",
|
||||
"syntax_pos",
|
||||
@@ -3799,7 +3799,7 @@ dependencies = [
|
||||
"rustc",
|
||||
"rustc_data_structures",
|
||||
"rustc_target",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
]
|
||||
@@ -3826,7 +3826,7 @@ dependencies = [
|
||||
"rustc_errors",
|
||||
"rustc_index",
|
||||
"rustc_target",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
]
|
||||
@@ -4070,7 +4070,7 @@ name = "serialize"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4134,6 +4134,12 @@ version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.3.8"
|
||||
@@ -4359,7 +4365,7 @@ dependencies = [
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax_pos",
|
||||
]
|
||||
|
||||
@@ -4377,7 +4383,7 @@ dependencies = [
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serialize",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
]
|
||||
@@ -4391,7 +4397,7 @@ dependencies = [
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_target",
|
||||
"smallvec",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_expand",
|
||||
"syntax_pos",
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
set -ex
|
||||
|
||||
# Originally from https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
||||
curl https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \
|
||||
# Originally from https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
||||
curl https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/clang%2Bllvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \
|
||||
tar xJf -
|
||||
export PATH=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
|
||||
export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
|
||||
|
||||
git clone https://github.com/CraneStation/wasi-sysroot
|
||||
git clone https://github.com/CraneStation/wasi-libc
|
||||
|
||||
cd wasi-sysroot
|
||||
git reset --hard e5f14be38362f1ab83302895a6e74b2ffd0e2302
|
||||
cd wasi-libc
|
||||
git reset --hard a94d2d04e7722b323573da2bd04e909a5763d35b
|
||||
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install
|
||||
|
||||
cd ..
|
||||
rm -rf reference-sysroot-wasi
|
||||
rm -rf wasi-libc
|
||||
rm -rf clang+llvm*
|
||||
|
||||
@@ -10,4 +10,4 @@ path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
+15
-17
@@ -26,31 +26,29 @@ macro_rules! panic {
|
||||
/// For details, see `std::macros`.
|
||||
#[cfg(not(bootstrap))]
|
||||
#[macro_export]
|
||||
#[allow_internal_unstable(core_panic, panic_internals)]
|
||||
#[allow_internal_unstable(core_panic,
|
||||
// FIXME(anp, eddyb) `core_intrinsics` is used here to allow calling
|
||||
// the `caller_location` intrinsic, but once `#[track_caller]` is implemented,
|
||||
// `panicking::{panic, panic_fmt}` can use that instead of a `Location` argument.
|
||||
core_intrinsics,
|
||||
)]
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
macro_rules! panic {
|
||||
() => (
|
||||
$crate::panic!("explicit panic")
|
||||
);
|
||||
($msg:expr) => ({
|
||||
const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor(
|
||||
$crate::file!(),
|
||||
$crate::line!(),
|
||||
$crate::column!(),
|
||||
);
|
||||
$crate::panicking::panic($msg, LOC)
|
||||
});
|
||||
($msg:expr) => (
|
||||
$crate::panicking::panic($msg, $crate::intrinsics::caller_location())
|
||||
);
|
||||
($msg:expr,) => (
|
||||
$crate::panic!($msg)
|
||||
);
|
||||
($fmt:expr, $($arg:tt)+) => ({
|
||||
const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor(
|
||||
$crate::file!(),
|
||||
$crate::line!(),
|
||||
$crate::column!(),
|
||||
);
|
||||
$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+), LOC)
|
||||
});
|
||||
($fmt:expr, $($arg:tt)+) => (
|
||||
$crate::panicking::panic_fmt(
|
||||
$crate::format_args!($fmt, $($arg)+),
|
||||
$crate::intrinsics::caller_location(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// Asserts that two expressions are equal to each other (using [`PartialEq`]).
|
||||
|
||||
@@ -39,5 +39,5 @@ parking_lot = "0.9"
|
||||
byteorder = { version = "1.3" }
|
||||
chalk-engine = { version = "0.9.0", default-features=false }
|
||||
rustc_fs_util = { path = "../librustc_fs_util" }
|
||||
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
measureme = "0.4"
|
||||
|
||||
@@ -304,7 +304,7 @@ unsafe fn alloc_from_iter<T, I: IntoIterator<Item = T>>(&self, iter: I) -> &mut
|
||||
// Move the content to the arena by copying it and then forgetting
|
||||
// the content of the SmallVec
|
||||
vec.as_ptr().copy_to_nonoverlapping(start_ptr, len);
|
||||
mem::forget(vec.drain());
|
||||
mem::forget(vec.drain(..));
|
||||
|
||||
// Record the destructors after doing the allocation as that may panic
|
||||
// and would cause `object`'s destuctor to run twice if it was recorded before
|
||||
|
||||
@@ -525,7 +525,7 @@ fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint {
|
||||
}
|
||||
|
||||
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
|
||||
tcx.crate_name(*self).as_str().to_string()
|
||||
tcx.crate_name(*self).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3382,7 +3382,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
|
||||
// either in std or core, i.e. has either a `::std::ops::Range` or
|
||||
// `::core::ops::Range` prefix.
|
||||
fn is_range_path(path: &Path) -> bool {
|
||||
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.as_str().to_string()).collect();
|
||||
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.to_string()).collect();
|
||||
let segs: Vec<_> = segs.iter().map(|seg| &**seg).collect();
|
||||
|
||||
// "{{root}}" is the equivalent of `::` prefix in `Path`.
|
||||
@@ -3423,7 +3423,7 @@ fn is_lit(sess: &Session, span: &Span) -> bool {
|
||||
ExprKind::Call(ref func, _) => {
|
||||
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
|
||||
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.kind {
|
||||
let new_call = segment.ident.as_str() == "new";
|
||||
let new_call = segment.ident.name == sym::new;
|
||||
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ pub fn print_item(&mut self, item: &hir::Item) {
|
||||
}
|
||||
hir::ItemKind::GlobalAsm(ref ga) => {
|
||||
self.head(visibility_qualified(&item.vis, "global asm"));
|
||||
self.s.word(ga.asm.as_str().to_string());
|
||||
self.s.word(ga.asm.to_string());
|
||||
self.end()
|
||||
}
|
||||
hir::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||
@@ -1855,7 +1855,7 @@ pub fn print_fn(&mut self,
|
||||
self.commasep(Inconsistent, &decl.inputs, |s, ty| {
|
||||
s.ibox(INDENT_UNIT);
|
||||
if let Some(arg_name) = arg_names.get(i) {
|
||||
s.s.word(arg_name.as_str().to_string());
|
||||
s.s.word(arg_name.to_string());
|
||||
s.s.word(":");
|
||||
s.s.space();
|
||||
} else if let Some(body_id) = body_id {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use syntax::ast;
|
||||
use syntax::feature_gate;
|
||||
use syntax::parse::token;
|
||||
use syntax::symbol::LocalInternedString;
|
||||
use syntax::symbol::SymbolStr;
|
||||
use syntax::tokenstream;
|
||||
use syntax_pos::SourceFile;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
use smallvec::SmallVec;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for LocalInternedString {
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for SymbolStr {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let str = self as &str;
|
||||
@@ -26,13 +26,13 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for LocalInternedString {
|
||||
type KeyType = LocalInternedString;
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for SymbolStr {
|
||||
type KeyType = SymbolStr;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self,
|
||||
_: &StableHashingContext<'a>)
|
||||
-> LocalInternedString {
|
||||
-> SymbolStr {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
@@ -45,12 +45,12 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
|
||||
type KeyType = LocalInternedString;
|
||||
type KeyType = SymbolStr;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self,
|
||||
_: &StableHashingContext<'a>)
|
||||
-> LocalInternedString {
|
||||
-> SymbolStr {
|
||||
self.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use crate::lint::{LintPass, LateLintPass, LintArray, FutureIncompatibleInfo};
|
||||
use crate::middle::stability;
|
||||
use crate::session::Session;
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use syntax::ast;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::source_map::Span;
|
||||
@@ -651,7 +651,7 @@ pub(crate) fn add_elided_lifetime_in_path_suggestion(
|
||||
};
|
||||
db.span_suggestion(
|
||||
replace_span,
|
||||
&format!("indicate the anonymous lifetime{}", pluralise!(n)),
|
||||
&format!("indicate the anonymous lifetime{}", pluralize!(n)),
|
||||
suggestion,
|
||||
Applicability::MachineApplicable
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use crate::rustc::lint;
|
||||
use crate::session::Session;
|
||||
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, HirIdSet};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use rustc_macros::HashStable;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
@@ -3044,7 +3044,7 @@ pub fn report_missing_lifetime_specifiers(
|
||||
span,
|
||||
E0106,
|
||||
"missing lifetime specifier{}",
|
||||
pluralise!(count)
|
||||
pluralize!(count)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -486,7 +486,7 @@ pub fn build_cgu_name<I, C, S>(&mut self,
|
||||
if self.tcx.sess.opts.debugging_opts.human_readable_cgu_names {
|
||||
cgu_name
|
||||
} else {
|
||||
let cgu_name = &cgu_name.as_str()[..];
|
||||
let cgu_name = &cgu_name.as_str();
|
||||
Symbol::intern(&CodegenUnit::mangle_name(cgu_name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
use crate::ty::SubtypePredicate;
|
||||
use crate::util::nodemap::{FxHashMap, FxHashSet};
|
||||
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{sym, kw};
|
||||
@@ -1130,7 +1130,7 @@ fn suggest_restricting_param_bound(
|
||||
let restrict_msg = "consider further restricting this bound";
|
||||
let param_name = self_ty.to_string();
|
||||
for param in generics.params.iter().filter(|p| {
|
||||
¶m_name == std::convert::AsRef::<str>::as_ref(&p.name.ident().as_str())
|
||||
p.name.ident().as_str() == param_name
|
||||
}) {
|
||||
if param_name.starts_with("impl ") {
|
||||
// `impl Trait` in argument:
|
||||
@@ -1553,7 +1553,7 @@ pub fn report_arg_count_mismatch(
|
||||
_ => format!("{} {}argument{}",
|
||||
arg_length,
|
||||
if distinct && arg_length > 1 { "distinct " } else { "" },
|
||||
pluralise!(arg_length))
|
||||
pluralize!(arg_length))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ pub fn evaluate(
|
||||
c.ident().map_or(false, |ident| {
|
||||
options.contains(&(
|
||||
ident.name,
|
||||
c.value_str().map(|s| s.as_str().to_string())
|
||||
c.value_str().map(|s| s.to_string())
|
||||
))
|
||||
})
|
||||
}) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use std::fmt;
|
||||
use rustc_target::spec::abi;
|
||||
use syntax::ast;
|
||||
use syntax::errors::pluralise;
|
||||
use syntax::errors::pluralize;
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use syntax_pos::Span;
|
||||
|
||||
@@ -100,17 +100,17 @@ fn report_maybe_different(f: &mut fmt::Formatter<'_>,
|
||||
write!(f, "expected a tuple with {} element{}, \
|
||||
found one with {} element{}",
|
||||
values.expected,
|
||||
pluralise!(values.expected),
|
||||
pluralize!(values.expected),
|
||||
values.found,
|
||||
pluralise!(values.found))
|
||||
pluralize!(values.found))
|
||||
}
|
||||
FixedArraySize(values) => {
|
||||
write!(f, "expected an array with a fixed size of {} element{}, \
|
||||
found one with {} element{}",
|
||||
values.expected,
|
||||
pluralise!(values.expected),
|
||||
pluralize!(values.expected),
|
||||
values.found,
|
||||
pluralise!(values.found))
|
||||
pluralize!(values.found))
|
||||
}
|
||||
ArgCount => {
|
||||
write!(f, "incorrect number of function parameters")
|
||||
@@ -165,7 +165,7 @@ fn report_maybe_different(f: &mut fmt::Formatter<'_>,
|
||||
ProjectionBoundsLength(ref values) => {
|
||||
write!(f, "expected {} associated type binding{}, found {}",
|
||||
values.expected,
|
||||
pluralise!(values.expected),
|
||||
pluralize!(values.expected),
|
||||
values.found)
|
||||
},
|
||||
ExistentialMismatch(ref values) => {
|
||||
@@ -196,7 +196,7 @@ pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
let n = tcx.lift(&n).unwrap();
|
||||
match n.try_eval_usize(tcx, ty::ParamEnv::empty()) {
|
||||
Some(n) => {
|
||||
format!("array of {} element{}", n, pluralise!(n)).into()
|
||||
format!("array of {} element{}", n, pluralize!(n)).into()
|
||||
}
|
||||
None => "array".into(),
|
||||
}
|
||||
|
||||
@@ -76,19 +76,19 @@ pub fn intersection<I>(tcx: TyCtxt<'tcx>, iter: I) -> DefIdForest
|
||||
break;
|
||||
}
|
||||
|
||||
for id in ret.root_ids.drain() {
|
||||
for id in ret.root_ids.drain(..) {
|
||||
if next_forest.contains(tcx, id) {
|
||||
next_ret.push(id);
|
||||
} else {
|
||||
old_ret.push(id);
|
||||
}
|
||||
}
|
||||
ret.root_ids.extend(old_ret.drain());
|
||||
ret.root_ids.extend(old_ret.drain(..));
|
||||
|
||||
next_ret.extend(next_forest.root_ids.into_iter().filter(|&id| ret.contains(tcx, id)));
|
||||
|
||||
mem::swap(&mut next_ret, &mut ret.root_ids);
|
||||
next_ret.drain();
|
||||
next_ret.drain(..);
|
||||
}
|
||||
ret
|
||||
}
|
||||
@@ -101,7 +101,7 @@ pub fn union<I>(tcx: TyCtxt<'tcx>, iter: I) -> DefIdForest
|
||||
let mut ret = DefIdForest::empty();
|
||||
let mut next_ret = SmallVec::new();
|
||||
for next_forest in iter {
|
||||
next_ret.extend(ret.root_ids.drain().filter(|&id| !next_forest.contains(tcx, id)));
|
||||
next_ret.extend(ret.root_ids.drain(..).filter(|&id| !next_forest.contains(tcx, id)));
|
||||
|
||||
for id in next_forest.root_ids {
|
||||
if !next_ret.contains(&id) {
|
||||
@@ -110,7 +110,7 @@ pub fn union<I>(tcx: TyCtxt<'tcx>, iter: I) -> DefIdForest
|
||||
}
|
||||
|
||||
mem::swap(&mut next_ret, &mut ret.root_ids);
|
||||
next_ret.drain();
|
||||
next_ret.drain(..);
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ macro_rules! encode_queries {
|
||||
let sorted_cnums = sorted_cnums_including_local_crate(tcx);
|
||||
let prev_cnums: Vec<_> = sorted_cnums.iter()
|
||||
.map(|&cnum| {
|
||||
let crate_name = tcx.original_crate_name(cnum).as_str().to_string();
|
||||
let crate_name = tcx.original_crate_name(cnum).to_string();
|
||||
let crate_disambiguator = tcx.crate_disambiguator(cnum);
|
||||
(cnum.as_u32(), crate_name, crate_disambiguator)
|
||||
})
|
||||
|
||||
@@ -10,4 +10,4 @@ path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -314,7 +314,7 @@ pub fn from_fn_attrs(
|
||||
codegen_fn_attrs.target_features
|
||||
.iter()
|
||||
.map(|f| {
|
||||
let feature = &*f.as_str();
|
||||
let feature = &f.as_str();
|
||||
format!("+{}", llvm_util::to_llvm_feature(cx.tcx.sess, feature))
|
||||
})
|
||||
)
|
||||
|
||||
@@ -203,6 +203,10 @@ pub unsafe fn create_module(
|
||||
let llvm_target = SmallCStr::new(&sess.target.target.llvm_target);
|
||||
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
|
||||
|
||||
if get_reloc_model(sess) == llvm::RelocMode::PIC {
|
||||
llvm::LLVMRustSetModulePICLevel(llmod);
|
||||
}
|
||||
|
||||
if is_pie_binary(sess) {
|
||||
llvm::LLVMRustSetModulePIELevel(llmod);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||
});
|
||||
|
||||
let namespace_name = match def_key.disambiguated_data.data {
|
||||
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate).as_str(),
|
||||
data => data.as_symbol().as_str()
|
||||
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate),
|
||||
data => data.as_symbol()
|
||||
};
|
||||
|
||||
let namespace_name = SmallCStr::new(&namespace_name);
|
||||
let namespace_name = SmallCStr::new(&namespace_name.as_str());
|
||||
|
||||
let scope = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateNameSpace(
|
||||
|
||||
@@ -1807,6 +1807,7 @@ pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
|
||||
|
||||
pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
|
||||
pub fn LLVMRustUnsetComdat(V: &Value);
|
||||
pub fn LLVMRustSetModulePICLevel(M: &Module);
|
||||
pub fn LLVMRustSetModulePIELevel(M: &Module);
|
||||
pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
|
||||
pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
|
||||
}
|
||||
|
||||
pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
|
||||
self.arg(&arg.as_str());
|
||||
self.arg(&*arg.as_str());
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -129,9 +129,9 @@ fn reachable_non_generics_provider(
|
||||
//
|
||||
// In general though we won't link right if these
|
||||
// symbols are stripped, and LTO currently strips them.
|
||||
if &*name == "rust_eh_personality" ||
|
||||
&*name == "rust_eh_register_frames" ||
|
||||
&*name == "rust_eh_unregister_frames" {
|
||||
if name == "rust_eh_personality" ||
|
||||
name == "rust_eh_register_frames" ||
|
||||
name == "rust_eh_unregister_frames" {
|
||||
SymbolExportLevel::C
|
||||
} else {
|
||||
SymbolExportLevel::Rust
|
||||
|
||||
@@ -552,8 +552,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
} else if let Some(kind) = *tcx.sess.allocator_kind.get() {
|
||||
let llmod_id = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||
&["crate"],
|
||||
Some("allocator")).as_str()
|
||||
.to_string();
|
||||
Some("allocator")).to_string();
|
||||
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
||||
time(tcx.sess, "write allocator module", || {
|
||||
backend.codegen_allocator(tcx, &mut modules, kind)
|
||||
@@ -576,8 +575,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
// Codegen the encoded metadata.
|
||||
let metadata_cgu_name = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||
&["crate"],
|
||||
Some("metadata")).as_str()
|
||||
.to_string();
|
||||
Some("metadata")).to_string();
|
||||
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
||||
time(tcx.sess, "write compressed metadata", || {
|
||||
backend.write_compressed_metadata(tcx, &ongoing_codegen.metadata,
|
||||
|
||||
@@ -995,7 +995,8 @@ fn get_caller_location(
|
||||
bx: &mut Bx,
|
||||
span: Span,
|
||||
) -> OperandRef<'tcx, Bx::Value> {
|
||||
let caller = bx.tcx().sess.source_map().lookup_char_pos(span.lo());
|
||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
|
||||
let const_loc = bx.tcx().const_caller_location((
|
||||
Symbol::intern(&caller.file.name.to_string()),
|
||||
caller.line as u32,
|
||||
|
||||
@@ -121,9 +121,10 @@ fn get_symbol_hash<'tcx>(
|
||||
substs.hash_stable(&mut hcx, &mut hasher);
|
||||
|
||||
if let Some(instantiating_crate) = instantiating_crate {
|
||||
(&tcx.original_crate_name(instantiating_crate).as_str()[..])
|
||||
tcx.original_crate_name(instantiating_crate).as_str()
|
||||
.hash_stable(&mut hcx, &mut hasher);
|
||||
tcx.crate_disambiguator(instantiating_crate)
|
||||
.hash_stable(&mut hcx, &mut hasher);
|
||||
(&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher);
|
||||
}
|
||||
|
||||
// We want to avoid accidental collision between different types of instances.
|
||||
|
||||
@@ -23,7 +23,7 @@ stable_deref_trait = "1.0.0"
|
||||
rayon = { version = "0.3.0", package = "rustc-rayon" }
|
||||
rayon-core = { version = "0.3.0", package = "rustc-rayon-core" }
|
||||
rustc-hash = "1.0.1"
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
rustc_index = { path = "../librustc_index", package = "rustc_index" }
|
||||
|
||||
[dependencies.parking_lot]
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
use syntax_pos::{SourceFile, Span, MultiSpan};
|
||||
|
||||
use crate::{
|
||||
Level, CodeSuggestion, Diagnostic, SubDiagnostic, pluralise,
|
||||
Level, CodeSuggestion, Diagnostic, SubDiagnostic, pluralize,
|
||||
SuggestionStyle, SourceMapper, SourceMapperDyn, DiagnosticId,
|
||||
};
|
||||
use crate::Level::Error;
|
||||
@@ -1581,7 +1581,7 @@ fn emit_suggestion_default(
|
||||
}
|
||||
if suggestions.len() > MAX_SUGGESTIONS {
|
||||
let others = suggestions.len() - MAX_SUGGESTIONS;
|
||||
let msg = format!("and {} other candidate{}", others, pluralise!(others));
|
||||
let msg = format!("and {} other candidate{}", others, pluralize!(others));
|
||||
buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);
|
||||
} else if notice_capitalization {
|
||||
let msg = "notice the capitalization difference";
|
||||
|
||||
@@ -1027,7 +1027,7 @@ pub fn is_failure_note(&self) -> bool {
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! pluralise {
|
||||
macro_rules! pluralize {
|
||||
($x:expr) => {
|
||||
if $x != 1 { "s" } else { "" }
|
||||
};
|
||||
|
||||
@@ -31,10 +31,6 @@
|
||||
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
|
||||
ATTR_EXPECTED_CGU_REUSE};
|
||||
|
||||
const MODULE: Symbol = sym::module;
|
||||
const CFG: Symbol = sym::cfg;
|
||||
const KIND: Symbol = sym::kind;
|
||||
|
||||
pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
if tcx.sess.opts.incremental.is_none() {
|
||||
@@ -71,7 +67,7 @@ fn check_attr(&self, attr: &ast::Attribute) {
|
||||
} else if attr.check_name(ATTR_PARTITION_CODEGENED) {
|
||||
(CguReuse::No, ComparisonKind::Exact)
|
||||
} else if attr.check_name(ATTR_EXPECTED_CGU_REUSE) {
|
||||
match &self.field(attr, KIND).as_str()[..] {
|
||||
match &*self.field(attr, sym::kind).as_str() {
|
||||
"no" => (CguReuse::No, ComparisonKind::Exact),
|
||||
"pre-lto" => (CguReuse::PreLto, ComparisonKind::Exact),
|
||||
"post-lto" => (CguReuse::PostLto, ComparisonKind::Exact),
|
||||
@@ -98,8 +94,8 @@ fn check_attr(&self, attr: &ast::Attribute) {
|
||||
return;
|
||||
}
|
||||
|
||||
let user_path = self.field(attr, MODULE).as_str().to_string();
|
||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).as_str().to_string();
|
||||
let user_path = self.field(attr, sym::module).to_string();
|
||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string();
|
||||
|
||||
if !user_path.starts_with(&crate_name) {
|
||||
let msg = format!("Found malformed codegen unit name `{}`. \
|
||||
@@ -125,7 +121,7 @@ fn check_attr(&self, attr: &ast::Attribute) {
|
||||
cgu_path_components,
|
||||
cgu_special_suffix);
|
||||
|
||||
debug!("mapping '{}' to cgu name '{}'", self.field(attr, MODULE), cgu_name);
|
||||
debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name);
|
||||
|
||||
if !self.available_cgus.contains(&cgu_name) {
|
||||
self.tcx.sess.span_err(attr.span,
|
||||
@@ -135,7 +131,7 @@ fn check_attr(&self, attr: &ast::Attribute) {
|
||||
cgu_name,
|
||||
self.available_cgus
|
||||
.iter()
|
||||
.map(|cgu| cgu.as_str().to_string())
|
||||
.map(|cgu| cgu.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")));
|
||||
}
|
||||
@@ -169,7 +165,7 @@ fn field(&self, attr: &ast::Attribute, name: Symbol) -> ast::Name {
|
||||
/// cfg flag called `foo`.
|
||||
fn check_config(&self, attr: &ast::Attribute) -> bool {
|
||||
let config = &self.tcx.sess.parse_sess.config;
|
||||
let value = self.field(attr, CFG);
|
||||
let value = self.field(attr, sym::cfg);
|
||||
debug!("check_config(config={:?}, value={:?})", config, value);
|
||||
if config.iter().any(|&(name, _)| name == value) {
|
||||
debug!("check_config: matched");
|
||||
|
||||
@@ -303,7 +303,7 @@ fn labels(&self, attr: &Attribute) -> Option<Labels> {
|
||||
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
||||
if item.check_name(LABEL) {
|
||||
let value = expect_associated_value(self.tcx, &item);
|
||||
return Some(self.resolve_labels(&item, value.as_str().as_ref()));
|
||||
return Some(self.resolve_labels(&item, &value.as_str()));
|
||||
}
|
||||
}
|
||||
None
|
||||
@@ -314,7 +314,7 @@ fn except(&self, attr: &Attribute) -> Labels {
|
||||
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
||||
if item.check_name(EXCEPT) {
|
||||
let value = expect_associated_value(self.tcx, &item);
|
||||
return self.resolve_labels(&item, value.as_str().as_ref());
|
||||
return self.resolve_labels(&item, &value.as_str());
|
||||
}
|
||||
}
|
||||
// if no `label` or `except` is given, only the node's group are asserted
|
||||
|
||||
@@ -11,4 +11,4 @@ doctest = false
|
||||
|
||||
[dependencies]
|
||||
rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -12,7 +12,7 @@ doctest = false
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
rayon = { version = "0.3.0", package = "rustc-rayon" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_ext = { path = "../libsyntax_ext" }
|
||||
syntax_expand = { path = "../libsyntax_expand" }
|
||||
|
||||
@@ -41,10 +41,20 @@ pub(crate) fn prev(&self) -> char {
|
||||
/// If requested position doesn't exist, `EOF_CHAR` is returned.
|
||||
/// However, getting `EOF_CHAR` doesn't always mean actual end of file,
|
||||
/// it should be checked with `is_eof` method.
|
||||
pub(crate) fn nth_char(&self, n: usize) -> char {
|
||||
fn nth_char(&self, n: usize) -> char {
|
||||
self.chars().nth(n).unwrap_or(EOF_CHAR)
|
||||
}
|
||||
|
||||
/// Peeks the next symbol from the input stream without consuming it.
|
||||
pub(crate) fn first(&self) -> char {
|
||||
self.nth_char(0)
|
||||
}
|
||||
|
||||
/// Peeks the second symbol from the input stream without consuming it.
|
||||
pub(crate) fn second(&self) -> char {
|
||||
self.nth_char(1)
|
||||
}
|
||||
|
||||
/// Checks if there is nothing more to consume.
|
||||
pub(crate) fn is_eof(&self) -> bool {
|
||||
self.chars.as_str().is_empty()
|
||||
|
||||
+150
-123
@@ -18,6 +18,8 @@
|
||||
pub mod unescape;
|
||||
|
||||
use crate::cursor::{Cursor, EOF_CHAR};
|
||||
use self::TokenKind::*;
|
||||
use self::LiteralKind::*;
|
||||
|
||||
/// Parsed token.
|
||||
/// It doesn't contain information about data that has been parsed,
|
||||
@@ -116,7 +118,6 @@ pub enum TokenKind {
|
||||
/// Unknown token, not expected by the lexer, e.g. "№"
|
||||
Unknown,
|
||||
}
|
||||
use self::TokenKind::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum LiteralKind {
|
||||
@@ -137,7 +138,6 @@ pub enum LiteralKind {
|
||||
/// "br"abc"", "br#"abc"#", "br####"ab"###"c"####", "br#"a"
|
||||
RawByteStr { n_hashes: usize, started: bool, terminated: bool },
|
||||
}
|
||||
use self::LiteralKind::*;
|
||||
|
||||
/// Base of numeric literal encoding according to its prefix.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
@@ -241,14 +241,13 @@ pub fn is_id_continue(c: char) -> bool {
|
||||
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_continue(c))
|
||||
}
|
||||
|
||||
|
||||
impl Cursor<'_> {
|
||||
/// Parses a token from the input string.
|
||||
fn advance_token(&mut self) -> Token {
|
||||
let first_char = self.bump().unwrap();
|
||||
let token_kind = match first_char {
|
||||
// Slash, comment or block comment.
|
||||
'/' => match self.nth_char(0) {
|
||||
'/' => match self.first() {
|
||||
'/' => self.line_comment(),
|
||||
'*' => self.block_comment(),
|
||||
_ => Slash,
|
||||
@@ -257,8 +256,8 @@ fn advance_token(&mut self) -> Token {
|
||||
// Whitespace sequence.
|
||||
c if is_whitespace(c) => self.whitespace(),
|
||||
|
||||
// Raw string literal or identifier.
|
||||
'r' => match (self.nth_char(0), self.nth_char(1)) {
|
||||
// Raw identifier, raw string literal or identifier.
|
||||
'r' => match (self.first(), self.second()) {
|
||||
('#', c1) if is_id_start(c1) => self.raw_ident(),
|
||||
('#', _) | ('"', _) => {
|
||||
let (n_hashes, started, terminated) = self.raw_double_quoted_string();
|
||||
@@ -273,7 +272,7 @@ fn advance_token(&mut self) -> Token {
|
||||
},
|
||||
|
||||
// Byte literal, byte string literal, raw byte string literal or identifier.
|
||||
'b' => match (self.nth_char(0), self.nth_char(1)) {
|
||||
'b' => match (self.first(), self.second()) {
|
||||
('\'', _) => {
|
||||
self.bump();
|
||||
let terminated = self.single_quoted_string();
|
||||
@@ -366,31 +365,23 @@ fn advance_token(&mut self) -> Token {
|
||||
}
|
||||
|
||||
fn line_comment(&mut self) -> TokenKind {
|
||||
debug_assert!(self.prev() == '/' && self.nth_char(0) == '/');
|
||||
debug_assert!(self.prev() == '/' && self.first() == '/');
|
||||
self.bump();
|
||||
loop {
|
||||
match self.nth_char(0) {
|
||||
'\n' => break,
|
||||
EOF_CHAR if self.is_eof() => break,
|
||||
_ => {
|
||||
self.bump();
|
||||
}
|
||||
}
|
||||
}
|
||||
self.eat_while(|c| c != '\n');
|
||||
LineComment
|
||||
}
|
||||
|
||||
fn block_comment(&mut self) -> TokenKind {
|
||||
debug_assert!(self.prev() == '/' && self.nth_char(0) == '*');
|
||||
debug_assert!(self.prev() == '/' && self.first() == '*');
|
||||
self.bump();
|
||||
let mut depth = 1usize;
|
||||
while let Some(c) = self.bump() {
|
||||
match c {
|
||||
'/' if self.nth_char(0) == '*' => {
|
||||
'/' if self.first() == '*' => {
|
||||
self.bump();
|
||||
depth += 1;
|
||||
}
|
||||
'*' if self.nth_char(0) == '/' => {
|
||||
'*' if self.first() == '/' => {
|
||||
self.bump();
|
||||
depth -= 1;
|
||||
if depth == 0 {
|
||||
@@ -409,31 +400,27 @@ fn block_comment(&mut self) -> TokenKind {
|
||||
|
||||
fn whitespace(&mut self) -> TokenKind {
|
||||
debug_assert!(is_whitespace(self.prev()));
|
||||
while is_whitespace(self.nth_char(0)) {
|
||||
self.bump();
|
||||
}
|
||||
self.eat_while(is_whitespace);
|
||||
Whitespace
|
||||
}
|
||||
|
||||
fn raw_ident(&mut self) -> TokenKind {
|
||||
debug_assert!(
|
||||
self.prev() == 'r'
|
||||
&& self.nth_char(0) == '#'
|
||||
&& is_id_start(self.nth_char(1))
|
||||
&& self.first() == '#'
|
||||
&& is_id_start(self.second())
|
||||
);
|
||||
// Eat "#" symbol.
|
||||
self.bump();
|
||||
self.bump();
|
||||
while is_id_continue(self.nth_char(0)) {
|
||||
self.bump();
|
||||
}
|
||||
// Eat the identifier part of RawIdent.
|
||||
self.eat_identifier();
|
||||
RawIdent
|
||||
}
|
||||
|
||||
fn ident(&mut self) -> TokenKind {
|
||||
debug_assert!(is_id_start(self.prev()));
|
||||
while is_id_continue(self.nth_char(0)) {
|
||||
self.bump();
|
||||
}
|
||||
// Start is already eaten, eat the rest of identifier.
|
||||
self.eat_while(is_id_continue);
|
||||
Ident
|
||||
}
|
||||
|
||||
@@ -442,7 +429,7 @@ fn number(&mut self, first_digit: char) -> LiteralKind {
|
||||
let mut base = Base::Decimal;
|
||||
if first_digit == '0' {
|
||||
// Attempt to parse encoding base.
|
||||
let has_digits = match self.nth_char(0) {
|
||||
let has_digits = match self.first() {
|
||||
'b' => {
|
||||
base = Base::Binary;
|
||||
self.bump();
|
||||
@@ -476,23 +463,23 @@ fn number(&mut self, first_digit: char) -> LiteralKind {
|
||||
self.eat_decimal_digits();
|
||||
};
|
||||
|
||||
match self.nth_char(0) {
|
||||
match self.first() {
|
||||
// Don't be greedy if this is actually an
|
||||
// integer literal followed by field/method access or a range pattern
|
||||
// (`0..2` and `12.foo()`)
|
||||
'.' if self.nth_char(1) != '.'
|
||||
&& !is_id_start(self.nth_char(1)) =>
|
||||
'.' if self.second() != '.'
|
||||
&& !is_id_start(self.second()) =>
|
||||
{
|
||||
// might have stuff after the ., and if it does, it needs to start
|
||||
// with a number
|
||||
self.bump();
|
||||
let mut empty_exponent = false;
|
||||
if self.nth_char(0).is_digit(10) {
|
||||
if self.first().is_digit(10) {
|
||||
self.eat_decimal_digits();
|
||||
match self.nth_char(0) {
|
||||
match self.first() {
|
||||
'e' | 'E' => {
|
||||
self.bump();
|
||||
empty_exponent = self.float_exponent().is_err()
|
||||
empty_exponent = !self.eat_float_exponent();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@@ -501,7 +488,7 @@ fn number(&mut self, first_digit: char) -> LiteralKind {
|
||||
}
|
||||
'e' | 'E' => {
|
||||
self.bump();
|
||||
let empty_exponent = self.float_exponent().is_err();
|
||||
let empty_exponent = !self.eat_float_exponent();
|
||||
Float { base, empty_exponent }
|
||||
}
|
||||
_ => Int { base, empty_int: false },
|
||||
@@ -510,65 +497,76 @@ fn number(&mut self, first_digit: char) -> LiteralKind {
|
||||
|
||||
fn lifetime_or_char(&mut self) -> TokenKind {
|
||||
debug_assert!(self.prev() == '\'');
|
||||
let mut starts_with_number = false;
|
||||
|
||||
// Check if the first symbol after '\'' is a valid identifier
|
||||
// character or a number (not a digit followed by '\'').
|
||||
if (is_id_start(self.nth_char(0))
|
||||
|| self.nth_char(0).is_digit(10) && {
|
||||
starts_with_number = true;
|
||||
true
|
||||
})
|
||||
&& self.nth_char(1) != '\''
|
||||
{
|
||||
self.bump();
|
||||
let can_be_a_lifetime = if self.second() == '\'' {
|
||||
// It's surely not a lifetime.
|
||||
false
|
||||
} else {
|
||||
// If the first symbol is valid for identifier, it can be a lifetime.
|
||||
// Also check if it's a number for a better error reporting (so '0 will
|
||||
// be reported as invalid lifetime and not as unterminated char literal).
|
||||
is_id_start(self.first()) || self.first().is_digit(10)
|
||||
};
|
||||
|
||||
// Skip the identifier.
|
||||
while is_id_continue(self.nth_char(0)) {
|
||||
self.bump();
|
||||
if !can_be_a_lifetime {
|
||||
let terminated = self.single_quoted_string();
|
||||
let suffix_start = self.len_consumed();
|
||||
if terminated {
|
||||
self.eat_literal_suffix();
|
||||
}
|
||||
|
||||
return if self.nth_char(0) == '\'' {
|
||||
self.bump();
|
||||
let kind = Char { terminated: true };
|
||||
Literal { kind, suffix_start: self.len_consumed() }
|
||||
} else {
|
||||
Lifetime { starts_with_number }
|
||||
};
|
||||
let kind = Char { terminated };
|
||||
return Literal { kind, suffix_start };
|
||||
}
|
||||
|
||||
// This is not a lifetime (checked above), parse a char literal.
|
||||
let terminated = self.single_quoted_string();
|
||||
let suffix_start = self.len_consumed();
|
||||
if terminated {
|
||||
self.eat_literal_suffix();
|
||||
// Either a lifetime or a character literal with
|
||||
// length greater than 1.
|
||||
|
||||
let starts_with_number = self.first().is_digit(10);
|
||||
|
||||
// Skip the literal contents.
|
||||
// First symbol can be a number (which isn't a valid identifier start),
|
||||
// so skip it without any checks.
|
||||
self.bump();
|
||||
self.eat_while(is_id_continue);
|
||||
|
||||
// Check if after skipping literal contents we've met a closing
|
||||
// single quote (which means that user attempted to create a
|
||||
// string with single quotes).
|
||||
if self.first() == '\'' {
|
||||
self.bump();
|
||||
let kind = Char { terminated: true };
|
||||
return Literal { kind, suffix_start: self.len_consumed() };
|
||||
}
|
||||
let kind = Char { terminated };
|
||||
return Literal { kind, suffix_start };
|
||||
|
||||
return Lifetime { starts_with_number };
|
||||
}
|
||||
|
||||
fn single_quoted_string(&mut self) -> bool {
|
||||
debug_assert!(self.prev() == '\'');
|
||||
// Parse `'''` as a single char literal.
|
||||
if self.nth_char(0) == '\'' && self.nth_char(1) == '\'' {
|
||||
// Check if it's a one-symbol literal.
|
||||
if self.second() == '\'' && self.first() != '\\' {
|
||||
self.bump();
|
||||
self.bump();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Literal has more than one symbol.
|
||||
|
||||
// Parse until either quotes are terminated or error is detected.
|
||||
let mut first = true;
|
||||
loop {
|
||||
match self.nth_char(0) {
|
||||
// Probably beginning of the comment, which we don't want to include
|
||||
// to the error report.
|
||||
'/' if !first => break,
|
||||
// Newline without following '\'' means unclosed quote, stop parsing.
|
||||
'\n' if self.nth_char(1) != '\'' => break,
|
||||
// End of file, stop parsing.
|
||||
EOF_CHAR if self.is_eof() => break,
|
||||
match self.first() {
|
||||
// Quotes are terminated, finish parsing.
|
||||
'\'' => {
|
||||
self.bump();
|
||||
return true;
|
||||
}
|
||||
// Probably beginning of the comment, which we don't want to include
|
||||
// to the error report.
|
||||
'/' => break,
|
||||
// Newline without following '\'' means unclosed quote, stop parsing.
|
||||
'\n' if self.second() != '\'' => break,
|
||||
// End of file, stop parsing.
|
||||
EOF_CHAR if self.is_eof() => break,
|
||||
// Escaped slash is considered one character, so bump twice.
|
||||
'\\' => {
|
||||
self.bump();
|
||||
@@ -579,8 +577,8 @@ fn single_quoted_string(&mut self) -> bool {
|
||||
self.bump();
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
// String was not terminated.
|
||||
false
|
||||
}
|
||||
|
||||
@@ -588,62 +586,71 @@ fn single_quoted_string(&mut self) -> bool {
|
||||
/// if string is terminated.
|
||||
fn double_quoted_string(&mut self) -> bool {
|
||||
debug_assert!(self.prev() == '"');
|
||||
loop {
|
||||
match self.nth_char(0) {
|
||||
while let Some(c) = self.bump() {
|
||||
match c {
|
||||
'"' => {
|
||||
self.bump();
|
||||
return true;
|
||||
}
|
||||
EOF_CHAR if self.is_eof() => return false,
|
||||
'\\' if self.nth_char(1) == '\\' || self.nth_char(1) == '"' => {
|
||||
'\\' if self.first() == '\\' || self.first() == '"' => {
|
||||
// Bump again to skip escaped character.
|
||||
self.bump();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
self.bump();
|
||||
}
|
||||
// End of file reached.
|
||||
false
|
||||
}
|
||||
|
||||
/// Eats the double-quoted string and returns a tuple of
|
||||
/// (amount of the '#' symbols, raw string started, raw string terminated)
|
||||
fn raw_double_quoted_string(&mut self) -> (usize, bool, bool) {
|
||||
debug_assert!(self.prev() == 'r');
|
||||
// Count opening '#' symbols.
|
||||
let n_hashes = {
|
||||
let mut acc: usize = 0;
|
||||
loop {
|
||||
match self.bump() {
|
||||
Some('#') => acc += 1,
|
||||
Some('"') => break acc,
|
||||
None | Some(_) => return (acc, false, false),
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut started: bool = false;
|
||||
let mut finished: bool = false;
|
||||
|
||||
// Skip the string itself and check that amount of closing '#'
|
||||
// symbols is equal to the amount of opening ones.
|
||||
loop {
|
||||
match self.bump() {
|
||||
Some('"') => {
|
||||
let mut acc = n_hashes;
|
||||
while self.nth_char(0) == '#' && acc > 0 {
|
||||
self.bump();
|
||||
acc -= 1;
|
||||
}
|
||||
if acc == 0 {
|
||||
return (n_hashes, true, true);
|
||||
}
|
||||
}
|
||||
Some(_) => (),
|
||||
None => return (n_hashes, true, false),
|
||||
}
|
||||
// Count opening '#' symbols.
|
||||
let n_hashes = self.eat_while(|c| c == '#');
|
||||
|
||||
// Check that string is started.
|
||||
match self.bump() {
|
||||
Some('"') => started = true,
|
||||
_ => return (n_hashes, started, finished),
|
||||
}
|
||||
|
||||
// Skip the string contents and on each '#' character met, check if this is
|
||||
// a raw string termination.
|
||||
while !finished {
|
||||
self.eat_while(|c| c != '"');
|
||||
|
||||
if self.is_eof() {
|
||||
return (n_hashes, started, finished);
|
||||
}
|
||||
|
||||
// Eat closing double quote.
|
||||
self.bump();
|
||||
|
||||
// Check that amount of closing '#' symbols
|
||||
// is equal to the amount of opening ones.
|
||||
let mut hashes_left = n_hashes;
|
||||
let is_closing_hash = |c| {
|
||||
if c == '#' && hashes_left != 0 {
|
||||
hashes_left -= 1;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
};
|
||||
finished = self.eat_while(is_closing_hash) == n_hashes;
|
||||
}
|
||||
|
||||
(n_hashes, started, finished)
|
||||
}
|
||||
|
||||
fn eat_decimal_digits(&mut self) -> bool {
|
||||
let mut has_digits = false;
|
||||
loop {
|
||||
match self.nth_char(0) {
|
||||
match self.first() {
|
||||
'_' => {
|
||||
self.bump();
|
||||
}
|
||||
@@ -660,7 +667,7 @@ fn eat_decimal_digits(&mut self) -> bool {
|
||||
fn eat_hexadecimal_digits(&mut self) -> bool {
|
||||
let mut has_digits = false;
|
||||
loop {
|
||||
match self.nth_char(0) {
|
||||
match self.first() {
|
||||
'_' => {
|
||||
self.bump();
|
||||
}
|
||||
@@ -674,23 +681,43 @@ fn eat_hexadecimal_digits(&mut self) -> bool {
|
||||
has_digits
|
||||
}
|
||||
|
||||
fn float_exponent(&mut self) -> Result<(), ()> {
|
||||
/// Eats the float exponent. Returns true if at least one digit was met,
|
||||
/// and returns false otherwise.
|
||||
fn eat_float_exponent(&mut self) -> bool {
|
||||
debug_assert!(self.prev() == 'e' || self.prev() == 'E');
|
||||
if self.nth_char(0) == '-' || self.nth_char(0) == '+' {
|
||||
if self.first() == '-' || self.first() == '+' {
|
||||
self.bump();
|
||||
}
|
||||
if self.eat_decimal_digits() { Ok(()) } else { Err(()) }
|
||||
self.eat_decimal_digits()
|
||||
}
|
||||
|
||||
// Eats the suffix if it's an identifier.
|
||||
// Eats the suffix of the literal, e.g. "_u8".
|
||||
fn eat_literal_suffix(&mut self) {
|
||||
if !is_id_start(self.nth_char(0)) {
|
||||
self.eat_identifier();
|
||||
}
|
||||
|
||||
// Eats the identifier.
|
||||
fn eat_identifier(&mut self) {
|
||||
if !is_id_start(self.first()) {
|
||||
return;
|
||||
}
|
||||
self.bump();
|
||||
|
||||
while is_id_continue(self.nth_char(0)) {
|
||||
self.eat_while(is_id_continue);
|
||||
}
|
||||
|
||||
/// Eats symbols while predicate returns true or until the end of file is reached.
|
||||
/// Returns amount of eaten symbols.
|
||||
fn eat_while<F>(&mut self, mut predicate: F) -> usize
|
||||
where
|
||||
F: FnMut(char) -> bool
|
||||
{
|
||||
let mut eaten: usize = 0;
|
||||
while predicate(self.first()) && !self.is_eof() {
|
||||
eaten += 1;
|
||||
self.bump();
|
||||
}
|
||||
|
||||
eaten
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1476,14 +1476,12 @@ fn check_ident_token(&mut self,
|
||||
let mut lint = cx.struct_span_lint(
|
||||
KEYWORD_IDENTS,
|
||||
ident.span,
|
||||
&format!("`{}` is a keyword in the {} edition",
|
||||
ident.as_str(),
|
||||
next_edition),
|
||||
&format!("`{}` is a keyword in the {} edition", ident, next_edition),
|
||||
);
|
||||
lint.span_suggestion(
|
||||
ident.span,
|
||||
"you can use a raw identifier to stay compatible",
|
||||
format!("r#{}", ident.as_str()),
|
||||
format!("r#{}", ident),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
lint.emit()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::errors::{Applicability, pluralise};
|
||||
use syntax::errors::{Applicability, pluralize};
|
||||
use syntax::feature_gate::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
||||
use syntax::print::pprust;
|
||||
use syntax::symbol::{kw, sym};
|
||||
@@ -144,7 +144,7 @@ fn check_must_use_ty<'tcx>(
|
||||
return true;
|
||||
}
|
||||
|
||||
let plural_suffix = pluralise!(plural_len);
|
||||
let plural_suffix = pluralize!(plural_len);
|
||||
|
||||
match ty.kind {
|
||||
ty::Adt(..) if ty.is_box() => {
|
||||
|
||||
@@ -13,7 +13,7 @@ doctest = false
|
||||
flate2 = "1.0"
|
||||
log = "0.4"
|
||||
memmap = "0.6"
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
|
||||
@@ -121,7 +121,7 @@ fn existing_match(&self, name: Symbol, hash: Option<&Svh>, kind: PathKind)
|
||||
// `source` stores paths which are normalized which may be different
|
||||
// from the strings on the command line.
|
||||
let source = &self.cstore.get_crate_data(cnum).source;
|
||||
if let Some(entry) = self.sess.opts.externs.get(&*name.as_str()) {
|
||||
if let Some(entry) = self.sess.opts.externs.get(&name.as_str()) {
|
||||
// Only use `--extern crate_name=path` here, not `--extern crate_name`.
|
||||
let found = entry.locations.iter().filter_map(|l| l.as_ref()).any(|l| {
|
||||
let l = fs::canonicalize(l).ok();
|
||||
|
||||
@@ -68,7 +68,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
Some(name) => name,
|
||||
None => continue, // skip like historical compilers
|
||||
};
|
||||
lib.kind = match &kind.as_str()[..] {
|
||||
lib.kind = match &*kind.as_str() {
|
||||
"static" => cstore::NativeStatic,
|
||||
"static-nobundle" => cstore::NativeStaticNobundle,
|
||||
"dylib" => cstore::NativeUnknown,
|
||||
|
||||
@@ -26,4 +26,4 @@ rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rustc_apfloat = { path = "../librustc_apfloat" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -974,7 +974,7 @@ fn report_borrow_conflicts_with_destructor(
|
||||
let mut err = self.cannot_borrow_across_destructor(borrow_span);
|
||||
|
||||
let what_was_dropped = match self.describe_place(place.as_ref()) {
|
||||
Some(name) => format!("`{}`", name.as_str()),
|
||||
Some(name) => format!("`{}`", name),
|
||||
None => String::from("temporary value"),
|
||||
};
|
||||
|
||||
|
||||
@@ -548,7 +548,7 @@ fn joined_uncovered_patterns(witnesses: &[super::Pat<'_>]) -> String {
|
||||
}
|
||||
|
||||
fn pattern_not_covered_label(witnesses: &[super::Pat<'_>], joined_patterns: &str) -> String {
|
||||
format!("pattern{} {} not covered", rustc_errors::pluralise!(witnesses.len()), joined_patterns)
|
||||
format!("pattern{} {} not covered", rustc_errors::pluralize!(witnesses.len()), joined_patterns)
|
||||
}
|
||||
|
||||
/// Point at the definition of non-covered `enum` variants.
|
||||
|
||||
@@ -95,10 +95,11 @@ pub fn emulate_intrinsic(
|
||||
) -> InterpResult<'tcx, bool> {
|
||||
let substs = instance.substs;
|
||||
|
||||
let intrinsic_name = &self.tcx.item_name(instance.def_id()).as_str()[..];
|
||||
let intrinsic_name = &*self.tcx.item_name(instance.def_id()).as_str();
|
||||
match intrinsic_name {
|
||||
"caller_location" => {
|
||||
let caller = self.tcx.sess.source_map().lookup_char_pos(span.lo());
|
||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||
let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
|
||||
let location = self.alloc_caller_location(
|
||||
Symbol::intern(&caller.file.name.to_string()),
|
||||
caller.line as u32,
|
||||
|
||||
@@ -642,8 +642,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||
struct_span_err!(
|
||||
tcx.sess, source_info.span, E0133,
|
||||
"{} is unsafe and requires unsafe function or block", description)
|
||||
.span_label(source_info.span, &description.as_str()[..])
|
||||
.note(&details.as_str()[..])
|
||||
.span_label(source_info.span, &*description.as_str())
|
||||
.note(&details.as_str())
|
||||
.emit();
|
||||
}
|
||||
UnsafetyViolationKind::ExternStatic(lint_hir_id) => {
|
||||
@@ -651,8 +651,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||
lint_hir_id,
|
||||
source_info.span,
|
||||
&format!("{} is unsafe and requires unsafe function or block \
|
||||
(error E0133)", &description.as_str()[..]),
|
||||
&details.as_str()[..]);
|
||||
(error E0133)", description),
|
||||
&details.as_str());
|
||||
}
|
||||
UnsafetyViolationKind::BorrowPacked(lint_hir_id) => {
|
||||
if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) {
|
||||
@@ -662,8 +662,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||
lint_hir_id,
|
||||
source_info.span,
|
||||
&format!("{} is unsafe and requires unsafe function or block \
|
||||
(error E0133)", &description.as_str()[..]),
|
||||
&details.as_str()[..]);
|
||||
(error E0133)", description),
|
||||
&details.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ fn in_call(
|
||||
Abi::RustIntrinsic |
|
||||
Abi::PlatformIntrinsic => {
|
||||
assert!(!cx.tcx.is_const_fn(def_id));
|
||||
match &cx.tcx.item_name(def_id).as_str()[..] {
|
||||
match &*cx.tcx.item_name(def_id).as_str() {
|
||||
| "size_of"
|
||||
| "min_align_of"
|
||||
| "needs_drop"
|
||||
@@ -1477,7 +1477,7 @@ fn visit_terminator_kind(&mut self,
|
||||
Abi::RustIntrinsic |
|
||||
Abi::PlatformIntrinsic => {
|
||||
assert!(!self.tcx.is_const_fn(def_id));
|
||||
match &self.tcx.item_name(def_id).as_str()[..] {
|
||||
match &*self.tcx.item_name(def_id).as_str() {
|
||||
// special intrinsic that can be called diretly without an intrinsic
|
||||
// feature gate needs a language feature gate
|
||||
"transmute" => {
|
||||
|
||||
@@ -402,7 +402,7 @@ fn check_terminator(
|
||||
///
|
||||
/// Adding more intrinsics requires sign-off from @rust-lang/lang.
|
||||
fn is_intrinsic_whitelisted(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
|
||||
match &tcx.item_name(def_id).as_str()[..] {
|
||||
match &*tcx.item_name(def_id).as_str() {
|
||||
| "size_of"
|
||||
| "min_align_of"
|
||||
| "needs_drop"
|
||||
|
||||
@@ -21,4 +21,4 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_metadata = { path = "../librustc_metadata" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
use crate::Resolver;
|
||||
use crate::resolve_imports::ImportDirectiveSubclass;
|
||||
|
||||
use errors::pluralise;
|
||||
use errors::pluralize;
|
||||
|
||||
use rustc::util::nodemap::NodeMap;
|
||||
use rustc::{lint, ty};
|
||||
@@ -297,7 +297,7 @@ impl Resolver<'_> {
|
||||
}).collect::<Vec<String>>();
|
||||
span_snippets.sort();
|
||||
let msg = format!("unused import{}{}",
|
||||
pluralise!(len),
|
||||
pluralize!(len),
|
||||
if !span_snippets.is_empty() {
|
||||
format!(": {}", span_snippets.join(", "))
|
||||
} else {
|
||||
|
||||
@@ -1876,7 +1876,7 @@ fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) {
|
||||
None
|
||||
}
|
||||
});
|
||||
find_best_match_for_name(names, &*ident.as_str(), None)
|
||||
find_best_match_for_name(names, &ident.as_str(), None)
|
||||
});
|
||||
self.r.record_partial_res(expr.id, PartialRes::new(Res::Err));
|
||||
self.r.report_error(
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
use crate::{names_to_string, module_to_string};
|
||||
use crate::diagnostics::Suggestion;
|
||||
|
||||
use errors::{Applicability, pluralise};
|
||||
use errors::{Applicability, pluralize};
|
||||
|
||||
use rustc_data_structures::ptr_key::PtrKey;
|
||||
use rustc::ty;
|
||||
@@ -730,7 +730,7 @@ fn throw_unresolved_import_error(
|
||||
|
||||
let msg = format!(
|
||||
"unresolved import{} {}",
|
||||
pluralise!(paths.len()),
|
||||
pluralize!(paths.len()),
|
||||
paths.join(", "),
|
||||
);
|
||||
|
||||
|
||||
@@ -362,6 +362,7 @@ fn $module() {
|
||||
("armv7-unknown-linux-gnueabi", armv7_unknown_linux_gnueabi),
|
||||
("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf),
|
||||
("thumbv7neon-unknown-linux-gnueabihf", thumbv7neon_unknown_linux_gnueabihf),
|
||||
("thumbv7neon-unknown-linux-musleabihf", thumbv7neon_unknown_linux_musleabihf),
|
||||
("armv7-unknown-linux-musleabi", armv7_unknown_linux_musleabi),
|
||||
("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf),
|
||||
("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu),
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
|
||||
|
||||
// This target is for musl Linux on ARMv7 with thumb mode enabled
|
||||
// (for consistency with Android and Debian-based distributions)
|
||||
// and with NEON unconditionally enabled and, therefore, with 32 FPU
|
||||
// registers enabled as well. See section A2.6.2 on page A2-56 in
|
||||
// https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf
|
||||
|
||||
pub fn target() -> TargetResult {
|
||||
let base = super::linux_musl_base::opts();
|
||||
Ok(Target {
|
||||
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
|
||||
// uses it to determine the calling convention and float ABI, and LLVM
|
||||
// doesn't support the "musleabihf" value.
|
||||
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
linker_flavor: LinkerFlavor::Gcc,
|
||||
|
||||
// Most of these settings are copied from the thumbv7neon_unknown_linux_gnueabihf
|
||||
// target.
|
||||
options: TargetOptions {
|
||||
features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(),
|
||||
cpu: "generic".to_string(),
|
||||
max_atomic_width: Some(64),
|
||||
abi_blacklist: super::arm_base::abi_blacklist(),
|
||||
target_mcount: "\u{1}mcount".to_string(),
|
||||
.. base
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -16,4 +16,4 @@ rustc_target = { path = "../librustc_target" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
chalk-engine = { version = "0.9.0", default-features=false }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -17,7 +17,7 @@ rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
use crate::require_c_abi_if_c_variadic;
|
||||
use smallvec::SmallVec;
|
||||
use syntax::ast;
|
||||
use syntax::errors::pluralise;
|
||||
use syntax::errors::pluralize;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
use syntax::symbol::sym;
|
||||
@@ -392,7 +392,7 @@ fn check_generic_arg_count(
|
||||
quantifier,
|
||||
bound,
|
||||
kind,
|
||||
pluralise!(bound),
|
||||
pluralize!(bound),
|
||||
))
|
||||
};
|
||||
|
||||
@@ -1360,7 +1360,7 @@ fn conv_object_ty_poly_trait_ref(&self,
|
||||
span,
|
||||
E0191,
|
||||
"the value of the associated type{} {} must be specified",
|
||||
pluralise!(associated_types.len()),
|
||||
pluralize!(associated_types.len()),
|
||||
names,
|
||||
);
|
||||
let (suggest, potential_assoc_types_spans) =
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use errors::{Applicability, DiagnosticId};
|
||||
|
||||
use syntax_pos::Span;
|
||||
use syntax::errors::pluralise;
|
||||
use syntax::errors::pluralize;
|
||||
|
||||
use super::{Inherited, FnCtxt, potentially_plural_count};
|
||||
|
||||
@@ -649,9 +649,9 @@ fn compare_number_of_generics<'tcx>(
|
||||
declaration has {} {kind} parameter{}",
|
||||
trait_.ident,
|
||||
impl_count,
|
||||
pluralise!(impl_count),
|
||||
pluralize!(impl_count),
|
||||
trait_count,
|
||||
pluralise!(trait_count),
|
||||
pluralize!(trait_count),
|
||||
kind = kind,
|
||||
),
|
||||
DiagnosticId::Error("E0049".into()),
|
||||
@@ -666,7 +666,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
"expected {} {} parameter{}",
|
||||
trait_count,
|
||||
kind,
|
||||
pluralise!(trait_count),
|
||||
pluralize!(trait_count),
|
||||
));
|
||||
}
|
||||
for span in spans {
|
||||
@@ -681,7 +681,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
"found {} {} parameter{}{}",
|
||||
impl_count,
|
||||
kind,
|
||||
pluralise!(impl_count),
|
||||
pluralize!(impl_count),
|
||||
suffix.unwrap_or_else(|| String::new()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ fn can_use_as_ref(
|
||||
}) = parent {
|
||||
if let Ok(src) = cm.span_to_snippet(sp) {
|
||||
for field in fields {
|
||||
if field.ident.as_str() == src.as_str() && field.is_shorthand {
|
||||
if field.ident.as_str() == src && field.is_shorthand {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -409,13 +409,13 @@ pub fn check_ref(
|
||||
let mut sugg_sp = sp;
|
||||
if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind {
|
||||
let clone_trait = self.tcx.lang_items().clone_trait().unwrap();
|
||||
if let ([arg], Some(true), "clone") = (
|
||||
if let ([arg], Some(true), sym::clone) = (
|
||||
&args[..],
|
||||
self.tables.borrow().type_dependent_def_id(expr.hir_id).map(|did| {
|
||||
let ai = self.tcx.associated_item(did);
|
||||
ai.container == ty::TraitContainer(clone_trait)
|
||||
}),
|
||||
&segment.ident.as_str()[..],
|
||||
segment.ident.name,
|
||||
) {
|
||||
// If this expression had a clone call when suggesting borrowing
|
||||
// we want to suggest removing it because it'd now be unecessary.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use crate::util::nodemap::FxHashMap;
|
||||
use crate::astconv::AstConv as _;
|
||||
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use syntax_pos::hygiene::DesugaringKind;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Symbol, kw, sym};
|
||||
@@ -1218,7 +1218,7 @@ fn check_expr_struct_fields(
|
||||
|
||||
struct_span_err!(tcx.sess, span, E0063,
|
||||
"missing field{} {}{} in initializer of `{}`",
|
||||
pluralise!(remaining_fields.len()),
|
||||
pluralize!(remaining_fields.len()),
|
||||
remaining_fields_names,
|
||||
truncated_fields_error,
|
||||
adt_ty)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use crate::middle::lang_items::FnOnceTraitLangItem;
|
||||
use crate::namespace::Namespace;
|
||||
use crate::util::nodemap::FxHashSet;
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use rustc::hir::{self, ExprKind, Node, QPath};
|
||||
use rustc::hir::def::{Res, DefKind};
|
||||
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
|
||||
@@ -601,7 +601,7 @@ macro_rules! report_function {
|
||||
"{an}other candidate{s} {were} found in the following trait{s}, perhaps \
|
||||
add a `use` for {one_of_them}:",
|
||||
an = if candidates.len() == 1 {"an" } else { "" },
|
||||
s = pluralise!(candidates.len()),
|
||||
s = pluralize!(candidates.len()),
|
||||
were = if candidates.len() == 1 { "was" } else { "were" },
|
||||
one_of_them = if candidates.len() == 1 {
|
||||
"it"
|
||||
@@ -835,11 +835,11 @@ fn suggest_traits_to_import<'b>(
|
||||
sp,
|
||||
&message(format!(
|
||||
"restrict type parameter `{}` with",
|
||||
param.name.ident().as_str(),
|
||||
param.name.ident(),
|
||||
)),
|
||||
candidates.iter().map(|t| format!(
|
||||
"{}{} {}{}",
|
||||
param.name.ident().as_str(),
|
||||
param.name.ident(),
|
||||
if impl_trait { " +" } else { ":" },
|
||||
self.tcx.def_path_str(t.def_id),
|
||||
if has_bounds.is_some() { " + "} else { "" },
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
mod op;
|
||||
|
||||
use crate::astconv::{AstConv, PathSeg};
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralize};
|
||||
use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath};
|
||||
use rustc::hir::def::{CtorOf, Res, DefKind};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
@@ -5162,5 +5162,5 @@ fn fatally_break_rust(sess: &Session) {
|
||||
}
|
||||
|
||||
fn potentially_plural_count(count: usize, word: &str) -> String {
|
||||
format!("{} {}{}", count, word, pluralise!(count))
|
||||
format!("{} {}{}", count, word, pluralize!(count))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::check::FnCtxt;
|
||||
use crate::util::nodemap::FxHashMap;
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, pluralize};
|
||||
use rustc::hir::{self, PatKind, Pat, HirId};
|
||||
use rustc::hir::def::{Res, DefKind, CtorKind};
|
||||
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
|
||||
@@ -703,8 +703,8 @@ fn e0023(
|
||||
fields: &[ty::FieldDef],
|
||||
expected: Ty<'tcx>
|
||||
) {
|
||||
let subpats_ending = pluralise!(subpats.len());
|
||||
let fields_ending = pluralise!(fields.len());
|
||||
let subpats_ending = pluralize!(subpats.len());
|
||||
let fields_ending = pluralize!(fields.len());
|
||||
let res_span = self.tcx.def_span(res.def_id());
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@@ -978,7 +978,7 @@ fn error_inexistent_fields(
|
||||
);
|
||||
|
||||
// we don't want to throw `E0027` in case we have thrown `E0026` for them
|
||||
unmentioned_fields.retain(|&x| x.as_str() != suggested_name.as_str());
|
||||
unmentioned_fields.retain(|&x| x.name != suggested_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1174,10 +1174,10 @@ fn error_scrutinee_inconsistent_length(&self, span: Span, min_len: u64, size: u6
|
||||
E0527,
|
||||
"pattern requires {} element{} but array has {}",
|
||||
min_len,
|
||||
pluralise!(min_len),
|
||||
pluralize!(min_len),
|
||||
size,
|
||||
)
|
||||
.span_label(span, format!("expected {} element{}", size, pluralise!(size)))
|
||||
.span_label(span, format!("expected {} element{}", size, pluralize!(size)))
|
||||
.emit();
|
||||
}
|
||||
|
||||
@@ -1188,14 +1188,14 @@ fn error_scrutinee_with_rest_inconsistent_length(&self, span: Span, min_len: u64
|
||||
E0528,
|
||||
"pattern requires at least {} element{} but array has {}",
|
||||
min_len,
|
||||
pluralise!(min_len),
|
||||
pluralize!(min_len),
|
||||
size,
|
||||
).span_label(
|
||||
span,
|
||||
format!(
|
||||
"pattern cannot match array of {} element{}",
|
||||
size,
|
||||
pluralise!(size),
|
||||
pluralize!(size),
|
||||
),
|
||||
).emit();
|
||||
}
|
||||
|
||||
@@ -2408,7 +2408,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||
abi: abi::Abi,
|
||||
) -> ty::PolyFnSig<'tcx> {
|
||||
let unsafety = if abi == abi::Abi::RustIntrinsic {
|
||||
intrinsic_operation_unsafety(&*tcx.item_name(def_id).as_str())
|
||||
intrinsic_operation_unsafety(&tcx.item_name(def_id).as_str())
|
||||
} else {
|
||||
hir::Unsafety::Unsafe
|
||||
};
|
||||
|
||||
@@ -404,7 +404,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if !human_readable.is_empty() {
|
||||
fmt.write_str(human_readable)
|
||||
} else if let Some(v) = value {
|
||||
write!(fmt, "<code>{}=\"{}\"</code>", Escape(n), Escape(&*v.as_str()))
|
||||
write!(fmt, "<code>{}=\"{}\"</code>", Escape(n), Escape(&v.as_str()))
|
||||
} else {
|
||||
write!(fmt, "<code>{}</code>", Escape(n))
|
||||
}
|
||||
|
||||
@@ -1167,7 +1167,7 @@ fn external_path(cx: &DocContext<'_>, name: Symbol, trait_did: Option<DefId>, ha
|
||||
global: false,
|
||||
res: Res::Err,
|
||||
segments: vec![PathSegment {
|
||||
name: name.as_str().to_string(),
|
||||
name: name.to_string(),
|
||||
args: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
||||
}],
|
||||
}
|
||||
@@ -3704,7 +3704,7 @@ fn qpath_to_string(p: &hir::QPath) -> String {
|
||||
s.push_str("::");
|
||||
}
|
||||
if seg.ident.name != kw::PathRoot {
|
||||
s.push_str(&*seg.ident.as_str());
|
||||
s.push_str(&seg.ident.as_str());
|
||||
}
|
||||
}
|
||||
s
|
||||
|
||||
@@ -2964,7 +2964,7 @@ fn render_attribute(attr: &ast::MetaItem) -> Option<String> {
|
||||
if attr.is_word() {
|
||||
Some(path)
|
||||
} else if let Some(v) = attr.value_str() {
|
||||
Some(format!("{} = {:?}", path, v.as_str()))
|
||||
Some(format!("{} = {:?}", path, v))
|
||||
} else if let Some(values) = attr.meta_item_list() {
|
||||
let display: Vec<_> = values.iter().filter_map(|attr| {
|
||||
attr.meta_item().and_then(|mi| render_attribute(mi))
|
||||
|
||||
@@ -10,4 +10,4 @@ path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
indexmap = "1"
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -15,6 +15,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "openbsd"),
|
||||
not(target_os = "freebsd"),
|
||||
not(target_os = "netbsd"),
|
||||
not(target_os = "fuchsia"),
|
||||
not(target_os = "redox")))]
|
||||
mod imp {
|
||||
@@ -142,7 +143,7 @@ pub fn fill_bytes(v: &mut [u8]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
|
||||
mod imp {
|
||||
use crate::ptr;
|
||||
|
||||
|
||||
@@ -21,4 +21,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
rustc_lexer = { path = "../librustc_lexer" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
||||
@@ -90,7 +90,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
impl fmt::Display for Lifetime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.ident.name.as_str())
|
||||
write!(f, "{}", self.ident.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -823,7 +823,7 @@ fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) {
|
||||
}
|
||||
|
||||
if let Some(allowed) = allow_features.as_ref() {
|
||||
if allowed.iter().find(|&f| f == &name.as_str() as &str).is_none() {
|
||||
if allowed.iter().find(|&f| name.as_str() == *f).is_none() {
|
||||
span_err!(span_handler, mi.span(), E0725,
|
||||
"the feature `{}` is not in the list of allowed features",
|
||||
name);
|
||||
|
||||
@@ -134,9 +134,9 @@ pub fn to_lit_token(&self) -> token::Lit {
|
||||
let (kind, symbol, suffix) = match *self {
|
||||
LitKind::Str(symbol, ast::StrStyle::Cooked) => {
|
||||
// Don't re-intern unless the escaped string is different.
|
||||
let s: &str = &symbol.as_str();
|
||||
let s = symbol.as_str();
|
||||
let escaped = s.escape_default().to_string();
|
||||
let symbol = if escaped == *s { symbol } else { Symbol::intern(&escaped) };
|
||||
let symbol = if s == escaped { symbol } else { Symbol::intern(&escaped) };
|
||||
(token::Str, symbol, None)
|
||||
}
|
||||
LitKind::Str(symbol, ast::StrStyle::Raw(n)) => {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
use crate::symbol::{kw, sym};
|
||||
use crate::ThinVec;
|
||||
use crate::util::parser::AssocOp;
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralise};
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralize};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
|
||||
use log::{debug, trace};
|
||||
@@ -515,11 +515,11 @@ pub(super) fn check_trailing_angle_brackets(&mut self, segment: &PathSegment, en
|
||||
self.diagnostic()
|
||||
.struct_span_err(
|
||||
span,
|
||||
&format!("unmatched angle bracket{}", pluralise!(total_num_of_gt)),
|
||||
&format!("unmatched angle bracket{}", pluralize!(total_num_of_gt)),
|
||||
)
|
||||
.span_suggestion(
|
||||
span,
|
||||
&format!("remove extra angle bracket{}", pluralise!(total_num_of_gt)),
|
||||
&format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
|
||||
@@ -210,7 +210,7 @@ pub(super) fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Opt
|
||||
// `/` to `\`.
|
||||
#[cfg(windows)]
|
||||
let s = s.replace("/", "\\");
|
||||
Some(dir_path.join(s))
|
||||
Some(dir_path.join(&*s))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -229,7 +229,7 @@ pub(super) fn default_submod_path(
|
||||
// `./<id>.rs` and `./<id>/mod.rs`.
|
||||
let relative_prefix_string;
|
||||
let relative_prefix = if let Some(ident) = relative {
|
||||
relative_prefix_string = format!("{}{}", ident.as_str(), path::MAIN_SEPARATOR);
|
||||
relative_prefix_string = format!("{}{}", ident, path::MAIN_SEPARATOR);
|
||||
&relative_prefix_string
|
||||
} else {
|
||||
""
|
||||
@@ -314,7 +314,7 @@ fn eval_src_mod(
|
||||
|
||||
fn push_directory(&mut self, id: Ident, attrs: &[Attribute]) {
|
||||
if let Some(path) = attr::first_attr_value_str_by_name(attrs, sym::path) {
|
||||
self.directory.path.to_mut().push(&path.as_str());
|
||||
self.directory.path.to_mut().push(&*path.as_str());
|
||||
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
|
||||
} else {
|
||||
// We have to push on the current module name in the case of relative
|
||||
@@ -325,10 +325,10 @@ fn push_directory(&mut self, id: Ident, attrs: &[Attribute]) {
|
||||
// directory path to `/x/y/z`, not `/x/z` with a relative offset of `y`.
|
||||
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
|
||||
if let Some(ident) = relative.take() { // remove the relative offset
|
||||
self.directory.path.to_mut().push(ident.as_str());
|
||||
self.directory.path.to_mut().push(&*ident.as_str());
|
||||
}
|
||||
}
|
||||
self.directory.path.to_mut().push(&id.as_str());
|
||||
self.directory.path.to_mut().push(&*id.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use std::mem;
|
||||
use log::debug;
|
||||
use errors::{Applicability, pluralise};
|
||||
use errors::{Applicability, pluralize};
|
||||
|
||||
/// Specifies how to parse a path.
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
@@ -368,14 +368,14 @@ fn parse_generic_args_with_leaning_angle_bracket_recovery(
|
||||
span,
|
||||
&format!(
|
||||
"unmatched angle bracket{}",
|
||||
pluralise!(snapshot.unmatched_angle_bracket_count)
|
||||
pluralize!(snapshot.unmatched_angle_bracket_count)
|
||||
),
|
||||
)
|
||||
.span_suggestion(
|
||||
span,
|
||||
&format!(
|
||||
"remove extra angle bracket{}",
|
||||
pluralise!(snapshot.unmatched_angle_bracket_count)
|
||||
pluralize!(snapshot.unmatched_angle_bracket_count)
|
||||
),
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use crate::source_map::Span;
|
||||
use crate::symbol::{kw};
|
||||
|
||||
use errors::{Applicability, pluralise};
|
||||
use errors::{Applicability, pluralize};
|
||||
|
||||
/// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT<u8, u8>`,
|
||||
/// `IDENT<<u8 as Trait>::AssocTy>`.
|
||||
@@ -412,7 +412,7 @@ fn parse_generic_bounds_common(&mut self,
|
||||
}
|
||||
err.span_suggestion_hidden(
|
||||
bound_list,
|
||||
&format!("remove the trait bound{}", pluralise!(negative_bounds_len)),
|
||||
&format!("remove the trait bound{}", pluralize!(negative_bounds_len)),
|
||||
new_bound_list,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
||||
@@ -623,7 +623,7 @@ fn print_attribute_inline(&mut self, attr: &ast::Attribute,
|
||||
}
|
||||
self.maybe_print_comment(attr.span.lo());
|
||||
if attr.is_sugared_doc {
|
||||
self.word(attr.value_str().unwrap().as_str().to_string());
|
||||
self.word(attr.value_str().unwrap().to_string());
|
||||
self.hardbreak()
|
||||
} else {
|
||||
match attr.style {
|
||||
@@ -1234,7 +1234,7 @@ fn print_associated_type(&mut self,
|
||||
}
|
||||
ast::ItemKind::GlobalAsm(ref ga) => {
|
||||
self.head(visibility_qualified(&item.vis, "global_asm!"));
|
||||
self.s.word(ga.asm.as_str().to_string());
|
||||
self.s.word(ga.asm.to_string());
|
||||
self.end();
|
||||
}
|
||||
ast::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||
@@ -2335,7 +2335,7 @@ fn print_expr_outer_attr_style(&mut self,
|
||||
}
|
||||
|
||||
crate fn print_name(&mut self, name: ast::Name) {
|
||||
self.s.word(name.as_str().to_string());
|
||||
self.s.word(name.to_string());
|
||||
self.ann.post(self, AnnNode::Name(&name))
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ pub fn len(&self) -> usize {
|
||||
|
||||
// Get the first stream. If it's `None`, create an empty
|
||||
// stream.
|
||||
let mut iter = streams.drain();
|
||||
let mut iter = streams.drain(..);
|
||||
let mut first_stream_lrc = iter.next().unwrap().0;
|
||||
|
||||
// Append the elements to the first stream, after reserving
|
||||
|
||||
@@ -22,5 +22,5 @@ rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
rustc_lexer = { path = "../librustc_lexer" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
syntax = { path = "../libsyntax" }
|
||||
|
||||
@@ -953,18 +953,7 @@ pub fn with_mixed_site_ctxt(&self, span: Span) -> Span {
|
||||
///
|
||||
/// Stops backtracing at include! boundary.
|
||||
pub fn expansion_cause(&self) -> Option<Span> {
|
||||
let mut expn_id = self.current_expansion.id;
|
||||
let mut last_macro = None;
|
||||
loop {
|
||||
let expn_data = expn_id.expn_data();
|
||||
// Stop going up the backtrace once include! is encountered
|
||||
if expn_data.is_root() || expn_data.kind.descr() == sym::include {
|
||||
break;
|
||||
}
|
||||
expn_id = expn_data.call_site.ctxt().outer_expn();
|
||||
last_macro = Some(expn_data.call_site);
|
||||
}
|
||||
last_macro
|
||||
self.current_expansion.id.expansion_cause()
|
||||
}
|
||||
|
||||
pub fn struct_span_warn<S: Into<MultiSpan>>(&self,
|
||||
|
||||
@@ -225,7 +225,7 @@ fn generic_extension<'cx>(
|
||||
};
|
||||
let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), true, false, None);
|
||||
p.root_module_name =
|
||||
cx.current_expansion.module.mod_path.last().map(|id| id.as_str().to_string());
|
||||
cx.current_expansion.module.mod_path.last().map(|id| id.to_string());
|
||||
p.last_type_ascription = cx.current_expansion.prior_type_ascription;
|
||||
|
||||
p.process_potential_macro_variable();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use errors::pluralise;
|
||||
use errors::pluralize;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax_pos::hygiene::{ExpnId, Transparency};
|
||||
@@ -350,10 +350,10 @@ fn with(self, other: LockstepIterSize) -> LockstepIterSize {
|
||||
"meta-variable `{}` repeats {} time{}, but `{}` repeats {} time{}",
|
||||
l_id,
|
||||
l_len,
|
||||
pluralise!(l_len),
|
||||
pluralize!(l_len),
|
||||
r_id,
|
||||
r_len,
|
||||
pluralise!(r_len),
|
||||
pluralize!(r_len),
|
||||
);
|
||||
LockstepIterSize::Contradiction(msg)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ fmt_macros = { path = "../libfmt_macros" }
|
||||
log = "0.4"
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_expand = { path = "../libsyntax_expand" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
|
||||
@@ -21,7 +21,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||
};
|
||||
|
||||
let sp = cx.with_def_site_ctxt(sp);
|
||||
let e = match env::var(&*var.as_str()) {
|
||||
let e = match env::var(&var.as_str()) {
|
||||
Err(..) => {
|
||||
let lt = cx.lifetime(sp, Ident::new(kw::StaticLifetime, sp));
|
||||
cx.expr_path(cx.path_all(sp,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use errors::DiagnosticBuilder;
|
||||
use errors::Applicability;
|
||||
use errors::pluralise;
|
||||
use errors::pluralize;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax_expand::base::{self, *};
|
||||
@@ -300,7 +300,7 @@ fn report_invalid_references(&self, numbered_position_args: bool) {
|
||||
&format!(
|
||||
"{} positional argument{} in format string, but {}",
|
||||
count,
|
||||
pluralise!(count),
|
||||
pluralize!(count),
|
||||
self.describe_num_args(),
|
||||
),
|
||||
);
|
||||
@@ -994,7 +994,7 @@ fn find_skips(snippet: &str, is_raw: bool) -> Vec<usize> {
|
||||
vec![]
|
||||
};
|
||||
|
||||
let fmt_str = &*fmt_str.as_str(); // for the suggestions below
|
||||
let fmt_str = &fmt_str.as_str(); // for the suggestions below
|
||||
let mut parser = parse::Parser::new(fmt_str, str_style, skips, append_newline);
|
||||
|
||||
let mut unverified_pieces = Vec::new();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
use crate::GLOBALS;
|
||||
use crate::{Span, DUMMY_SP};
|
||||
use crate::edition::Edition;
|
||||
use crate::symbol::{kw, Symbol};
|
||||
use crate::symbol::{kw, sym, Symbol};
|
||||
|
||||
use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
@@ -119,6 +119,23 @@ pub fn is_descendant_of(self, ancestor: ExpnId) -> bool {
|
||||
pub fn outer_expn_is_descendant_of(self, ctxt: SyntaxContext) -> bool {
|
||||
HygieneData::with(|data| data.is_descendant_of(self, data.outer_expn(ctxt)))
|
||||
}
|
||||
|
||||
/// Returns span for the macro which originally caused this expansion to happen.
|
||||
///
|
||||
/// Stops backtracing at include! boundary.
|
||||
pub fn expansion_cause(mut self) -> Option<Span> {
|
||||
let mut last_macro = None;
|
||||
loop {
|
||||
let expn_data = self.expn_data();
|
||||
// Stop going up the backtrace once include! is encountered
|
||||
if expn_data.is_root() || expn_data.kind.descr() == sym::include {
|
||||
break;
|
||||
}
|
||||
self = expn_data.call_site.ctxt().outer_expn();
|
||||
last_macro = Some(expn_data.call_site);
|
||||
}
|
||||
last_macro
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
+24
-28
@@ -806,9 +806,9 @@ pub fn modern_and_legacy(self) -> Ident {
|
||||
Ident::new(self.name, self.span.modern_and_legacy())
|
||||
}
|
||||
|
||||
/// Convert the name to a `LocalInternedString`. This is a slowish
|
||||
/// operation because it requires locking the symbol interner.
|
||||
pub fn as_str(self) -> LocalInternedString {
|
||||
/// Convert the name to a `SymbolStr`. This is a slowish operation because
|
||||
/// it requires locking the symbol interner.
|
||||
pub fn as_str(self) -> SymbolStr {
|
||||
self.name.as_str()
|
||||
}
|
||||
}
|
||||
@@ -896,11 +896,11 @@ pub fn with<F: FnOnce(&str) -> R, R>(self, f: F) -> R {
|
||||
})
|
||||
}
|
||||
|
||||
/// Convert to a `LocalInternedString`. This is a slowish operation because
|
||||
/// it requires locking the symbol interner.
|
||||
pub fn as_str(self) -> LocalInternedString {
|
||||
/// Convert to a `SymbolStr`. This is a slowish operation because it
|
||||
/// requires locking the symbol interner.
|
||||
pub fn as_str(self) -> SymbolStr {
|
||||
with_interner(|interner| unsafe {
|
||||
LocalInternedString {
|
||||
SymbolStr {
|
||||
string: std::mem::transmute::<&str, &str>(interner.get(self))
|
||||
}
|
||||
})
|
||||
@@ -973,6 +973,7 @@ pub fn intern(&mut self, string: &str) -> Symbol {
|
||||
self.names.insert(string, name);
|
||||
name
|
||||
}
|
||||
|
||||
// Get the symbol as a string. `Symbol::as_str()` should be used in
|
||||
// preference to this function.
|
||||
pub fn get(&self, symbol: Symbol) -> &str {
|
||||
@@ -1078,7 +1079,6 @@ pub fn is_raw_guess(self) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// If an interner exists, return it. Otherwise, prepare a fresh one.
|
||||
#[inline]
|
||||
fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
|
||||
GLOBALS.with(|globals| f(&mut *globals.symbol_interner.lock()))
|
||||
@@ -1092,46 +1092,42 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
|
||||
/// safely treat `string` which points to interner data, as an immortal string,
|
||||
/// as long as this type never crosses between threads.
|
||||
//
|
||||
// FIXME: ensure that the interner outlives any thread which uses
|
||||
// `LocalInternedString`, by creating a new thread right after constructing the
|
||||
// interner.
|
||||
// FIXME: ensure that the interner outlives any thread which uses `SymbolStr`,
|
||||
// by creating a new thread right after constructing the interner.
|
||||
#[derive(Clone, Eq, PartialOrd, Ord)]
|
||||
pub struct LocalInternedString {
|
||||
pub struct SymbolStr {
|
||||
string: &'static str,
|
||||
}
|
||||
|
||||
impl<U: ?Sized> std::convert::AsRef<U> for LocalInternedString
|
||||
where
|
||||
str: std::convert::AsRef<U>
|
||||
{
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &U {
|
||||
self.string.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for LocalInternedString {
|
||||
// This impl allows a `SymbolStr` to be directly equated with a `String` or
|
||||
// `&str`.
|
||||
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {
|
||||
fn eq(&self, other: &T) -> bool {
|
||||
self.string == other.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl !Send for LocalInternedString {}
|
||||
impl !Sync for LocalInternedString {}
|
||||
impl !Send for SymbolStr {}
|
||||
impl !Sync for SymbolStr {}
|
||||
|
||||
impl std::ops::Deref for LocalInternedString {
|
||||
/// This impl means that if `ss` is a `SymbolStr`:
|
||||
/// - `*ss` is a `str`;
|
||||
/// - `&*ss` is a `&str`;
|
||||
/// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a
|
||||
/// function expecting a `&str`.
|
||||
impl std::ops::Deref for SymbolStr {
|
||||
type Target = str;
|
||||
#[inline]
|
||||
fn deref(&self) -> &str { self.string }
|
||||
}
|
||||
|
||||
impl fmt::Debug for LocalInternedString {
|
||||
impl fmt::Debug for SymbolStr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(self.string, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for LocalInternedString {
|
||||
impl fmt::Display for SymbolStr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(self.string, f)
|
||||
}
|
||||
|
||||
@@ -755,6 +755,10 @@ LLVMRustSetDataLayoutFromTargetMachine(LLVMModuleRef Module,
|
||||
unwrap(Module)->setDataLayout(Target->createDataLayout());
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetModulePICLevel(LLVMModuleRef M) {
|
||||
unwrap(M)->setPICLevel(PICLevel::Level::BigPIC);
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetModulePIELevel(LLVMModuleRef M) {
|
||||
unwrap(M)->setPIELevel(PIELevel::Level::Large);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
macro_rules! caller_location_from_macro {
|
||||
() => (core::intrinsics::caller_location());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let loc = core::intrinsics::caller_location();
|
||||
assert_eq!(loc.file(), file!());
|
||||
assert_eq!(loc.line(), 5);
|
||||
assert_eq!(loc.line(), 10);
|
||||
assert_eq!(loc.column(), 15);
|
||||
|
||||
// `caller_location()` in a macro should behave similarly to `file!` and `line!`,
|
||||
// i.e. point to where the macro was invoked, instead of the macro itself.
|
||||
let loc2 = caller_location_from_macro!();
|
||||
assert_eq!(loc2.file(), file!());
|
||||
assert_eq!(loc2.line(), 17);
|
||||
assert_eq!(loc2.column(), 16);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user