Rollup merge of #56747 - ljedrz:remove_box_from_target, r=zackmdavis
target: remove Box returned by get_targets
diff --git a/.gitmodules b/.gitmodules
index 3fc6e45..70164d4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -5,9 +5,6 @@
[submodule "src/rust-installer"]
path = src/tools/rust-installer
url = https://github.com/rust-lang/rust-installer.git
-[submodule "src/liblibc"]
- path = src/liblibc
- url = https://github.com/rust-lang/libc.git
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang-nursery/nomicon.git
@@ -23,9 +20,6 @@
[submodule "src/tools/rls"]
path = src/tools/rls
url = https://github.com/rust-lang-nursery/rls.git
-[submodule "src/libcompiler_builtins"]
- path = src/libcompiler_builtins
- url = https://github.com/rust-lang-nursery/compiler-builtins.git
[submodule "src/tools/clippy"]
path = src/tools/clippy
url = https://github.com/rust-lang-nursery/rust-clippy.git
@@ -35,9 +29,6 @@
[submodule "src/tools/miri"]
path = src/tools/miri
url = https://github.com/solson/miri.git
-[submodule "src/dlmalloc"]
- path = src/dlmalloc
- url = https://github.com/alexcrichton/dlmalloc-rs.git
[submodule "src/doc/rust-by-example"]
path = src/doc/rust-by-example
url = https://github.com/rust-lang/rust-by-example.git
@@ -67,6 +58,3 @@
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide
-[submodule "src/rust-sgx"]
- path = src/rust-sgx
- url = https://github.com/fortanix/rust-sgx
diff --git a/Cargo.lock b/Cargo.lock
index c3c8812..be4a1c2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -15,9 +15,9 @@
name = "alloc"
version = "0.0.0"
dependencies = [
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
- "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -81,7 +81,7 @@
[[package]]
name = "backtrace"
-version = "0.3.9"
+version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -407,10 +407,11 @@
[[package]]
name = "compiler_builtins"
-version = "0.0.0"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
- "core 0.0.0",
+ "rustc-std-workspace-core 1.0.0",
]
[[package]]
@@ -456,7 +457,7 @@
name = "core"
version = "0.0.0"
dependencies = [
- "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -658,10 +659,12 @@
[[package]]
name = "dlmalloc"
-version = "0.0.0"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "compiler_builtins 0.0.0",
- "core 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-std-workspace-core 1.0.0",
]
[[package]]
@@ -725,7 +728,7 @@
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -733,7 +736,7 @@
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -748,7 +751,7 @@
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -814,10 +817,11 @@
[[package]]
name = "fortanix-sgx-abi"
-version = "0.0.0"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "compiler_builtins 0.0.0",
- "core 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-std-workspace-core 1.0.0",
]
[[package]]
@@ -1140,16 +1144,11 @@
[[package]]
name = "libc"
-version = "0.0.0"
-dependencies = [
- "compiler_builtins 0.0.0",
- "core 0.0.0",
-]
-
-[[package]]
-name = "libc"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rustc-std-workspace-core 1.0.0",
+]
[[package]]
name = "libgit2-sys"
@@ -1520,9 +1519,9 @@
name = "panic_abort"
version = "0.0.0"
dependencies = [
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
- "libc 0.0.0",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1530,9 +1529,9 @@
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
- "libc 0.0.0",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"unwind 0.0.0",
]
@@ -1683,7 +1682,7 @@
version = "0.0.0"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@@ -1814,7 +1813,7 @@
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1836,7 +1835,7 @@
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1861,7 +1860,7 @@
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2061,7 +2060,7 @@
version = "0.0.0"
dependencies = [
"arena 0.0.0",
- "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2243,6 +2242,13 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "rustc-std-workspace-core"
+version = "1.0.0"
+dependencies = [
+ "core 0.0.0",
+]
+
+[[package]]
name = "rustc-workspace-hack"
version = "1.0.0"
dependencies = [
@@ -2284,7 +2290,7 @@
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@@ -2479,7 +2485,7 @@
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@@ -2531,7 +2537,7 @@
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@@ -2644,7 +2650,7 @@
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@@ -2877,15 +2883,15 @@
"alloc 0.0.0",
"build_helper 0.1.0",
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
- "dlmalloc 0.0.0",
- "fortanix-sgx-abi 0.0.0",
- "libc 0.0.0",
+ "dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"panic_abort 0.0.0",
"panic_unwind 0.0.0",
"profiler_builtins 0.0.0",
- "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_asan 0.0.0",
"rustc_lsan 0.0.0",
"rustc_msan 0.0.0",
@@ -3217,9 +3223,9 @@
name = "unwind"
version = "0.0.0"
dependencies = [
- "compiler_builtins 0.0.0",
+ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
- "libc 0.0.0",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -3374,7 +3380,7 @@
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
-"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
+"checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782"
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
"checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a"
"checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf"
@@ -3397,6 +3403,7 @@
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
+"checksum compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad611263b9f31bdb66e66227d3b781600fd1e68d5deee29b23f5e2ac9cb4892"
"checksum compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "89747fe073b7838343bd2c2445e7a7c2e0d415598f8925f0fa9205b9cdfc48cb"
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
@@ -3418,6 +3425,7 @@
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
+"checksum dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c46c65de42b063004b31c67a98abe071089b289ff0919c660ed7ff4f59317f8"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455"
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
@@ -3434,6 +3442,7 @@
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+"checksum fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "26105e20b4c3f7a319db1376b54ac9a46e5761e949405553375095d05a0cee4d"
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"
diff --git a/Cargo.toml b/Cargo.toml
index b763caa..667c557 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -65,6 +65,10 @@
# here
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
+# See comments in `tools/rustc-std-workspace-core/README.md` for what's going on
+# here
+rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
+
[patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
rustc_tools_util = { path = "src/tools/clippy/rustc_tools_util" }
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 7dc64db..32f3e57 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -684,6 +684,11 @@
.env("RUSTDOC_REAL", self.rustdoc(host))
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
.env("RUSTC_BOOTSTRAP", "1");
+
+ // Remove make-related flags that can cause jobserver problems.
+ cmd.env_remove("MAKEFLAGS");
+ cmd.env_remove("MFLAGS");
+
if let Some(linker) = self.linker(host) {
cmd.env("RUSTC_TARGET_LINKER", linker);
}
diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs
index 88b6925..878b6ed 100644
--- a/src/bootstrap/channel.rs
+++ b/src/bootstrap/channel.rs
@@ -24,7 +24,7 @@
use config::Config;
// The version number
-pub const CFG_RELEASE_NUM: &str = "1.32.0";
+pub const CFG_RELEASE_NUM: &str = "1.33.0";
pub struct GitInfo {
inner: Option<Info>,
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 2e792b6..689d053 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -152,11 +152,12 @@
if builder.no_std(target) == Some(true) {
// for no-std targets we only compile a few no_std crates
- cargo.arg("--features").arg("c mem")
+ cargo
.args(&["-p", "alloc"])
- .args(&["-p", "compiler_builtins"])
.arg("--manifest-path")
- .arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
+ .arg(builder.src.join("src/liballoc/Cargo.toml"))
+ .arg("--features")
+ .arg("compiler-builtins-mem");
} else {
let features = builder.std_features();
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 1ae494b..f03eefb 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -857,12 +857,9 @@
// (essentially libstd and all of its path dependencies)
let std_src_dirs = [
"src/build_helper",
- "src/dlmalloc",
"src/liballoc",
"src/libbacktrace",
- "src/libcompiler_builtins",
"src/libcore",
- "src/liblibc",
"src/libpanic_abort",
"src/libpanic_unwind",
"src/librustc_asan",
@@ -871,21 +868,15 @@
"src/librustc_tsan",
"src/libstd",
"src/libunwind",
- "src/rustc/compiler_builtins_shim",
- "src/rustc/libc_shim",
- "src/rustc/dlmalloc_shim",
- "src/rustc/fortanix-sgx-abi_shim",
"src/libtest",
"src/libterm",
"src/libprofiler_builtins",
"src/stdsimd",
"src/libproc_macro",
- ];
- let std_src_dirs_exclude = [
- "src/libcompiler_builtins/compiler-rt/test",
+ "src/tools/rustc-std-workspace-core",
];
- copy_src_dirs(builder, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);
+ copy_src_dirs(builder, &std_src_dirs[..], &[], &dst_src);
for file in src_files.iter() {
builder.copy(&builder.src.join(file), &dst_src.join(file));
}
@@ -909,7 +900,7 @@
}
}
-const CARGO_VENDOR_VERSION: &str = "0.1.19";
+const CARGO_VENDOR_VERSION: &str = "0.1.22";
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct PlainSourceTarball;
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index c31db48..c879291 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1134,10 +1134,10 @@
let krate = &self.crates[&krate];
if krate.is_local(self) {
ret.push(krate);
- for dep in &krate.deps {
- if visited.insert(dep) && dep != "build_helper" {
- list.push(*dep);
- }
+ }
+ for dep in &krate.deps {
+ if visited.insert(dep) && dep != "build_helper" {
+ list.push(*dep);
}
}
}
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index ca9894f..dc061fe 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1558,10 +1558,7 @@
let builder = run.builder;
run = run.krate("test");
for krate in run.builder.in_tree_crates("std") {
- if krate.is_local(&run.builder)
- && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
- && krate.name != "dlmalloc"
- {
+ if !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) {
run = run.path(krate.local_path(&builder).to_str().unwrap());
}
}
diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs
index 0cbb080..a580a87 100644
--- a/src/build_helper/lib.rs
+++ b/src/build_helper/lib.rs
@@ -224,14 +224,12 @@
// Timestamps are created automatically when the result of `native_lib_boilerplate` goes out
// of scope, so all the build actions should be completed until then.
pub fn native_lib_boilerplate(
- src_name: &str,
+ src_dir: &Path,
out_name: &str,
link_name: &str,
search_subdir: &str,
) -> Result<NativeLibBoilerplate, ()> {
- let current_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
- let src_dir = current_dir.join("..").join(src_name);
- rerun_if_changed_anything_in_dir(&src_dir);
+ rerun_if_changed_anything_in_dir(src_dir);
let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or_else(||
env::var_os("OUT_DIR").unwrap());
@@ -248,9 +246,9 @@
);
let timestamp = out_dir.join("rustbuild.timestamp");
- if !up_to_date(Path::new("build.rs"), ×tamp) || !up_to_date(&src_dir, ×tamp) {
+ if !up_to_date(Path::new("build.rs"), ×tamp) || !up_to_date(src_dir, ×tamp) {
Ok(NativeLibBoilerplate {
- src_dir: src_dir,
+ src_dir: src_dir.to_path_buf(),
out_dir: out_dir,
})
} else {
@@ -279,8 +277,11 @@
} else {
format!("static={}", link_name)
};
+ // The source for `compiler-rt` comes from the `compiler-builtins` crate, so
+ // load our env var set by cargo to find the source code.
+ let dir = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
let lib = native_lib_boilerplate(
- "libcompiler_builtins/compiler-rt",
+ dir.as_ref(),
sanitizer_name,
&to_link,
search_path,
diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
index c7e6af2..4f8a3c0 100644
--- a/src/ci/docker/dist-various-1/Dockerfile
+++ b/src/ci/docker/dist-various-1/Dockerfile
@@ -52,8 +52,8 @@
CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv6 -marm" \
bash musl.sh arm && \
env \
- CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm" \
- CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm" \
+ CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \
+ CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm -mfpu=vfp" \
bash musl.sh armhf && \
env \
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \
diff --git a/src/dlmalloc b/src/dlmalloc
deleted file mode 160000
index de99f4b..0000000
--- a/src/dlmalloc
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit de99f4b0c886f5916cd1a146464276d65bef61b8
diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index 4fc5f42..94f2104 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -22,6 +22,13 @@
This flag lets you append multiple extra arguments to the linker invocation. The
options should be separated by spaces.
+## linker-flavor
+
+This flag lets you control the linker flavor used by `rustc`. If a linker is given with the
+`-C linker` flag described above then the linker flavor is inferred from the value provided. If no
+linker is given then the linker flavor is used to determine the linker to use. Every `rustc` target
+defaults to some linker flavor.
+
## link-dead-code
Normally, the linker will remove dead code. This flag disables this behavior.
diff --git a/src/doc/unstable-book/src/compiler-flags/linker-flavor.md b/src/doc/unstable-book/src/compiler-flags/linker-flavor.md
deleted file mode 100644
index 3965960..0000000
--- a/src/doc/unstable-book/src/compiler-flags/linker-flavor.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# `linker-flavor`
-
-The tracking issue for this feature is: None
-
-------------------------
-
-Every `rustc` target defaults to some linker. For example, Linux targets default
-to gcc. In some cases, you may want to override the default; you can do that
-with the unstable CLI argument: `-Z linker-flavor`.
-
-Here how you would use this flag to link a Rust binary for the
-`thumbv7m-none-eabi` using LLD instead of GCC.
-
-``` text
-$ xargo rustc --target thumbv7m-none-eabi -- \
- -C linker=ld.lld \
- -Z linker-flavor=ld \
- -Z print-link-args | tr ' ' '\n'
-"ld.lld"
-"-L"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
-"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c.0.o"
-"-o"
-"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c"
-"--gc-sections"
-"-L"
-"$PWD/target/thumbv7m-none-eabi/debug/deps"
-"-L"
-"$PWD/target/debug/deps"
-"-L"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
-"-Bstatic"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
-"-Bdynamic"
-```
-
-Whereas the default is:
-
-``` text
-$ xargo rustc --target thumbv7m-none-eabi -- \
- -C link-arg=-nostartfiles \
- -Z print-link-args | tr ' ' '\n'
-"arm-none-eabi-gcc"
-"-L"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
-"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9.0.o"
-"-o"
-"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9"
-"-Wl,--gc-sections"
-"-nodefaultlibs"
-"-L"
-"$PWD/target/thumbv7m-none-eabi/debug/deps"
-"-L"
-"$PWD/target/debug/deps"
-"-L"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
-"-Wl,-Bstatic"
-"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
-"-nostartfiles"
-"-Wl,-Bdynamic"
-```
diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py
index a376c85..f02c7d8 100755
--- a/src/etc/gdb_rust_pretty_printing.py
+++ b/src/etc/gdb_rust_pretty_printing.py
@@ -9,6 +9,7 @@
# except according to those terms.
import gdb
+import re
import sys
import debugger_pretty_printers_common as rustpp
@@ -20,6 +21,16 @@
rust_enabled = 'set language rust' in gdb.execute('complete set language ru', to_string = True)
+# The btree pretty-printers fail in a confusing way unless
+# https://sourceware.org/bugzilla/show_bug.cgi?id=21763 is fixed.
+# This fix went in 8.1, so check for that.
+# See https://github.com/rust-lang/rust/issues/56730
+gdb_81 = False
+_match = re.match('([0-9]+)\\.([0-9]+)', gdb.VERSION)
+if _match:
+ if int(_match.group(1)) > 8 or (int(_match.group(1)) == 8 and int(_match.group(2)) >= 1):
+ gdb_81 = True
+
#===============================================================================
# GDB Pretty Printing Module for Rust
#===============================================================================
@@ -110,10 +121,10 @@
if type_kind == rustpp.TYPE_KIND_STD_VECDEQUE:
return RustStdVecDequePrinter(val)
- if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
+ if type_kind == rustpp.TYPE_KIND_STD_BTREESET and gdb_81:
return RustStdBTreeSetPrinter(val)
- if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
+ if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP and gdb_81:
return RustStdBTreeMapPrinter(val)
if type_kind == rustpp.TYPE_KIND_STD_STRING:
diff --git a/src/liballoc/Cargo.toml b/src/liballoc/Cargo.toml
index 642a43d..b2eb356 100644
--- a/src/liballoc/Cargo.toml
+++ b/src/liballoc/Cargo.toml
@@ -11,10 +11,10 @@
[dependencies]
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
[dev-dependencies]
-rand = "0.5"
+rand = "0.6"
[[test]]
name = "collectionstests"
@@ -28,3 +28,6 @@
name = "vec_deque_append_bench"
path = "../liballoc/benches/vec_deque_append.rs"
harness = false
+
+[features]
+compiler-builtins-mem = ['compiler_builtins/mem']
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs
index c0adeca..0c5926f 100644
--- a/src/liballoc/collections/vec_deque.rs
+++ b/src/liballoc/collections/vec_deque.rs
@@ -1026,7 +1026,10 @@
iter: Iter {
tail: drain_tail,
head: drain_head,
- ring: unsafe { self.buffer_as_mut_slice() },
+ // Crucially, we only create shared references from `self` here and read from
+ // it. We do not write to `self` nor reborrow to a mutable reference.
+ // Hence the raw pointer we created above, for `deque`, remains valid.
+ ring: unsafe { self.buffer_as_slice() },
},
}
}
diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs
index b0d8fa6..536291d 100644
--- a/src/liballoc/tests/binary_heap.rs
+++ b/src/liballoc/tests/binary_heap.rs
@@ -14,7 +14,7 @@
use std::panic::{self, AssertUnwindSafe};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
-use rand::{thread_rng, Rng};
+use rand::{thread_rng, seq::SliceRandom};
#[test]
fn test_iterator() {
@@ -332,7 +332,7 @@
let panic_item = PanicOrd(i, true);
// heapify the sane items
- rng.shuffle(&mut panic_ords);
+ panic_ords.shuffle(&mut rng);
let mut heap = BinaryHeap::from(panic_ords);
let inner_data;
diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs
index 787e495..6f31e6c 100644
--- a/src/liballoc/tests/slice.rs
+++ b/src/liballoc/tests/slice.rs
@@ -18,7 +18,7 @@
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize};
use std::thread;
-use rand::{Rng, RngCore, thread_rng};
+use rand::{Rng, RngCore, thread_rng, seq::SliceRandom};
use rand::distributions::Standard;
fn square(n: usize) -> usize {
@@ -459,7 +459,7 @@
for i in 0..v.len() {
v[i] = i as i32;
}
- v.sort_by(|_, _| *rng.choose(&[Less, Equal, Greater]).unwrap());
+ v.sort_by(|_, _| *[Less, Equal, Greater].choose(&mut rng).unwrap());
v.sort();
for i in 0..v.len() {
assert_eq!(v[i], i as i32);
diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs
index 683ce2b..9ad8ad1 100644
--- a/src/liballoc/tests/str.rs
+++ b/src/liballoc/tests/str.rs
@@ -1514,9 +1514,9 @@
#[test]
fn trim_ws() {
- assert_eq!(" \t a \t ".trim_left_matches(|c: char| c.is_whitespace()),
+ assert_eq!(" \t a \t ".trim_start_matches(|c: char| c.is_whitespace()),
"a \t ");
- assert_eq!(" \t a \t ".trim_right_matches(|c: char| c.is_whitespace()),
+ assert_eq!(" \t a \t ".trim_end_matches(|c: char| c.is_whitespace()),
" \t a");
assert_eq!(" \t a \t ".trim_start_matches(|c: char| c.is_whitespace()),
"a \t ");
@@ -1524,9 +1524,9 @@
" \t a");
assert_eq!(" \t a \t ".trim_matches(|c: char| c.is_whitespace()),
"a");
- assert_eq!(" \t \t ".trim_left_matches(|c: char| c.is_whitespace()),
+ assert_eq!(" \t \t ".trim_start_matches(|c: char| c.is_whitespace()),
"");
- assert_eq!(" \t \t ".trim_right_matches(|c: char| c.is_whitespace()),
+ assert_eq!(" \t \t ".trim_end_matches(|c: char| c.is_whitespace()),
"");
assert_eq!(" \t \t ".trim_start_matches(|c: char| c.is_whitespace()),
"");
diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins
deleted file mode 160000
index 10f4f35..0000000
--- a/src/libcompiler_builtins
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 10f4f35f9670bb29715a8c1ec01284852d47ed35
diff --git a/src/libcore/Cargo.toml b/src/libcore/Cargo.toml
index 7fd61f0..fa2ab11 100644
--- a/src/libcore/Cargo.toml
+++ b/src/libcore/Cargo.toml
@@ -20,7 +20,7 @@
path = "../libcore/benches/lib.rs"
[dev-dependencies]
-rand = "0.5"
+rand = "0.6"
[features]
# Make panics and failed asserts immediately abort without formatting any message
diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs
index d7a112e..899fae9 100644
--- a/src/libcore/ffi.rs
+++ b/src/libcore/ffi.rs
@@ -1,7 +1,6 @@
#![stable(feature = "", since = "1.30.0")]
#![allow(non_camel_case_types)]
-#![cfg_attr(stage0, allow(dead_code))]
//! Utilities related to FFI bindings.
@@ -123,7 +122,6 @@
all supported platforms",
issue = "27745")]
#[repr(transparent)]
-#[cfg(not(stage0))]
pub struct VaList<'a>(&'a mut VaListImpl);
// The VaArgSafe trait needs to be used in public interfaces, however, the trait
@@ -173,7 +171,6 @@
issue = "27745")]
impl<T> sealed_trait::VaArgSafe for *const T {}
-#[cfg(not(stage0))]
impl<'a> VaList<'a> {
/// Advance to the next arg.
#[unstable(feature = "c_variadic",
@@ -208,7 +205,6 @@
}
}
-#[cfg(not(stage0))]
extern "rust-intrinsic" {
/// Destroy the arglist `ap` after initialization with `va_start` or
/// `va_copy`.
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index eebb98b..b94d5b4 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -718,7 +718,6 @@
pub fn uninit<T>() -> T;
/// Moves a value out of scope without running drop glue.
- #[cfg(not(stage0))]
pub fn forget<T: ?Sized>(_: T);
/// Reinterprets the bits of a value of one type as another type.
@@ -1476,14 +1475,12 @@
/// The stabilized versions of this intrinsic are available on the integer
/// primitives via the `rotate_left` method. For example,
/// [`std::u32::rotate_left`](../../std/primitive.u32.html#method.rotate_left)
- #[cfg(not(stage0))]
pub fn rotate_left<T>(x: T, y: T) -> T;
/// Performs rotate right.
/// The stabilized versions of this intrinsic are available on the integer
/// primitives via the `rotate_right` method. For example,
/// [`std::u32::rotate_right`](../../std/primitive.u32.html#method.rotate_right)
- #[cfg(not(stage0))]
pub fn rotate_right<T>(x: T, y: T) -> T;
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index 0d43f92..d3d1612 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -640,15 +640,15 @@
#[unstable(feature = "pin", issue = "49150")]
pub auto trait Unpin {}
-/// A type which does not implement `Unpin`.
+/// A marker type which does not implement `Unpin`.
///
-/// If a type contains a `Pinned`, it will not implement `Unpin` by default.
+/// If a type contains a `PhantomPinned`, it will not implement `Unpin` by default.
#[unstable(feature = "pin", issue = "49150")]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
-pub struct Pinned;
+pub struct PhantomPinned;
#[unstable(feature = "pin", issue = "49150")]
-impl !Unpin for Pinned {}
+impl !Unpin for PhantomPinned {}
#[unstable(feature = "pin", issue = "49150")]
impl<'a, T: ?Sized + 'a> Unpin for &'a T {}
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 06754f1..afd9fcb 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -149,7 +149,6 @@
///
/// [`forget`]: fn.forget.html
#[inline]
-#[cfg(not(stage0))]
#[unstable(feature = "forget_unsized", issue = "0")]
pub fn forget_unsized<T: ?Sized>(t: T) {
unsafe { intrinsics::forget(t) }
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 13b4221..4acf3a1 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2330,12 +2330,7 @@
#[rustc_const_unstable(feature = "const_int_rotate")]
#[inline]
pub const fn rotate_left(self, n: u32) -> Self {
- #[cfg(not(stage0))] {
- unsafe { intrinsics::rotate_left(self, n as $SelfT) }
- }
- #[cfg(stage0)] {
- (self << (n % $BITS)) | (self >> (($BITS - (n % $BITS)) % $BITS))
- }
+ unsafe { intrinsics::rotate_left(self, n as $SelfT) }
}
}
@@ -2360,12 +2355,7 @@
#[rustc_const_unstable(feature = "const_int_rotate")]
#[inline]
pub const fn rotate_right(self, n: u32) -> Self {
- #[cfg(not(stage0))] {
- unsafe { intrinsics::rotate_right(self, n as $SelfT) }
- }
- #[cfg(stage0)] {
- (self >> (n % $BITS)) | (self << (($BITS - (n % $BITS)) % $BITS))
- }
+ unsafe { intrinsics::rotate_right(self, n as $SelfT) }
}
}
diff --git a/src/libcore/ops/unsize.rs b/src/libcore/ops/unsize.rs
index 4d9a40a..e86a392 100644
--- a/src/libcore/ops/unsize.rs
+++ b/src/libcore/ops/unsize.rs
@@ -93,7 +93,7 @@
/// {}
/// ```
#[unstable(feature = "dispatch_from_dyn", issue = "0")]
-#[cfg_attr(not(stage0), lang = "dispatch_from_dyn")]
+#[lang = "dispatch_from_dyn"]
pub trait DispatchFromDyn<T> {
// Empty.
}
diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs
index aa51555..0ad6e8c 100644
--- a/src/libcore/pin.rs
+++ b/src/libcore/pin.rs
@@ -7,23 +7,33 @@
//! since moving an object with pointers to itself will invalidate them,
//! which could cause undefined behavior.
//!
-//! In order to prevent objects from moving, they must be pinned
-//! by wrapping a pointer to the data in the [`Pin`] type. A pointer wrapped
-//! in a `Pin` is otherwise equivalent to its normal version, e.g., `Pin<Box<T>>`
-//! and `Box<T>` work the same way except that the first is pinning the value
-//! of `T` in place.
+//! By default, all types in Rust are movable. Rust allows passing all types by-value,
+//! and common smart-pointer types such as `Box`, `Rc`, and `&mut` allow replacing and
+//! moving the values they contain. In order to prevent objects from moving, they must
+//! be pinned by wrapping a pointer to the data in the [`Pin`] type.
+//! Doing this prohibits moving the value behind the pointer.
+//! For example, `Pin<Box<T>>` functions much like a regular `Box<T>`,
+//! but doesn't allow moving `T`. The pointer value itself (the `Box`) can still be moved,
+//! but the value behind it cannot.
//!
-//! First of all, these are pointer types because pinned data mustn't be passed around by value
-//! (that would change its location in memory).
-//! Secondly, since data can be moved out of `&mut` and `Box` with functions such as [`swap`],
-//! which causes their contents to swap places in memory,
-//! we need dedicated types that prohibit such operations.
+//! Since data can be moved out of `&mut` and `Box` with functions such as [`swap`],
+//! changing the location of the underlying data, [`Pin`] prohibits accessing the
+//! underlying pointer type (the `&mut` or `Box`) directly, and provides its own set of
+//! APIs for accessing and using the value. [`Pin`] also guarantees that no other
+//! functions will move the pointed-to value. This allows for the creation of
+//! self-references and other special behaviors that are only possible for unmovable
+//! values.
//!
-//! However, these restrictions are usually not necessary,
-//! so most types implement the [`Unpin`] auto-trait,
-//! which indicates that the type can be moved out safely.
-//! Doing so removes the limitations of pinning types,
-//! making them the same as their non-pinning counterparts.
+//! However, these restrictions are usually not necessary. Many types are always freely
+//! movable. These types implement the [`Unpin`] auto-trait, which nullifies the affect
+//! of [`Pin`]. For `T: Unpin`, `Pin<Box<T>>` and `Box<T>` function identically, as do
+//! `Pin<&mut T>` and `&mut T`.
+//!
+//! Note that pinning and `Unpin` only affect the pointed-to type. For example, whether
+//! or not `Box<T>` is `Unpin` has no affect on the behavior of `Pin<Box<T>>`. Similarly,
+//! `Pin<Box<T>>` and `Pin<&mut T>` are always `Unpin` themselves, even though the
+//! `T` underneath them isn't, because the pointers in `Pin<Box<_>>` and `Pin<&mut _>`
+//! are always freely movable, even if the data they point to isn't.
//!
//! [`Pin`]: struct.Pin.html
//! [`Unpin`]: trait.Unpin.html
@@ -36,7 +46,7 @@
//! #![feature(pin)]
//!
//! use std::pin::Pin;
-//! use std::marker::Pinned;
+//! use std::marker::PhantomPinned;
//! use std::ptr::NonNull;
//!
//! // This is a self-referential struct since the slice field points to the data field.
@@ -47,7 +57,7 @@
//! struct Unmovable {
//! data: String,
//! slice: NonNull<String>,
-//! _pin: Pinned,
+//! _pin: PhantomPinned,
//! }
//!
//! impl Unmovable {
@@ -60,7 +70,7 @@
//! // we only create the pointer once the data is in place
//! // otherwise it will have already moved before we even started
//! slice: NonNull::dangling(),
-//! _pin: Pinned,
+//! _pin: PhantomPinned,
//! };
//! let mut boxed = Box::pinned(res);
//!
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index b11ae30..f61e582 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -2848,14 +2848,14 @@
#[unstable(feature = "ptr_internals", issue = "0")]
impl<'a, T: ?Sized> From<&'a mut T> for Unique<T> {
fn from(reference: &'a mut T) -> Self {
- Unique { pointer: unsafe { NonZero(reference as _) }, _marker: PhantomData }
+ Unique { pointer: unsafe { NonZero(reference as *mut T) }, _marker: PhantomData }
}
}
#[unstable(feature = "ptr_internals", issue = "0")]
impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
fn from(reference: &'a T) -> Self {
- Unique { pointer: unsafe { NonZero(reference as _) }, _marker: PhantomData }
+ Unique { pointer: unsafe { NonZero(reference as *const T) }, _marker: PhantomData }
}
}
@@ -3058,7 +3058,7 @@
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
#[inline]
fn from(reference: &'a mut T) -> Self {
- NonNull { pointer: unsafe { NonZero(reference as _) } }
+ NonNull { pointer: unsafe { NonZero(reference as *mut T) } }
}
}
@@ -3066,6 +3066,6 @@
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
#[inline]
fn from(reference: &'a T) -> Self {
- NonNull { pointer: unsafe { NonZero(reference as _) } }
+ NonNull { pointer: unsafe { NonZero(reference as *const T) } }
}
}
diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs
index 27eeb04..060983a 100644
--- a/src/libcore/sync/atomic.rs
+++ b/src/libcore/sync/atomic.rs
@@ -1940,7 +1940,7 @@
8,
u64 AtomicU64 ATOMIC_U64_INIT
}
-#[cfg(all(not(stage0), target_has_atomic = "128"))]
+#[cfg(target_has_atomic = "128")]
atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1954,7 +1954,7 @@
16,
i128 AtomicI128 ATOMIC_I128_INIT
}
-#[cfg(all(not(stage0), target_has_atomic = "128"))]
+#[cfg(target_has_atomic = "128")]
atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
diff --git a/src/libcore/tests/num/flt2dec/random.rs b/src/libcore/tests/num/flt2dec/random.rs
index 95dfcb5..21a7c9f 100644
--- a/src/libcore/tests/num/flt2dec/random.rs
+++ b/src/libcore/tests/num/flt2dec/random.rs
@@ -18,7 +18,8 @@
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};
-use rand::{FromEntropy, XorShiftRng};
+use rand::FromEntropy;
+use rand::rngs::SmallRng;
use rand::distributions::{Distribution, Uniform};
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
@@ -71,7 +72,10 @@
pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
where F: FnMut(&Decoded, &mut [u8]) -> Option<(usize, i16)>,
G: FnMut(&Decoded, &mut [u8]) -> (usize, i16) {
- let mut rng = XorShiftRng::from_entropy();
+ if cfg!(target_os = "emscripten") {
+ return // using rng pulls in i128 support, which doesn't work
+ }
+ let mut rng = SmallRng::from_entropy();
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
let x = f32::from_bits(f32_range.sample(&mut rng));
@@ -82,7 +86,10 @@
pub fn f64_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
where F: FnMut(&Decoded, &mut [u8]) -> Option<(usize, i16)>,
G: FnMut(&Decoded, &mut [u8]) -> (usize, i16) {
- let mut rng = XorShiftRng::from_entropy();
+ if cfg!(target_os = "emscripten") {
+ return // using rng pulls in i128 support, which doesn't work
+ }
+ let mut rng = SmallRng::from_entropy();
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
let x = f64::from_bits(f64_range.sample(&mut rng));
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs
index dba5a43..4f00ebe 100644
--- a/src/libcore/tests/slice.rs
+++ b/src/libcore/tests/slice.rs
@@ -1024,11 +1024,11 @@
fn sort_unstable() {
use core::cmp::Ordering::{Equal, Greater, Less};
use core::slice::heapsort;
- use rand::{FromEntropy, Rng, XorShiftRng};
+ use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};
let mut v = [0; 600];
let mut tmp = [0; 600];
- let mut rng = XorShiftRng::from_entropy();
+ let mut rng = SmallRng::from_entropy();
for len in (2..25).chain(500..510) {
let v = &mut v[0..len];
@@ -1073,7 +1073,7 @@
for i in 0..v.len() {
v[i] = i as i32;
}
- v.sort_unstable_by(|_, _| *rng.choose(&[Less, Equal, Greater]).unwrap());
+ v.sort_unstable_by(|_, _| *[Less, Equal, Greater].choose(&mut rng).unwrap());
v.sort_unstable();
for i in 0..v.len() {
assert_eq!(v[i], i as i32);
diff --git a/src/liblibc b/src/liblibc
deleted file mode 160000
index 5b40375..0000000
--- a/src/liblibc
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 5b403753da9ec8ff501adf34cb6d63b319b4a3ae
diff --git a/src/libpanic_abort/Cargo.toml b/src/libpanic_abort/Cargo.toml
index 633d273..e304e61 100644
--- a/src/libpanic_abort/Cargo.toml
+++ b/src/libpanic_abort/Cargo.toml
@@ -11,5 +11,5 @@
[dependencies]
core = { path = "../libcore" }
-libc = { path = "../rustc/libc_shim" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+libc = { version = "0.2", default-features = false }
+compiler_builtins = "0.1.0"
diff --git a/src/libpanic_unwind/Cargo.toml b/src/libpanic_unwind/Cargo.toml
index 74aaa4d..c9fce62 100644
--- a/src/libpanic_unwind/Cargo.toml
+++ b/src/libpanic_unwind/Cargo.toml
@@ -12,6 +12,6 @@
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
-libc = { path = "../rustc/libc_shim" }
+libc = { version = "0.2", default-features = false }
unwind = { path = "../libunwind" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = "0.1.0"
diff --git a/src/libprofiler_builtins/Cargo.toml b/src/libprofiler_builtins/Cargo.toml
index 79192fb..7c95cf0 100644
--- a/src/libprofiler_builtins/Cargo.toml
+++ b/src/libprofiler_builtins/Cargo.toml
@@ -13,7 +13,7 @@
[dependencies]
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
[build-dependencies]
cc = "1.0.1"
diff --git a/src/libprofiler_builtins/build.rs b/src/libprofiler_builtins/build.rs
index 8d6c7d6..db72ce7 100644
--- a/src/libprofiler_builtins/build.rs
+++ b/src/libprofiler_builtins/build.rs
@@ -56,9 +56,15 @@
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
}
+ // The source for `compiler-rt` comes from the `compiler-builtins` crate, so
+ // load our env var set by cargo to find the source code.
+ let root = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
+ let root = Path::new(&root);
+
for src in profile_sources {
- cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
+ cfg.file(root.join("lib").join("profile").join(src));
}
+ cfg.warnings(false);
cfg.compile("profiler-rt");
}
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs
index e6a7c20..56da6b7 100644
--- a/src/librustc/ich/impls_ty.rs
+++ b/src/librustc/ich/impls_ty.rs
@@ -338,7 +338,7 @@
);
impl_stable_hash_for!(
- impl<'tcx, M> for enum mir::interpret::AllocType<'tcx, M> [ mir::interpret::AllocType ] {
+ impl<'tcx> for enum mir::interpret::AllocKind<'tcx> [ mir::interpret::AllocKind ] {
Function(instance),
Static(def_id),
Memory(mem),
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index a09d167..b7759a8 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -463,7 +463,7 @@
Ok(ref s) => {
// FIXME(Manishearth) ideally the emitting code
// can tell us whether or not this is global
- let opt_colon = if s.trim_left().starts_with("::") {
+ let opt_colon = if s.trim_start().starts_with("::") {
""
} else {
"::"
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 289f693..8b16aaf 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -183,50 +183,14 @@
impl<'tcx> EvalError<'tcx> {
pub fn print_backtrace(&mut self) {
if let Some(ref mut backtrace) = self.backtrace {
- eprintln!("{}", print_backtrace(&mut *backtrace));
+ print_backtrace(&mut *backtrace);
}
}
}
-fn print_backtrace(backtrace: &mut Backtrace) -> String {
- use std::fmt::Write;
-
+fn print_backtrace(backtrace: &mut Backtrace) {
backtrace.resolve();
-
- let mut trace_text = "\n\nAn error occurred in miri:\n".to_string();
- write!(trace_text, "backtrace frames: {}\n", backtrace.frames().len()).unwrap();
- 'frames: for (i, frame) in backtrace.frames().iter().enumerate() {
- if frame.symbols().is_empty() {
- write!(trace_text, " {}: no symbols\n", i).unwrap();
- }
- let mut first = true;
- for symbol in frame.symbols() {
- if first {
- write!(trace_text, " {}: ", i).unwrap();
- first = false;
- } else {
- let len = i.to_string().len();
- write!(trace_text, " {} ", " ".repeat(len)).unwrap();
- }
- if let Some(name) = symbol.name() {
- write!(trace_text, "{}\n", name).unwrap();
- } else {
- write!(trace_text, "<unknown>\n").unwrap();
- }
- write!(trace_text, " at ").unwrap();
- if let Some(file_path) = symbol.filename() {
- write!(trace_text, "{}", file_path.display()).unwrap();
- } else {
- write!(trace_text, "<unknown_file>").unwrap();
- }
- if let Some(line) = symbol.lineno() {
- write!(trace_text, ":{}\n", line).unwrap();
- } else {
- write!(trace_text, "\n").unwrap();
- }
- }
- }
- trace_text
+ eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
}
impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
@@ -238,7 +202,7 @@
if val == "immediate" {
// Print it now
- eprintln!("{}", print_backtrace(&mut backtrace));
+ print_backtrace(&mut backtrace);
None
} else {
Some(Box::new(backtrace))
diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs
index 9369b6e..d54a1c9 100644
--- a/src/librustc/mir/interpret/mod.rs
+++ b/src/librustc/mir/interpret/mod.rs
@@ -41,7 +41,6 @@
use ty::layout::{self, Size};
use middle::region;
use std::io;
-use std::hash::Hash;
use rustc_serialize::{Encoder, Decodable, Encodable};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::{Lock as Mutex, HashMapExt};
@@ -90,7 +89,7 @@
impl ::rustc_serialize::UseSpecializedDecodable for AllocId {}
#[derive(RustcDecodable, RustcEncodable)]
-enum AllocKind {
+enum AllocDiscriminant {
Alloc,
Fn,
Static,
@@ -104,23 +103,23 @@
tcx: TyCtxt<'a, 'tcx, 'tcx>,
alloc_id: AllocId,
) -> Result<(), E::Error> {
- let alloc_type: AllocType<'tcx, &'tcx Allocation> =
+ let alloc_kind: AllocKind<'tcx> =
tcx.alloc_map.lock().get(alloc_id).expect("no value for AllocId");
- match alloc_type {
- AllocType::Memory(alloc) => {
+ match alloc_kind {
+ AllocKind::Memory(alloc) => {
trace!("encoding {:?} with {:#?}", alloc_id, alloc);
- AllocKind::Alloc.encode(encoder)?;
+ AllocDiscriminant::Alloc.encode(encoder)?;
alloc.encode(encoder)?;
}
- AllocType::Function(fn_instance) => {
+ AllocKind::Function(fn_instance) => {
trace!("encoding {:?} with {:#?}", alloc_id, fn_instance);
- AllocKind::Fn.encode(encoder)?;
+ AllocDiscriminant::Fn.encode(encoder)?;
fn_instance.encode(encoder)?;
}
- AllocType::Static(did) => {
+ AllocKind::Static(did) => {
// referring to statics doesn't need to know about their allocations,
// just about its DefId
- AllocKind::Static.encode(encoder)?;
+ AllocDiscriminant::Static.encode(encoder)?;
did.encode(encoder)?;
}
}
@@ -189,10 +188,10 @@
let idx = decoder.read_u32()? as usize;
let pos = self.state.data_offsets[idx] as usize;
- // Decode the AllocKind now so that we know if we have to reserve an
+ // Decode the AllocDiscriminant now so that we know if we have to reserve an
// AllocId.
let (alloc_kind, pos) = decoder.with_position(pos, |decoder| {
- let alloc_kind = AllocKind::decode(decoder)?;
+ let alloc_kind = AllocDiscriminant::decode(decoder)?;
Ok((alloc_kind, decoder.position()))
})?;
@@ -208,7 +207,7 @@
ref mut entry @ State::Empty => {
// We are allowed to decode
match alloc_kind {
- AllocKind::Alloc => {
+ AllocDiscriminant::Alloc => {
// If this is an allocation, we need to reserve an
// AllocId so we can decode cyclic graphs.
let alloc_id = decoder.tcx().alloc_map.lock().reserve();
@@ -217,7 +216,7 @@
alloc_id);
Some(alloc_id)
},
- AllocKind::Fn | AllocKind::Static => {
+ AllocDiscriminant::Fn | AllocDiscriminant::Static => {
// Fns and statics cannot be cyclic and their AllocId
// is determined later by interning
*entry = State::InProgressNonAlloc(
@@ -251,15 +250,15 @@
// Now decode the actual data
let alloc_id = decoder.with_position(pos, |decoder| {
match alloc_kind {
- AllocKind::Alloc => {
+ AllocDiscriminant::Alloc => {
let allocation = <&'tcx Allocation as Decodable>::decode(decoder)?;
// We already have a reserved AllocId.
let alloc_id = alloc_id.unwrap();
trace!("decoded alloc {:?} {:#?}", alloc_id, allocation);
- decoder.tcx().alloc_map.lock().set_id_same_memory(alloc_id, allocation);
+ decoder.tcx().alloc_map.lock().set_alloc_id_same_memory(alloc_id, allocation);
Ok(alloc_id)
},
- AllocKind::Fn => {
+ AllocDiscriminant::Fn => {
assert!(alloc_id.is_none());
trace!("creating fn alloc id");
let instance = ty::Instance::decode(decoder)?;
@@ -267,7 +266,7 @@
let alloc_id = decoder.tcx().alloc_map.lock().create_fn_alloc(instance);
Ok(alloc_id)
},
- AllocKind::Static => {
+ AllocDiscriminant::Static => {
assert!(alloc_id.is_none());
trace!("creating extern static alloc id at");
let did = DefId::decode(decoder)?;
@@ -292,39 +291,42 @@
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, RustcDecodable, RustcEncodable)]
-pub enum AllocType<'tcx, M> {
+pub enum AllocKind<'tcx> {
/// The alloc id is used as a function pointer
Function(Instance<'tcx>),
/// The alloc id points to a "lazy" static variable that did not get computed (yet).
/// This is also used to break the cycle in recursive statics.
Static(DefId),
/// The alloc id points to memory
- Memory(M)
+ Memory(&'tcx Allocation),
}
-pub struct AllocMap<'tcx, M> {
+pub struct AllocMap<'tcx> {
/// Lets you know what an AllocId refers to
- id_to_type: FxHashMap<AllocId, AllocType<'tcx, M>>,
+ id_to_kind: FxHashMap<AllocId, AllocKind<'tcx>>,
- /// Used to ensure that functions and statics only get one associated AllocId
- type_interner: FxHashMap<AllocType<'tcx, M>, AllocId>,
+ /// Used to ensure that statics only get one associated AllocId
+ type_interner: FxHashMap<AllocKind<'tcx>, AllocId>,
/// The AllocId to assign to the next requested id.
/// Always incremented, never gets smaller.
next_id: AllocId,
}
-impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> {
+impl<'tcx> AllocMap<'tcx> {
pub fn new() -> Self {
AllocMap {
- id_to_type: Default::default(),
+ id_to_kind: Default::default(),
type_interner: Default::default(),
next_id: AllocId(0),
}
}
- /// obtains a new allocation ID that can be referenced but does not
+ /// Obtains a new allocation ID that can be referenced but does not
/// yet have an allocation backing it.
+ ///
+ /// Make sure to call `set_alloc_id_memory` or `set_alloc_id_same_memory` before returning such
+ /// an `AllocId` from a query.
pub fn reserve(
&mut self,
) -> AllocId {
@@ -337,53 +339,73 @@
next
}
- fn intern(&mut self, alloc_type: AllocType<'tcx, M>) -> AllocId {
- if let Some(&alloc_id) = self.type_interner.get(&alloc_type) {
+ fn intern(&mut self, alloc_kind: AllocKind<'tcx>) -> AllocId {
+ if let Some(&alloc_id) = self.type_interner.get(&alloc_kind) {
return alloc_id;
}
let id = self.reserve();
- debug!("creating alloc_type {:?} with id {}", alloc_type, id);
- self.id_to_type.insert(id, alloc_type.clone());
- self.type_interner.insert(alloc_type, id);
+ debug!("creating alloc_kind {:?} with id {}", alloc_kind, id);
+ self.id_to_kind.insert(id, alloc_kind.clone());
+ self.type_interner.insert(alloc_kind, id);
id
}
- // FIXME: Check if functions have identity. If not, we should not intern these,
- // but instead create a new id per use.
- // Alternatively we could just make comparing function pointers an error.
+ /// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
+ /// by the linker and functions can be duplicated across crates.
+ /// We thus generate a new `AllocId` for every mention of a function. This means that
+ /// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
- self.intern(AllocType::Function(instance))
+ let id = self.reserve();
+ self.id_to_kind.insert(id, AllocKind::Function(instance));
+ id
}
- pub fn get(&self, id: AllocId) -> Option<AllocType<'tcx, M>> {
- self.id_to_type.get(&id).cloned()
+ /// Returns `None` in case the `AllocId` is dangling. An `EvalContext` can still have a
+ /// local `Allocation` for that `AllocId`, but having such an `AllocId` in a constant is
+ /// illegal and will likely ICE.
+ /// This function exists to allow const eval to detect the difference between evaluation-
+ /// local dangling pointers and allocations in constants/statics.
+ pub fn get(&self, id: AllocId) -> Option<AllocKind<'tcx>> {
+ self.id_to_kind.get(&id).cloned()
}
- pub fn unwrap_memory(&self, id: AllocId) -> M {
+ /// Panics if the `AllocId` does not refer to an `Allocation`
+ pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation {
match self.get(id) {
- Some(AllocType::Memory(mem)) => mem,
+ Some(AllocKind::Memory(mem)) => mem,
_ => bug!("expected allocation id {} to point to memory", id),
}
}
+ /// Generate an `AllocId` for a static or return a cached one in case this function has been
+ /// called on the same static before.
pub fn intern_static(&mut self, static_id: DefId) -> AllocId {
- self.intern(AllocType::Static(static_id))
+ self.intern(AllocKind::Static(static_id))
}
- pub fn allocate(&mut self, mem: M) -> AllocId {
+ /// Intern the `Allocation` and return a new `AllocId`, even if there's already an identical
+ /// `Allocation` with a different `AllocId`.
+ // FIXME: is this really necessary? Can we ensure `FOO` and `BAR` being different after codegen
+ // in `static FOO: u32 = 42; static BAR: u32 = 42;` even if they reuse the same allocation
+ // inside rustc?
+ pub fn allocate(&mut self, mem: &'tcx Allocation) -> AllocId {
let id = self.reserve();
- self.set_id_memory(id, mem);
+ self.set_alloc_id_memory(id, mem);
id
}
- pub fn set_id_memory(&mut self, id: AllocId, mem: M) {
- if let Some(old) = self.id_to_type.insert(id, AllocType::Memory(mem)) {
+ /// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. Trying to
+ /// call this function twice, even with the same `Allocation` will ICE the compiler.
+ pub fn set_alloc_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
+ if let Some(old) = self.id_to_kind.insert(id, AllocKind::Memory(mem)) {
bug!("tried to set allocation id {}, but it was already existing as {:#?}", id, old);
}
}
- pub fn set_id_same_memory(&mut self, id: AllocId, mem: M) {
- self.id_to_type.insert_same(id, AllocType::Memory(mem));
+ /// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. May be called
+ /// twice for the same `(AllocId, Allocation)` pair.
+ fn set_alloc_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
+ self.id_to_kind.insert_same(id, AllocKind::Memory(mem));
}
}
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index 500bd47..b8d4c5a 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -18,7 +18,7 @@
/// Represents the result of a raw const operation, pre-validation.
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Hash)]
pub struct RawConst<'tcx> {
- // the value lives here, at offset 0, and that allocation definitely is a `AllocType::Memory`
+ // the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
// (so you can use `AllocMap::unwrap_memory`).
pub alloc_id: AllocId,
pub ty: Ty<'tcx>,
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index b7a4295..68b5c3e 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -2637,7 +2637,7 @@
if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty {
return ty::tls::with(|tcx| {
let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
- if let Some(interpret::AllocType::Memory(alloc)) = alloc {
+ if let Some(interpret::AllocKind::Memory(alloc)) = alloc {
assert_eq!(len as usize as u128, len);
let slice =
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 750b7f1..b58d80e 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -14,7 +14,7 @@
use std::str::FromStr;
use session::{early_error, early_warn, Session};
-use session::search_paths::SearchPaths;
+use session::search_paths::SearchPath;
use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_target::spec::{Target, TargetTriple};
@@ -374,7 +374,7 @@
lint_cap: Option<lint::Level> [TRACKED],
describe_lints: bool [UNTRACKED],
output_types: OutputTypes [TRACKED],
- search_paths: SearchPaths [UNTRACKED],
+ search_paths: Vec<SearchPath> [UNTRACKED],
libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
maybe_sysroot: Option<PathBuf> [TRACKED],
@@ -593,7 +593,7 @@
lint_cap: None,
describe_lints: false,
output_types: OutputTypes(BTreeMap::new()),
- search_paths: SearchPaths::new(),
+ search_paths: vec![],
maybe_sysroot: None,
target_triple: TargetTriple::from_triple(host_triple()),
test: false,
@@ -1135,6 +1135,8 @@
"enable incremental compilation"),
default_linker_libraries: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
"allow the linker to link its default libraries"),
+ linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
+ "Linker flavor"),
}
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
@@ -1297,8 +1299,6 @@
"pass `-install_name @rpath/...` to the macOS linker"),
sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
"Use a sanitizer"),
- linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
- "Linker flavor"),
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
"set the optimization fuel quota for a crate"),
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
@@ -2115,9 +2115,9 @@
}
};
- let mut search_paths = SearchPaths::new();
+ let mut search_paths = vec![];
for s in &matches.opt_strs("L") {
- search_paths.add_path(&s[..], error_format);
+ search_paths.push(SearchPath::from_cli_opt(&s[..], error_format));
}
let libs = matches
@@ -2535,6 +2535,7 @@
use session::config::{build_configuration, build_session_options_and_crate_config};
use session::config::{LtoCli, CrossLangLto};
use session::build_session;
+ use session::search_paths::SearchPath;
use std::collections::{BTreeMap, BTreeSet};
use std::iter::FromIterator;
use std::path::PathBuf;
@@ -2790,48 +2791,48 @@
// Reference
v1.search_paths
- .add_path("native=abc", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("native=abc", super::ErrorOutputType::Json(false)));
v1.search_paths
- .add_path("crate=def", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("crate=def", super::ErrorOutputType::Json(false)));
v1.search_paths
- .add_path("dependency=ghi", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("dependency=ghi", super::ErrorOutputType::Json(false)));
v1.search_paths
- .add_path("framework=jkl", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("framework=jkl", super::ErrorOutputType::Json(false)));
v1.search_paths
- .add_path("all=mno", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("all=mno", super::ErrorOutputType::Json(false)));
v2.search_paths
- .add_path("native=abc", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("native=abc", super::ErrorOutputType::Json(false)));
v2.search_paths
- .add_path("dependency=ghi", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("dependency=ghi", super::ErrorOutputType::Json(false)));
v2.search_paths
- .add_path("crate=def", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("crate=def", super::ErrorOutputType::Json(false)));
v2.search_paths
- .add_path("framework=jkl", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("framework=jkl", super::ErrorOutputType::Json(false)));
v2.search_paths
- .add_path("all=mno", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("all=mno", super::ErrorOutputType::Json(false)));
v3.search_paths
- .add_path("crate=def", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("crate=def", super::ErrorOutputType::Json(false)));
v3.search_paths
- .add_path("framework=jkl", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("framework=jkl", super::ErrorOutputType::Json(false)));
v3.search_paths
- .add_path("native=abc", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("native=abc", super::ErrorOutputType::Json(false)));
v3.search_paths
- .add_path("dependency=ghi", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("dependency=ghi", super::ErrorOutputType::Json(false)));
v3.search_paths
- .add_path("all=mno", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("all=mno", super::ErrorOutputType::Json(false)));
v4.search_paths
- .add_path("all=mno", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("all=mno", super::ErrorOutputType::Json(false)));
v4.search_paths
- .add_path("native=abc", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("native=abc", super::ErrorOutputType::Json(false)));
v4.search_paths
- .add_path("crate=def", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("crate=def", super::ErrorOutputType::Json(false)));
v4.search_paths
- .add_path("dependency=ghi", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("dependency=ghi", super::ErrorOutputType::Json(false)));
v4.search_paths
- .add_path("framework=jkl", super::ErrorOutputType::Json(false));
+ .push(SearchPath::from_cli_opt("framework=jkl", super::ErrorOutputType::Json(false)));
assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs
index 8159c65..c204556 100644
--- a/src/librustc/session/filesearch.rs
+++ b/src/librustc/session/filesearch.rs
@@ -12,13 +12,12 @@
pub use self::FileMatch::*;
-use rustc_data_structures::fx::FxHashSet;
use std::borrow::Cow;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
-use session::search_paths::{SearchPaths, PathKind};
+use session::search_paths::{SearchPath, PathKind};
use rustc_fs_util::fix_windows_verbatim_for_gcc;
#[derive(Copy, Clone)]
@@ -30,31 +29,19 @@
// A module for searching for libraries
pub struct FileSearch<'a> {
- pub sysroot: &'a Path,
- pub search_paths: &'a SearchPaths,
- pub triple: &'a str,
- pub kind: PathKind,
+ sysroot: &'a Path,
+ triple: &'a str,
+ search_paths: &'a [SearchPath],
+ tlib_path: &'a SearchPath,
+ kind: PathKind,
}
impl<'a> FileSearch<'a> {
- pub fn for_each_lib_search_path<F>(&self, mut f: F) where
- F: FnMut(&Path, PathKind)
- {
- let mut visited_dirs = FxHashSet::default();
- visited_dirs.reserve(self.search_paths.paths.len() + 1);
- for (path, kind) in self.search_paths.iter(self.kind) {
- f(path, kind);
- visited_dirs.insert(path.to_path_buf());
- }
-
- debug!("filesearch: searching lib path");
- let tlib_path = make_target_lib_path(self.sysroot,
- self.triple);
- if !visited_dirs.contains(&tlib_path) {
- f(&tlib_path, PathKind::All);
- }
-
- visited_dirs.insert(tlib_path);
+ pub fn search_paths(&self) -> impl Iterator<Item = &'a SearchPath> {
+ let kind = self.kind;
+ self.search_paths.iter()
+ .filter(move |sp| sp.kind.matches(kind))
+ .chain(std::iter::once(self.tlib_path))
}
pub fn get_lib_path(&self) -> PathBuf {
@@ -64,14 +51,8 @@
pub fn search<F>(&self, mut pick: F)
where F: FnMut(&Path, PathKind) -> FileMatch
{
- self.for_each_lib_search_path(|lib_search_path, kind| {
- debug!("searching {}", lib_search_path.display());
- let files = match fs::read_dir(lib_search_path) {
- Ok(files) => files,
- Err(..) => return,
- };
- let files = files.filter_map(|p| p.ok().map(|s| s.path()))
- .collect::<Vec<_>>();
+ for search_path in self.search_paths() {
+ debug!("searching {}", search_path.dir.display());
fn is_rlib(p: &Path) -> bool {
p.extension() == Some("rlib".as_ref())
}
@@ -79,11 +60,11 @@
// an rlib and a dylib we only read one of the files of
// metadata, so in the name of speed, bring all rlib files to
// the front of the search list.
- let files1 = files.iter().filter(|p| is_rlib(p));
- let files2 = files.iter().filter(|p| !is_rlib(p));
+ let files1 = search_path.files.iter().filter(|p| is_rlib(p));
+ let files2 = search_path.files.iter().filter(|p| !is_rlib(p));
for path in files1.chain(files2) {
debug!("testing {}", path.display());
- let maybe_picked = pick(path, kind);
+ let maybe_picked = pick(path, search_path.kind);
match maybe_picked {
FileMatches => {
debug!("picked {}", path.display());
@@ -93,29 +74,30 @@
}
}
}
- });
+ }
}
pub fn new(sysroot: &'a Path,
triple: &'a str,
- search_paths: &'a SearchPaths,
- kind: PathKind) -> FileSearch<'a> {
+ search_paths: &'a Vec<SearchPath>,
+ tlib_path: &'a SearchPath,
+ kind: PathKind)
+ -> FileSearch<'a> {
debug!("using sysroot = {}, triple = {}", sysroot.display(), triple);
FileSearch {
sysroot,
- search_paths,
triple,
+ search_paths,
+ tlib_path,
kind,
}
}
- // Returns a list of directories where target-specific dylibs might be located.
- pub fn get_dylib_search_paths(&self) -> Vec<PathBuf> {
- let mut paths = Vec::new();
- self.for_each_lib_search_path(|lib_search_path, _| {
- paths.push(lib_search_path.to_path_buf());
- });
- paths
+ // Returns just the directories within the search paths.
+ pub fn search_path_dirs(&self) -> Vec<PathBuf> {
+ self.search_paths()
+ .map(|sp| sp.dir.to_path_buf())
+ .collect()
}
// Returns a list of directories where target-specific tool binaries are located.
@@ -138,8 +120,7 @@
p
}
-fn make_target_lib_path(sysroot: &Path,
- target_triple: &str) -> PathBuf {
+pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
sysroot.join(&relative_target_lib_path(sysroot, target_triple))
}
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index d1dd745..12b5646 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -19,8 +19,8 @@
use lint::builtin::BuiltinLintDiagnostics;
use middle::allocator::AllocatorKind;
use middle::dependency_format;
-use session::search_paths::PathKind;
use session::config::{OutputType, Lto};
+use session::search_paths::{PathKind, SearchPath};
use util::nodemap::{FxHashMap, FxHashSet};
use util::common::{duration_to_secs_str, ErrorReported};
use util::common::ProfileQueriesMsg;
@@ -48,7 +48,7 @@
use std::env;
use std::fmt;
use std::io::Write;
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use std::time::Duration;
use std::sync::mpsc;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -64,12 +64,15 @@
pub target: config::Config,
pub host: Target,
pub opts: config::Options,
+ pub host_tlib_path: SearchPath,
+ /// This is `None` if the host and target are the same.
+ pub target_tlib_path: Option<SearchPath>,
pub parse_sess: ParseSess,
/// For a library crate, this is always none
pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>,
pub plugin_registrar_fn: Once<Option<ast::NodeId>>,
pub proc_macro_decls_static: Once<Option<ast::NodeId>>,
- pub default_sysroot: Option<PathBuf>,
+ pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
/// `None` means that there is no source file.
pub local_crate_source_file: Option<PathBuf>,
@@ -694,27 +697,22 @@
)
}
- pub fn sysroot<'a>(&'a self) -> &'a Path {
- match self.opts.maybe_sysroot {
- Some(ref sysroot) => sysroot,
- None => self.default_sysroot
- .as_ref()
- .expect("missing sysroot and default_sysroot in Session"),
- }
- }
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
filesearch::FileSearch::new(
- self.sysroot(),
+ &self.sysroot,
self.opts.target_triple.triple(),
&self.opts.search_paths,
+ // target_tlib_path==None means it's the same as host_tlib_path.
+ self.target_tlib_path.as_ref().unwrap_or(&self.host_tlib_path),
kind,
)
}
pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
filesearch::FileSearch::new(
- self.sysroot(),
+ &self.sysroot,
config::host_triple(),
&self.opts.search_paths,
+ &self.host_tlib_path,
kind,
)
}
@@ -1109,9 +1107,18 @@
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map);
- let default_sysroot = match sopts.maybe_sysroot {
- Some(_) => None,
- None => Some(filesearch::get_or_default_sysroot()),
+ let sysroot = match &sopts.maybe_sysroot {
+ Some(sysroot) => sysroot.clone(),
+ None => filesearch::get_or_default_sysroot(),
+ };
+
+ let host_triple = config::host_triple();
+ let target_triple = sopts.target_triple.triple();
+ let host_tlib_path = SearchPath::from_sysroot_and_triple(&sysroot, host_triple);
+ let target_tlib_path = if host_triple == target_triple {
+ None
+ } else {
+ Some(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
};
let file_path_mapping = sopts.file_path_mapping();
@@ -1142,12 +1149,14 @@
target: target_cfg,
host,
opts: sopts,
+ host_tlib_path,
+ target_tlib_path,
parse_sess: p_s,
// For a library crate, this is always none
entry_fn: Once::new(),
plugin_registrar_fn: Once::new(),
proc_macro_decls_static: Once::new(),
- default_sysroot,
+ sysroot,
local_crate_source_file,
working_dir,
lint_store: RwLock::new(lint::LintStore::new()),
diff --git a/src/librustc/session/search_paths.rs b/src/librustc/session/search_paths.rs
index 6b0a8a0..5c44a07 100644
--- a/src/librustc/session/search_paths.rs
+++ b/src/librustc/session/search_paths.rs
@@ -8,18 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::slice;
use std::path::{Path, PathBuf};
use session::{early_error, config};
+use session::filesearch::make_target_lib_path;
#[derive(Clone, Debug)]
-pub struct SearchPaths {
- crate paths: Vec<(PathKind, PathBuf)>,
-}
-
-pub struct Iter<'a> {
- kind: PathKind,
- iter: slice::Iter<'a, (PathKind, PathBuf)>,
+pub struct SearchPath {
+ pub kind: PathKind,
+ pub dir: PathBuf,
+ pub files: Vec<PathBuf>,
}
#[derive(Eq, PartialEq, Clone, Copy, Debug, PartialOrd, Ord, Hash)]
@@ -32,12 +29,17 @@
All,
}
-impl SearchPaths {
- pub fn new() -> SearchPaths {
- SearchPaths { paths: Vec::new() }
+impl PathKind {
+ pub fn matches(&self, kind: PathKind) -> bool {
+ match (self, kind) {
+ (PathKind::All, _) | (_, PathKind::All) => true,
+ _ => *self == kind,
+ }
}
+}
- pub fn add_path(&mut self, path: &str, output: config::ErrorOutputType) {
+impl SearchPath {
+ pub fn from_cli_opt(path: &str, output: config::ErrorOutputType) -> Self {
let (kind, path) = if path.starts_with("native=") {
(PathKind::Native, &path["native=".len()..])
} else if path.starts_with("crate=") {
@@ -54,34 +56,28 @@
if path.is_empty() {
early_error(output, "empty search path given via `-L`");
}
- self.paths.push((kind, PathBuf::from(path)));
+
+ let dir = PathBuf::from(path);
+ Self::new(kind, dir)
}
- pub fn iter(&self, kind: PathKind) -> Iter<'_> {
- Iter { kind: kind, iter: self.paths.iter() }
+ pub fn from_sysroot_and_triple(sysroot: &Path, triple: &str) -> Self {
+ Self::new(PathKind::All, make_target_lib_path(sysroot, triple))
}
-}
-impl<'a> Iterator for Iter<'a> {
- type Item = (&'a Path, PathKind);
-
- fn next(&mut self) -> Option<(&'a Path, PathKind)> {
- loop {
- match *self.iter.next()? {
- (kind, ref p) if self.kind == PathKind::All ||
- kind == PathKind::All ||
- kind == self.kind => {
- return Some((p, kind))
- }
- _ => {}
+ fn new(kind: PathKind, dir: PathBuf) -> Self {
+ // Get the files within the directory.
+ let files = match std::fs::read_dir(&dir) {
+ Ok(files) => {
+ files.filter_map(|p| {
+ p.ok().map(|s| s.path())
+ })
+ .collect::<Vec<_>>()
}
- }
- }
+ Err(..) => vec![],
+ };
- fn size_hint(&self) -> (usize, Option<usize>) {
- // This iterator will never return more elements than the base iterator;
- // but it can ignore all the remaining elements.
- let (_, upper) = self.iter.size_hint();
- (0, upper)
+ SearchPath { kind, dir, files }
}
}
+
diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs
index 22221e0..b0ca2f6 100644
--- a/src/librustc/traits/specialize/specialization_graph.rs
+++ b/src/librustc/traits/specialize/specialization_graph.rs
@@ -132,10 +132,12 @@
simplified_self,
);
- for possible_sibling in match simplified_self {
- Some(sty) => self.filtered(sty),
- None => self.iter(),
- } {
+ let possible_siblings = match simplified_self {
+ Some(sty) => PotentialSiblings::Filtered(self.filtered(sty)),
+ None => PotentialSiblings::Unfiltered(self.iter()),
+ };
+
+ for possible_sibling in possible_siblings {
debug!(
"insert: impl_def_id={:?}, simplified_self={:?}, possible_sibling={:?}",
impl_def_id,
@@ -222,14 +224,37 @@
Ok(Inserted::BecameNewSibling(last_lint))
}
- fn iter(&mut self) -> Box<dyn Iterator<Item = DefId> + '_> {
+ fn iter(&mut self) -> impl Iterator<Item = DefId> + '_ {
let nonblanket = self.nonblanket_impls.iter_mut().flat_map(|(_, v)| v.iter());
- Box::new(self.blanket_impls.iter().chain(nonblanket).cloned())
+ self.blanket_impls.iter().chain(nonblanket).cloned()
}
- fn filtered(&mut self, sty: SimplifiedType) -> Box<dyn Iterator<Item = DefId> + '_> {
+ fn filtered(&mut self, sty: SimplifiedType) -> impl Iterator<Item = DefId> + '_ {
let nonblanket = self.nonblanket_impls.entry(sty).or_default().iter();
- Box::new(self.blanket_impls.iter().chain(nonblanket).cloned())
+ self.blanket_impls.iter().chain(nonblanket).cloned()
+ }
+}
+
+// A custom iterator used by Children::insert
+enum PotentialSiblings<I, J>
+ where I: Iterator<Item = DefId>,
+ J: Iterator<Item = DefId>
+{
+ Unfiltered(I),
+ Filtered(J)
+}
+
+impl<I, J> Iterator for PotentialSiblings<I, J>
+ where I: Iterator<Item = DefId>,
+ J: Iterator<Item = DefId>
+{
+ type Item = DefId;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ match *self {
+ PotentialSiblings::Unfiltered(ref mut iter) => iter.next(),
+ PotentialSiblings::Filtered(ref mut iter) => iter.next()
+ }
}
}
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index a3db3a0..e27d734 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -946,7 +946,7 @@
/// Stores the value of constants (and deduplicates the actual memory)
allocation_interner: Lock<FxHashMap<&'tcx Allocation, ()>>,
- pub alloc_map: Lock<interpret::AllocMap<'tcx, &'tcx Allocation>>,
+ pub alloc_map: Lock<interpret::AllocMap<'tcx>>,
layout_interner: Lock<FxHashMap<&'tcx LayoutDetails, ()>>,
diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs
index 1e648c4..c2bfa62 100644
--- a/src/librustc/util/profiling.rs
+++ b/src/librustc/util/profiling.rs
@@ -62,11 +62,15 @@
}
fn print(&self, lock: &mut StderrLock<'_>) {
- writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |")
+ writeln!(lock, "| Phase | Time (ms) \
+ | Time (%) | Queries | Hits (%)")
.unwrap();
- writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |")
+ writeln!(lock, "| ---------------- | -------------- \
+ | -------- | -------------- | --------")
.unwrap();
+ let total_time = ($(self.times.$name + )* 0) as f32;
+
$(
let (hits, total) = self.query_counts.$name;
let (hits, total) = if total > 0 {
@@ -78,11 +82,12 @@
writeln!(
lock,
- "| {0: <16} | {1: <14} | {2: <14} | {3: <8} |",
+ "| {0: <16} | {1: <14} | {2: <8.2} | {3: <14} | {4: <8}",
stringify!($name),
self.times.$name / 1_000_000,
+ ((self.times.$name as f32) / total_time) * 100.0,
total,
- hits
+ hits,
).unwrap();
)*
}
diff --git a/src/librustc_asan/Cargo.toml b/src/librustc_asan/Cargo.toml
index 734564c..836caf2 100644
--- a/src/librustc_asan/Cargo.toml
+++ b/src/librustc_asan/Cargo.toml
@@ -16,4 +16,4 @@
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = "0.1.0"
diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs
index ffe5e12..48e0a3a 100644
--- a/src/librustc_codegen_llvm/attributes.rs
+++ b/src/librustc_codegen_llvm/attributes.rs
@@ -15,14 +15,16 @@
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::session::Session;
use rustc::session::config::Sanitizer;
-use rustc::ty::TyCtxt;
+use rustc::ty::{self, TyCtxt, PolyFnSig};
use rustc::ty::layout::HasTyCtxt;
use rustc::ty::query::Providers;
+use rustc_data_structures::small_c_str::SmallCStr;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::PanicStrategy;
use rustc_codegen_ssa::traits::*;
+use abi::Abi;
use attributes;
use llvm::{self, Attribute};
use llvm::AttributePlace::Function;
@@ -60,7 +62,7 @@
/// Tell LLVM whether the function can or cannot unwind.
#[inline]
-pub fn unwind(val: &'ll Value, can_unwind: bool) {
+fn unwind(val: &'ll Value, can_unwind: bool) {
Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind);
}
@@ -129,8 +131,7 @@
}
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
- let cpu = llvm_util::target_cpu(cx.tcx.sess);
- let target_cpu = CString::new(cpu).unwrap();
+ let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess));
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
@@ -150,9 +151,10 @@
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
/// attributes.
pub fn from_fn_attrs(
- cx: &CodegenCx<'ll, '_>,
+ cx: &CodegenCx<'ll, 'tcx>,
llfn: &'ll Value,
id: Option<DefId>,
+ sig: PolyFnSig<'tcx>,
) {
let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
.unwrap_or_else(|| CodegenFnAttrs::new());
@@ -194,37 +196,42 @@
llvm::AttributePlace::ReturnValue, llfn);
}
- let can_unwind = if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
- Some(true)
+ unwind(llfn, if cx.tcx.sess.panic_strategy() != PanicStrategy::Unwind {
+ // In panic=abort mode we assume nothing can unwind anywhere, so
+ // optimize based on this!
+ false
+ } else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
+ // If a specific #[unwind] attribute is present, use that
+ true
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) {
- Some(false)
-
- // Perhaps questionable, but we assume that anything defined
- // *in Rust code* may unwind. Foreign items like `extern "C" {
- // fn foo(); }` are assumed not to unwind **unless** they have
- // a `#[unwind]` attribute.
- } else if id.map(|id| !cx.tcx.is_foreign_item(id)).unwrap_or(false) {
- Some(true)
- } else {
- None
- };
-
- match can_unwind {
- Some(false) => attributes::unwind(llfn, false),
- Some(true) if cx.tcx.sess.panic_strategy() == PanicStrategy::Unwind => {
- attributes::unwind(llfn, true);
+ // Special attribute for allocator functions, which can't unwind
+ false
+ } else if let Some(id) = id {
+ let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
+ if cx.tcx.is_foreign_item(id) {
+ // Foreign items like `extern "C" { fn foo(); }` are assumed not to
+ // unwind
+ false
+ } else if sig.abi != Abi::Rust && sig.abi != Abi::RustCall {
+ // Any items defined in Rust that *don't* have the `extern` ABI are
+ // defined to not unwind. We insert shims to abort if an unwind
+ // happens to enforce this.
+ false
+ } else {
+ // Anything else defined in Rust is assumed that it can possibly
+ // unwind
+ true
}
- Some(true) | None => {}
- }
+ } else {
+ // assume this can possibly unwind, avoiding the application of a
+ // `nounwind` attribute below.
+ true
+ });
// Always annotate functions with the target-cpu they are compiled for.
// Without this, ThinLTO won't inline Rust functions into Clang generated
// functions (because Clang annotates functions this way too).
- // NOTE: For now we just apply this if -Zcross-lang-lto is specified, since
- // it introduce a little overhead and isn't really necessary otherwise.
- if cx.tcx.sess.opts.debugging_opts.cross_lang_lto.enabled() {
- apply_target_cpu_attr(cx, llfn);
- }
+ apply_target_cpu_attr(cx, llfn);
let features = llvm_target_features(cx.tcx.sess)
.map(|s| s.to_string())
diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs
index 9e100a1..f1c0464 100644
--- a/src/librustc_codegen_llvm/back/link.rs
+++ b/src/librustc_codegen_llvm/back/link.rs
@@ -212,12 +212,7 @@
}
fn archive_search_paths(sess: &Session) -> Vec<PathBuf> {
- let mut search = Vec::new();
- sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path, _| {
- search.push(path.to_path_buf());
- });
-
- search
+ sess.target_filesearch(PathKind::Native).search_path_dirs()
}
fn archive_config<'a>(sess: &'a Session,
@@ -1024,11 +1019,10 @@
// where extern libraries might live, based on the
// addl_lib_search_paths
if sess.opts.cg.rpath {
- let sysroot = sess.sysroot();
let target_triple = sess.opts.target_triple.triple();
let mut get_install_prefix_lib_path = || {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
- let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
+ let tlib = filesearch::relative_target_lib_path(&sess.sysroot, target_triple);
let mut path = PathBuf::from(install_prefix);
path.push(&tlib);
@@ -1068,12 +1062,13 @@
fn add_local_native_libraries(cmd: &mut dyn Linker,
sess: &Session,
codegen_results: &CodegenResults) {
- sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| {
- match k {
- PathKind::Framework => { cmd.framework_path(path); }
- _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(path)); }
+ let filesearch = sess.target_filesearch(PathKind::All);
+ for search_path in filesearch.search_paths() {
+ match search_path.kind {
+ PathKind::Framework => { cmd.framework_path(&search_path.dir); }
+ _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir)); }
}
- });
+ }
let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| {
relevant_lib(sess, l)
diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs
index f13eeb6..87185a2 100644
--- a/src/librustc_codegen_llvm/callee.rs
+++ b/src/librustc_codegen_llvm/callee.rs
@@ -94,7 +94,7 @@
if instance.def.is_inline(tcx) {
attributes::inline(cx, llfn, attributes::InlineAttr::Hint);
}
- attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));
+ attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()), sig);
let instance_def_id = instance.def_id();
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs
index 55f286e..ad14ca7 100644
--- a/src/librustc_codegen_llvm/common.rs
+++ b/src/librustc_codegen_llvm/common.rs
@@ -21,7 +21,7 @@
use rustc_codegen_ssa::traits::*;
use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size};
-use rustc::mir::interpret::{Scalar, AllocType, Allocation};
+use rustc::mir::interpret::{Scalar, AllocKind, Allocation};
use consts::const_alloc_to_llvm;
use rustc_codegen_ssa::mir::place::PlaceRef;
@@ -316,9 +316,9 @@
}
},
Scalar::Ptr(ptr) => {
- let alloc_type = self.tcx.alloc_map.lock().get(ptr.alloc_id);
- let base_addr = match alloc_type {
- Some(AllocType::Memory(alloc)) => {
+ let alloc_kind = self.tcx.alloc_map.lock().get(ptr.alloc_id);
+ let base_addr = match alloc_kind {
+ Some(AllocKind::Memory(alloc)) => {
let init = const_alloc_to_llvm(self, alloc);
if alloc.mutability == Mutability::Mutable {
self.static_addr_of_mut(init, alloc.align, None)
@@ -326,10 +326,10 @@
self.static_addr_of(init, alloc.align, None)
}
}
- Some(AllocType::Function(fn_instance)) => {
+ Some(AllocKind::Function(fn_instance)) => {
self.get_fn(fn_instance)
}
- Some(AllocType::Static(def_id)) => {
+ Some(AllocKind::Static(def_id)) => {
assert!(self.tcx.is_static(def_id).is_some());
self.get_static(def_id)
}
diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs
index 6c90937..0bd6146 100644
--- a/src/librustc_codegen_llvm/context.rs
+++ b/src/librustc_codegen_llvm/context.rs
@@ -409,7 +409,6 @@
));
let llfn = self.declare_fn("rust_eh_unwind_resume", sig);
- attributes::unwind(llfn, true);
attributes::apply_target_cpu_attr(self, llfn);
unwresume.set(Some(llfn));
llfn
diff --git a/src/librustc_codegen_llvm/declare.rs b/src/librustc_codegen_llvm/declare.rs
index c23aab4..2964f2e 100644
--- a/src/librustc_codegen_llvm/declare.rs
+++ b/src/librustc_codegen_llvm/declare.rs
@@ -26,8 +26,7 @@
use rustc::ty::layout::LayoutOf;
use rustc::session::config::Sanitizer;
use rustc_data_structures::small_c_str::SmallCStr;
-use rustc_target::spec::PanicStrategy;
-use abi::{Abi, FnType, FnTypeExt};
+use abi::{FnType, FnTypeExt};
use attributes;
use context::CodegenCx;
use type_::Type;
@@ -86,10 +85,6 @@
_ => {},
}
- if cx.tcx.sess.panic_strategy() != PanicStrategy::Unwind {
- attributes::unwind(llfn, false);
- }
-
attributes::non_lazy_bind(cx.sess(), llfn);
llfn
@@ -132,10 +127,6 @@
llvm::Attribute::NoReturn.apply_llfn(Function, llfn);
}
- if sig.abi != Abi::Rust && sig.abi != Abi::RustCall {
- attributes::unwind(llfn, false);
- }
-
fty.apply_attrs_llfn(llfn);
llfn
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 59608b1..8b26ada 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -1081,7 +1081,7 @@
Abi::Rust
));
let llfn = cx.define_internal_fn(name, rust_fn_sig);
- attributes::from_fn_attrs(cx, llfn, None);
+ attributes::from_fn_attrs(cx, llfn, None, rust_fn_sig);
let bx = Builder::new_block(cx, llfn, "entry-block");
codegen(bx);
llfn
@@ -1171,6 +1171,27 @@
);
let arg_tys = sig.inputs();
+ if name == "simd_select_bitmask" {
+ let in_ty = arg_tys[0];
+ let m_len = match in_ty.sty {
+ // Note that this `.unwrap()` crashes for isize/usize, that's sort
+ // of intentional as there's not currently a use case for that.
+ ty::Int(i) => i.bit_width().unwrap(),
+ ty::Uint(i) => i.bit_width().unwrap(),
+ _ => return_error!("`{}` is not an integral type", in_ty),
+ };
+ require_simd!(arg_tys[1], "argument");
+ let v_len = arg_tys[1].simd_size(tcx);
+ require!(m_len == v_len,
+ "mismatched lengths: mask length `{}` != other vector length `{}`",
+ m_len, v_len
+ );
+ let i1 = bx.type_i1();
+ let i1xn = bx.type_vector(i1, m_len as u64);
+ let m_i1s = bx.bitcast(args[0].immediate(), i1xn);
+ return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
+ }
+
// every intrinsic takes a SIMD vector as its first argument
require_simd!(arg_tys[0], "input");
let in_ty = arg_tys[0];
diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs
index fdb6373..12109ae 100644
--- a/src/librustc_codegen_llvm/llvm_util.rs
+++ b/src/librustc_codegen_llvm/llvm_util.rs
@@ -124,6 +124,7 @@
];
const X86_WHITELIST: &[(&str, Option<&str>)] = &[
+ ("adx", Some("adx_target_feature")),
("aes", None),
("avx", None),
("avx2", None),
diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs
index 1d5bcc4..9c69d7d 100644
--- a/src/librustc_codegen_llvm/mono_item.rs
+++ b/src/librustc_codegen_llvm/mono_item.rs
@@ -82,7 +82,12 @@
if instance.def.is_inline(self.tcx) {
attributes::inline(self, lldecl, attributes::InlineAttr::Hint);
}
- attributes::from_fn_attrs(self, lldecl, Some(instance.def.def_id()));
+ attributes::from_fn_attrs(
+ self,
+ lldecl,
+ Some(instance.def.def_id()),
+ mono_sig,
+ );
self.instances.borrow_mut().insert(instance, lldecl);
}
diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml
index 7b1c7cf..5099449 100644
--- a/src/librustc_codegen_ssa/Cargo.toml
+++ b/src/librustc_codegen_ssa/Cargo.toml
@@ -16,7 +16,7 @@
rustc-demangle = "0.1.4"
memmap = "0.6"
log = "0.4.5"
-libc = "0.2.43"
+libc = "0.2.44"
jobserver = "0.1.11"
serialize = { path = "../libserialize" }
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
index 24a70dc..59102e0 100644
--- a/src/librustc_codegen_ssa/back/link.rs
+++ b/src/librustc_codegen_ssa/back/link.rs
@@ -192,11 +192,7 @@
// linker and linker flavor specified via command line have precedence over what the target
// specification specifies
- if let Some(ret) = infer_from(
- sess,
- sess.opts.cg.linker.clone(),
- sess.opts.debugging_opts.linker_flavor,
- ) {
+ if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), sess.opts.cg.linker_flavor) {
return ret;
}
diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs
index 2f92c42..4960c89 100644
--- a/src/librustc_codegen_ssa/back/linker.rs
+++ b/src/librustc_codegen_ssa/back/linker.rs
@@ -606,8 +606,7 @@
self.cmd.arg("/DEBUG");
// This will cause the Microsoft linker to embed .natvis info into the PDB file
- let sysroot = self.sess.sysroot();
- let natvis_dir_path = sysroot.join("lib\\rustlib\\etc");
+ let natvis_dir_path = self.sess.sysroot.join("lib\\rustlib\\etc");
if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) {
// LLVM 5.0.0's lld-link frontend doesn't yet recognize, and chokes
// on, the /NATVIS:... flags. LLVM 6 (or earlier) should at worst ignore
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index f2edcdc..b26d81b 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -975,7 +975,7 @@
let mut old_path = OsString::new();
if cfg!(windows) {
old_path = env::var_os("PATH").unwrap_or(old_path);
- let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
+ let mut new_path = sess.host_filesearch(PathKind::All).search_path_dirs();
for path in env::split_paths(&old_path) {
if !new_path.contains(&path) {
new_path.push(path);
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 39777e0..41c9b22 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -1042,7 +1042,7 @@
targets.sort();
println!("{}", targets.join("\n"));
},
- Sysroot => println!("{}", sess.sysroot().display()),
+ Sysroot => println!("{}", sess.sysroot.display()),
TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
FileNames | CrateName => {
let input = input.unwrap_or_else(||
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index ae9f6a5..7bd0f0f 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -1262,7 +1262,7 @@
// Do not underline the leading...
let start = part.snippet.len()
- .saturating_sub(part.snippet.trim_left().len());
+ .saturating_sub(part.snippet.trim_start().len());
// ...or trailing spaces. Account for substitutions containing unicode
// characters.
let sub_len = part.snippet.trim().chars().fold(0, |acc, ch| {
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index b1e44ea..66364ff 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -376,7 +376,7 @@
store.register_removed("resolve_trait_on_defaulted_unit",
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
store.register_removed("private_no_mangle_fns",
- "no longer an warning, #[no_mangle] functions always exported");
+ "no longer a warning, #[no_mangle] functions always exported");
store.register_removed("private_no_mangle_statics",
- "no longer an warning, #[no_mangle] statics always exported");
+ "no longer a warning, #[no_mangle] statics always exported");
}
diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs
index 13be50e..e071c34 100644
--- a/src/librustc_lint/nonstandard_style.rs
+++ b/src/librustc_lint/nonstandard_style.rs
@@ -167,7 +167,7 @@
fn to_snake_case(mut str: &str) -> String {
let mut words = vec![];
// Preserve leading underscores
- str = str.trim_left_matches(|c: char| {
+ str = str.trim_start_matches(|c: char| {
if c == '_' {
words.push(String::new());
true
@@ -199,7 +199,7 @@
if ident.is_empty() {
return true;
}
- let ident = ident.trim_left_matches('\'');
+ let ident = ident.trim_start_matches('\'');
let ident = ident.trim_matches('_');
let mut allow_underscore = true;
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index 7d01ed5..ce48208 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -192,11 +192,11 @@
// On MSVC llvm-config will print the full name to libraries, but
// we're only interested in the name part
let name = Path::new(lib).file_name().unwrap().to_str().unwrap();
- name.trim_right_matches(".lib")
+ name.trim_end_matches(".lib")
} else if lib.ends_with(".lib") {
// Some MSVC libraries just come up with `.lib` tacked on, so chop
// that off
- lib.trim_right_matches(".lib")
+ lib.trim_end_matches(".lib")
} else {
continue;
};
diff --git a/src/librustc_lsan/Cargo.toml b/src/librustc_lsan/Cargo.toml
index 2573825..a8e11df 100644
--- a/src/librustc_lsan/Cargo.toml
+++ b/src/librustc_lsan/Cargo.toml
@@ -16,4 +16,4 @@
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = "0.1.0"
diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs
index 1f298f6..f01ed9e 100644
--- a/src/librustc_metadata/locator.rs
+++ b/src/librustc_metadata/locator.rs
@@ -678,7 +678,7 @@
// candidates are all canonicalized, so we canonicalize the sysroot
// as well.
if let Some((ref prev, _)) = ret {
- let sysroot = self.sess.sysroot();
+ let sysroot = &self.sess.sysroot;
let sysroot = sysroot.canonicalize()
.unwrap_or_else(|_| sysroot.to_path_buf());
if prev.starts_with(&sysroot) {
diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs
index db60017..fb93c41 100644
--- a/src/librustc_mir/borrow_check/move_errors.rs
+++ b/src/librustc_mir/borrow_check/move_errors.rs
@@ -426,13 +426,13 @@
.span_to_snippet(pat_span)
.unwrap();
if pat_snippet.starts_with('&') {
- let pat_snippet = pat_snippet[1..].trim_left();
+ let pat_snippet = pat_snippet[1..].trim_start();
let suggestion;
let to_remove;
if pat_snippet.starts_with("mut")
&& pat_snippet["mut".len()..].starts_with(Pattern_White_Space)
{
- suggestion = pat_snippet["mut".len()..].trim_left();
+ suggestion = pat_snippet["mut".len()..].trim_start();
to_remove = "&mut";
} else {
suggestion = pat_snippet;
diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs
index cfea357..328b330 100644
--- a/src/librustc_mir/build/matches/simplify.rs
+++ b/src/librustc_mir/build/matches/simplify.rs
@@ -26,6 +26,10 @@
use build::matches::{Ascription, Binding, MatchPair, Candidate};
use hair::*;
use rustc::mir::*;
+use rustc::ty;
+use rustc::ty::layout::{Integer, IntegerExt, Size};
+use syntax::attr::{SignedInt, UnsignedInt};
+use rustc::hir::RangeEnd;
use std::mem;
@@ -62,6 +66,7 @@
match_pair: MatchPair<'pat, 'tcx>,
candidate: &mut Candidate<'pat, 'tcx>)
-> Result<(), MatchPair<'pat, 'tcx>> {
+ let tcx = self.hir.tcx();
match *match_pair.pattern.kind {
PatternKind::AscribeUserType { ref subpattern, ref user_ty, user_ty_span } => {
candidate.ascriptions.push(Ascription {
@@ -104,7 +109,34 @@
Err(match_pair)
}
- PatternKind::Range { .. } => {
+ PatternKind::Range { lo, hi, ty, end } => {
+ let range = match ty.sty {
+ ty::Char => {
+ Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32)))
+ }
+ ty::Int(ity) => {
+ // FIXME(49937): refactor these bit manipulations into interpret.
+ let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
+ let min = 1u128 << (size.bits() - 1);
+ let max = (1u128 << (size.bits() - 1)) - 1;
+ Some((min, max, size))
+ }
+ ty::Uint(uty) => {
+ // FIXME(49937): refactor these bit manipulations into interpret.
+ let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
+ let max = !0u128 >> (128 - size.bits());
+ Some((0, max, size))
+ }
+ _ => None,
+ };
+ if let Some((min, max, sz)) = range {
+ if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
+ if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) {
+ // Irrefutable pattern match.
+ return Ok(());
+ }
+ }
+ }
Err(match_pair)
}
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index b0601b3..ab52d9b 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -628,12 +628,7 @@
// unwind anyway. Don't stop them.
let attrs = &tcx.get_attrs(fn_def_id);
match attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs) {
- None => {
- // FIXME(rust-lang/rust#48251) -- Had to disable
- // abort-on-panic for backwards compatibility reasons.
- false
- }
-
+ None => true,
Some(UnwindAttr::Allowed) => false,
Some(UnwindAttr::Aborts) => true,
}
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index 4c77350..5cfcc16 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -178,11 +178,11 @@
use rustc::hir::def_id::DefId;
use rustc::hir::RangeEnd;
-use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
-use rustc::ty::layout::{Integer, IntegerExt, VariantIdx};
+use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Const};
+use rustc::ty::layout::{Integer, IntegerExt, VariantIdx, Size};
use rustc::mir::Field;
-use rustc::mir::interpret::ConstValue;
+use rustc::mir::interpret::{ConstValue, Pointer, Scalar};
use rustc::util::common::ErrorReported;
use syntax::attr::{SignedInt, UnsignedInt};
@@ -200,14 +200,60 @@
pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pattern<'tcx>)
-> &'a Pattern<'tcx>
{
- cx.pattern_arena.alloc(LiteralExpander.fold_pattern(&pat))
+ cx.pattern_arena.alloc(LiteralExpander { tcx: cx.tcx }.fold_pattern(&pat))
}
-struct LiteralExpander;
-impl<'tcx> PatternFolder<'tcx> for LiteralExpander {
+struct LiteralExpander<'a, 'tcx> {
+ tcx: TyCtxt<'a, 'tcx, 'tcx>
+}
+
+impl<'a, 'tcx> LiteralExpander<'a, 'tcx> {
+ /// Derefs `val` and potentially unsizes the value if `crty` is an array and `rty` a slice.
+ ///
+ /// `crty` and `rty` can differ because you can use array constants in the presence of slice
+ /// patterns. So the pattern may end up being a slice, but the constant is an array. We convert
+ /// the array to a slice in that case.
+ fn fold_const_value_deref(
+ &mut self,
+ val: ConstValue<'tcx>,
+ // the pattern's pointee type
+ rty: Ty<'tcx>,
+ // the constant's pointee type
+ crty: Ty<'tcx>,
+ ) -> ConstValue<'tcx> {
+ match (val, &crty.sty, &rty.sty) {
+ // the easy case, deref a reference
+ (ConstValue::Scalar(Scalar::Ptr(p)), x, y) if x == y => ConstValue::ByRef(
+ p.alloc_id,
+ self.tcx.alloc_map.lock().unwrap_memory(p.alloc_id),
+ p.offset,
+ ),
+ // unsize array to slice if pattern is array but match value or other patterns are slice
+ (ConstValue::Scalar(Scalar::Ptr(p)), ty::Array(t, n), ty::Slice(u)) => {
+ assert_eq!(t, u);
+ ConstValue::ScalarPair(
+ Scalar::Ptr(p),
+ n.val.try_to_scalar().unwrap(),
+ )
+ },
+ // fat pointers stay the same
+ (ConstValue::ScalarPair(..), _, _) => val,
+ // FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` being used
+ _ => bug!("cannot deref {:#?}, {} -> {}", val, crty, rty),
+ }
+ }
+}
+
+impl<'a, 'tcx> PatternFolder<'tcx> for LiteralExpander<'a, 'tcx> {
fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
match (&pat.ty.sty, &*pat.kind) {
- (&ty::Ref(_, rty, _), &PatternKind::Constant { ref value }) => {
+ (
+ &ty::Ref(_, rty, _),
+ &PatternKind::Constant { value: Const {
+ val,
+ ty: ty::TyS { sty: ty::Ref(_, crty, _), .. },
+ } },
+ ) => {
Pattern {
ty: pat.ty,
span: pat.span,
@@ -215,7 +261,11 @@
subpattern: Pattern {
ty: rty,
span: pat.span,
- kind: box PatternKind::Constant { value: value.clone() },
+ kind: box PatternKind::Constant { value: Const::from_const_value(
+ self.tcx,
+ self.fold_const_value_deref(*val, rty, crty),
+ rty,
+ ) },
}
}
}
@@ -732,15 +782,17 @@
for row in patterns {
match *row.kind {
PatternKind::Constant { value } => {
- if let Some(ptr) = value.to_ptr() {
- let is_array_ptr = value.ty
- .builtin_deref(true)
- .and_then(|t| t.ty.builtin_index())
- .map_or(false, |t| t == cx.tcx.types.u8);
- if is_array_ptr {
- let alloc = cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
- max_fixed_len = cmp::max(max_fixed_len, alloc.bytes.len() as u64);
- }
+ // extract the length of an array/slice from a constant
+ match (value.val, &value.ty.sty) {
+ (_, ty::Array(_, n)) => max_fixed_len = cmp::max(
+ max_fixed_len,
+ n.unwrap_usize(cx.tcx),
+ ),
+ (ConstValue::ScalarPair(_, n), ty::Slice(_)) => max_fixed_len = cmp::max(
+ max_fixed_len,
+ n.to_usize(&cx.tcx).unwrap(),
+ ),
+ _ => {},
}
}
PatternKind::Slice { ref prefix, slice: None, ref suffix } => {
@@ -1348,28 +1400,62 @@
}
}
-fn slice_pat_covered_by_constructor<'tcx>(
+// checks whether a constant is equal to a user-written slice pattern. Only supports byte slices,
+// meaning all other types will compare unequal and thus equal patterns often do not cause the
+// second pattern to lint about unreachable match arms.
+fn slice_pat_covered_by_const<'tcx>(
tcx: TyCtxt<'_, 'tcx, '_>,
_span: Span,
- ctor: &Constructor,
+ const_val: &ty::Const<'tcx>,
prefix: &[Pattern<'tcx>],
slice: &Option<Pattern<'tcx>>,
suffix: &[Pattern<'tcx>]
) -> Result<bool, ErrorReported> {
- let data: &[u8] = match *ctor {
- ConstantValue(const_val) => {
- let val = match const_val.val {
- ConstValue::Unevaluated(..) |
- ConstValue::ByRef(..) => bug!("unexpected ConstValue: {:?}", const_val),
- ConstValue::Scalar(val) | ConstValue::ScalarPair(val, _) => val,
- };
- if let Ok(ptr) = val.to_ptr() {
- tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id).bytes.as_ref()
- } else {
- bug!("unexpected non-ptr ConstantValue")
+ let data: &[u8] = match (const_val.val, &const_val.ty.sty) {
+ (ConstValue::ByRef(id, alloc, offset), ty::Array(t, n)) => {
+ if *t != tcx.types.u8 {
+ // FIXME(oli-obk): can't mix const patterns with slice patterns and get
+ // any sort of exhaustiveness/unreachable check yet
+ // This solely means that we don't lint about unreachable patterns, even if some
+ // are definitely unreachable.
+ return Ok(false);
}
- }
- _ => bug!()
+ let ptr = Pointer::new(id, offset);
+ let n = n.assert_usize(tcx).unwrap();
+ alloc.get_bytes(&tcx, ptr, Size::from_bytes(n)).unwrap()
+ },
+ // a slice fat pointer to a zero length slice
+ (ConstValue::ScalarPair(Scalar::Bits { .. }, n), ty::Slice(t)) => {
+ if *t != tcx.types.u8 {
+ // FIXME(oli-obk): can't mix const patterns with slice patterns and get
+ // any sort of exhaustiveness/unreachable check yet
+ // This solely means that we don't lint about unreachable patterns, even if some
+ // are definitely unreachable.
+ return Ok(false);
+ }
+ assert_eq!(n.to_usize(&tcx).unwrap(), 0);
+ &[]
+ },
+ //
+ (ConstValue::ScalarPair(Scalar::Ptr(ptr), n), ty::Slice(t)) => {
+ if *t != tcx.types.u8 {
+ // FIXME(oli-obk): can't mix const patterns with slice patterns and get
+ // any sort of exhaustiveness/unreachable check yet
+ // This solely means that we don't lint about unreachable patterns, even if some
+ // are definitely unreachable.
+ return Ok(false);
+ }
+ let n = n.to_usize(&tcx).unwrap();
+ tcx.alloc_map
+ .lock()
+ .unwrap_memory(ptr.alloc_id)
+ .get_bytes(&tcx, ptr, Size::from_bytes(n))
+ .unwrap()
+ },
+ _ => bug!(
+ "slice_pat_covered_by_const: {:#?}, {:#?}, {:#?}, {:#?}",
+ const_val, prefix, slice, suffix,
+ ),
};
let pat_len = prefix.len() + suffix.len();
@@ -1675,22 +1761,23 @@
// necessarily point to memory, they are usually just integers. The only time
// they should be pointing to memory is when they are subslices of nonzero
// slices
- let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty {
- ty::TyKind::Array(t, n) => (value.to_ptr(), n.unwrap_usize(cx.tcx), t),
- ty::TyKind::Slice(t) => {
- match value.val {
- ConstValue::ScalarPair(ptr, n) => (
- ptr.to_ptr().ok(),
- n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64,
- t,
- ),
- _ => span_bug!(
- pat.span,
- "slice pattern constant must be scalar pair but is {:?}",
- value,
- ),
- }
- },
+ let (opt_ptr, n, ty) = match (value.val, &value.ty.sty) {
+ (ConstValue::ByRef(id, alloc, offset), ty::TyKind::Array(t, n)) => (
+ Some((
+ Pointer::new(id, offset),
+ alloc,
+ )),
+ n.unwrap_usize(cx.tcx),
+ t,
+ ),
+ (ConstValue::ScalarPair(ptr, n), ty::TyKind::Slice(t)) => (
+ ptr.to_ptr().ok().map(|ptr| (
+ ptr,
+ cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id),
+ )),
+ n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64,
+ t,
+ ),
_ => span_bug!(
pat.span,
"unexpected const-val {:?} with ctor {:?}",
@@ -1702,8 +1789,7 @@
// convert a constant slice/array pattern to a list of patterns.
match (n, opt_ptr) {
(0, _) => Some(SmallVec::new()),
- (_, Some(ptr)) => {
- let alloc = cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
+ (_, Some((ptr, alloc))) => {
let layout = cx.tcx.layout_of(cx.param_env.and(ty)).ok()?;
(0..n).map(|i| {
let ptr = ptr.offset(layout.size * i, &cx.tcx).ok()?;
@@ -1766,10 +1852,8 @@
None
}
}
- ConstantValue(..) => {
- match slice_pat_covered_by_constructor(
- cx.tcx, pat.span, constructor, prefix, slice, suffix
- ) {
+ ConstantValue(cv) => {
+ match slice_pat_covered_by_const(cx.tcx, pat.span, cv, prefix, slice, suffix) {
Ok(true) => Some(smallvec![]),
Ok(false) => None,
Err(ErrorReported) => None
diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs
index d695a64..ddd6a70 100644
--- a/src/librustc_mir/hair/pattern/mod.rs
+++ b/src/librustc_mir/hair/pattern/mod.rs
@@ -1259,34 +1259,32 @@
}
}
- if let ty::Ref(_, rty, _) = ty.value.sty {
- if let ty::Str = rty.sty {
- match (a.val, b.val) {
- (
- ConstValue::ScalarPair(
- Scalar::Ptr(ptr_a),
- len_a,
- ),
- ConstValue::ScalarPair(
- Scalar::Ptr(ptr_b),
- len_b,
- ),
- ) if ptr_a.offset.bytes() == 0 && ptr_b.offset.bytes() == 0 => {
- if let Ok(len_a) = len_a.to_bits(tcx.data_layout.pointer_size) {
- if let Ok(len_b) = len_b.to_bits(tcx.data_layout.pointer_size) {
- if len_a == len_b {
- let map = tcx.alloc_map.lock();
- let alloc_a = map.unwrap_memory(ptr_a.alloc_id);
- let alloc_b = map.unwrap_memory(ptr_b.alloc_id);
- if alloc_a.bytes.len() as u128 == len_a {
- return from_bool(alloc_a == alloc_b);
- }
+ if let ty::Str = ty.value.sty {
+ match (a.val, b.val) {
+ (
+ ConstValue::ScalarPair(
+ Scalar::Ptr(ptr_a),
+ len_a,
+ ),
+ ConstValue::ScalarPair(
+ Scalar::Ptr(ptr_b),
+ len_b,
+ ),
+ ) if ptr_a.offset.bytes() == 0 && ptr_b.offset.bytes() == 0 => {
+ if let Ok(len_a) = len_a.to_bits(tcx.data_layout.pointer_size) {
+ if let Ok(len_b) = len_b.to_bits(tcx.data_layout.pointer_size) {
+ if len_a == len_b {
+ let map = tcx.alloc_map.lock();
+ let alloc_a = map.unwrap_memory(ptr_a.alloc_id);
+ let alloc_b = map.unwrap_memory(ptr_b.alloc_id);
+ if alloc_a.bytes.len() as u128 == len_a {
+ return from_bool(alloc_a == alloc_b);
}
}
}
}
- _ => (),
}
+ _ => (),
}
}
diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs
index bbee6e0..cbe2e25 100644
--- a/src/librustc_mir/interpret/intrinsics.rs
+++ b/src/librustc_mir/interpret/intrinsics.rs
@@ -103,7 +103,7 @@
if bits == 0 {
return err!(Intrinsic(format!("{} called on 0", intrinsic_name)));
}
- numeric_intrinsic(intrinsic_name.trim_right_matches("_nonzero"), bits, kind)?
+ numeric_intrinsic(intrinsic_name.trim_end_matches("_nonzero"), bits, kind)?
} else {
numeric_intrinsic(intrinsic_name, bits, kind)?
};
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index e32abb9..420fe26 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -29,7 +29,7 @@
use super::{
Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
- EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic,
+ EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck,
};
@@ -204,12 +204,12 @@
None => {
// Deallocating static memory -- always an error
return match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
- Some(AllocType::Function(..)) => err!(DeallocatedWrongMemoryKind(
+ Some(AllocKind::Function(..)) => err!(DeallocatedWrongMemoryKind(
"function".to_string(),
format!("{:?}", kind),
)),
- Some(AllocType::Static(..)) |
- Some(AllocType::Memory(..)) => err!(DeallocatedWrongMemoryKind(
+ Some(AllocKind::Static(..)) |
+ Some(AllocKind::Memory(..)) => err!(DeallocatedWrongMemoryKind(
"static".to_string(),
format!("{:?}", kind),
)),
@@ -326,15 +326,15 @@
) -> EvalResult<'tcx, Cow<'tcx, Allocation<M::PointerTag, M::AllocExtra>>> {
let alloc = tcx.alloc_map.lock().get(id);
let def_id = match alloc {
- Some(AllocType::Memory(mem)) => {
+ Some(AllocKind::Memory(mem)) => {
// We got tcx memory. Let the machine figure out whether and how to
// turn that into memory with the right pointer tag.
return Ok(M::adjust_static_allocation(mem, memory_extra))
}
- Some(AllocType::Function(..)) => {
+ Some(AllocKind::Function(..)) => {
return err!(DerefFunctionPointer)
}
- Some(AllocType::Static(did)) => {
+ Some(AllocKind::Static(did)) => {
did
}
None =>
@@ -435,8 +435,8 @@
}
// Could also be a fn ptr or extern static
match self.tcx.alloc_map.lock().get(id) {
- Some(AllocType::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
- Some(AllocType::Static(did)) => {
+ Some(AllocKind::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
+ Some(AllocKind::Static(did)) => {
// The only way `get` couldn't have worked here is if this is an extern static
assert!(self.tcx.is_foreign_item(did));
// Use size and align of the type
@@ -459,7 +459,7 @@
}
trace!("reading fn ptr: {}", ptr.alloc_id);
match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
- Some(AllocType::Function(instance)) => Ok(instance),
+ Some(AllocKind::Function(instance)) => Ok(instance),
_ => Err(EvalErrorKind::ExecuteMemory.into()),
}
}
@@ -557,16 +557,16 @@
Err(()) => {
// static alloc?
match self.tcx.alloc_map.lock().get(id) {
- Some(AllocType::Memory(alloc)) => {
+ Some(AllocKind::Memory(alloc)) => {
self.dump_alloc_helper(
&mut allocs_seen, &mut allocs_to_print,
msg, alloc, " (immutable)".to_owned()
);
}
- Some(AllocType::Function(func)) => {
+ Some(AllocKind::Function(func)) => {
trace!("{} {}", msg, func);
}
- Some(AllocType::Static(did)) => {
+ Some(AllocKind::Static(did)) => {
trace!("{} {:?}", msg, did);
}
None => {
@@ -638,7 +638,7 @@
// ensure llvm knows not to put this into immutable memory
alloc.mutability = mutability;
let alloc = self.tcx.intern_const_alloc(alloc);
- self.tcx.alloc_map.lock().set_id_memory(alloc_id, alloc);
+ self.tcx.alloc_map.lock().set_alloc_id_memory(alloc_id, alloc);
// recurse into inner allocations
for &(_, alloc) in alloc.relocations.values() {
// FIXME: Reusing the mutability here is likely incorrect. It is originally
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 4f17373..c7bfea8 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -17,7 +17,7 @@
use rustc::ty;
use rustc_data_structures::fx::FxHashSet;
use rustc::mir::interpret::{
- Scalar, AllocType, EvalResult, EvalErrorKind,
+ Scalar, AllocKind, EvalResult, EvalErrorKind,
};
use super::{
@@ -388,7 +388,7 @@
"integer pointer in non-ZST reference", self.path);
// Skip validation entirely for some external statics
let alloc_kind = self.ecx.tcx.alloc_map.lock().get(ptr.alloc_id);
- if let Some(AllocType::Static(did)) = alloc_kind {
+ if let Some(AllocKind::Static(did)) = alloc_kind {
// `extern static` cannot be validated as they have no body.
// FIXME: Statics from other crates are also skipped.
// They might be checked at a different type, but for now we
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index c962a24..a6239a8 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -197,7 +197,7 @@
use rustc::mir::{self, Location, Promoted};
use rustc::mir::visit::Visitor as MirVisitor;
use rustc::mir::mono::MonoItem;
-use rustc::mir::interpret::{Scalar, GlobalId, AllocType, ErrorHandled};
+use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled};
use monomorphize::{self, Instance};
use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
@@ -1161,22 +1161,22 @@
alloc_id: AllocId,
output: &mut Vec<MonoItem<'tcx>>,
) {
- let alloc_type = tcx.alloc_map.lock().get(alloc_id);
- match alloc_type {
- Some(AllocType::Static(did)) => {
+ let alloc_kind = tcx.alloc_map.lock().get(alloc_id);
+ match alloc_kind {
+ Some(AllocKind::Static(did)) => {
let instance = Instance::mono(tcx, did);
if should_monomorphize_locally(tcx, &instance) {
trace!("collecting static {:?}", did);
output.push(MonoItem::Static(did));
}
}
- Some(AllocType::Memory(alloc)) => {
+ Some(AllocKind::Memory(alloc)) => {
trace!("collecting {:?} with {:#?}", alloc_id, alloc);
for &((), inner) in alloc.relocations.values() {
collect_miri(tcx, inner, output);
}
},
- Some(AllocType::Function(fn_instance)) => {
+ Some(AllocKind::Function(fn_instance)) => {
if should_monomorphize_locally(tcx, &fn_instance) {
trace!("collecting {:?} with {:#?}", alloc_id, fn_instance);
output.push(create_fn_mono_item(fn_instance));
diff --git a/src/librustc_msan/Cargo.toml b/src/librustc_msan/Cargo.toml
index 2916567..78c39d0 100644
--- a/src/librustc_msan/Cargo.toml
+++ b/src/librustc_msan/Cargo.toml
@@ -16,4 +16,4 @@
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = "0.1.0"
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 2681295..7730239 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -295,9 +295,8 @@
Erroneous code example:
```compile_fail,E0259
-# #![feature(libc)]
extern crate core;
-extern crate libc as core;
+extern crate std as core;
fn main() {}
```
@@ -308,9 +307,8 @@
Correct example:
```
-# #![feature(libc)]
extern crate core;
-extern crate libc as other_name;
+extern crate std as other_name;
fn main() {}
```
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index ebd2c87..e449fec 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -3010,6 +3010,7 @@
// Visit all direct subpatterns of this pattern.
let outer_pat_id = pat.id;
pat.walk(&mut |pat| {
+ debug!("resolve_pattern pat={:?} node={:?}", pat, pat.node);
match pat.node {
PatKind::Ident(bmode, ident, ref opt_pat) => {
// First try to resolve the identifier as some existing
@@ -3166,6 +3167,7 @@
format!("not found in {}", mod_str),
item_span)
};
+
let code = DiagnosticId::Error(code.into());
let mut err = this.session.struct_span_err_with_code(base_span, &base_msg, code);
@@ -3189,11 +3191,22 @@
return (err, Vec::new());
}
if is_self_value(path, ns) {
+ debug!("smart_resolve_path_fragment E0424 source:{:?}", source);
+
__diagnostic_used!(E0424);
err.code(DiagnosticId::Error("E0424".into()));
- err.span_label(span, format!("`self` value is a keyword \
- only available in \
- methods with `self` parameter"));
+ err.span_label(span, match source {
+ PathSource::Pat => {
+ format!("`self` value is a keyword \
+ and may not be bound to \
+ variables or shadowed")
+ }
+ _ => {
+ format!("`self` value is a keyword \
+ only available in methods \
+ with `self` parameter")
+ }
+ });
return (err, Vec::new());
}
diff --git a/src/librustc_tsan/Cargo.toml b/src/librustc_tsan/Cargo.toml
index baadb64..f061827 100644
--- a/src/librustc_tsan/Cargo.toml
+++ b/src/librustc_tsan/Cargo.toml
@@ -16,4 +16,4 @@
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+compiler_builtins = "0.1.0"
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index f4f6b3d..db4b686 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -123,7 +123,7 @@
let sole_field_ty = sole_field.ty(self.tcx, substs);
if self.can_coerce(expr_ty, sole_field_ty) {
let variant_path = self.tcx.item_path_str(variant.did);
- Some(variant_path.trim_left_matches("std::prelude::v1::").to_string())
+ Some(variant_path.trim_start_matches("std::prelude::v1::").to_string())
} else {
None
}
@@ -519,7 +519,7 @@
let suffix_suggestion = format!(
"{}{}{}{}",
if needs_paren { "(" } else { "" },
- src.trim_right_matches(&checked_ty.to_string()),
+ src.trim_end_matches(&checked_ty.to_string()),
expected_ty,
if needs_paren { ")" } else { "" },
);
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs
index 5c0eef5..a40e56d 100644
--- a/src/librustc_typeck/check/intrinsic.rs
+++ b/src/librustc_typeck/check/intrinsic.rs
@@ -435,7 +435,8 @@
"simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)),
"simd_extract" => (2, vec![param(0), tcx.types.u32], param(1)),
"simd_cast" => (2, vec![param(0)], param(1)),
- "simd_select" => (2, vec![param(0), param(1), param(1)], param(1)),
+ "simd_select" |
+ "simd_select_bitmask" => (2, vec![param(0), param(1), param(1)], param(1)),
"simd_reduce_all" | "simd_reduce_any" => (1, vec![param(0)], tcx.types.bool),
"simd_reduce_add_ordered" | "simd_reduce_mul_ordered"
=> (2, vec![param(0), param(1)], param(1)),
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index f4d05c6..b421f07 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -20,7 +20,7 @@
use rustc::session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
use rustc::session::config::{nightly_options, build_codegen_options, build_debugging_options,
get_cmd_lint_options};
-use rustc::session::search_paths::SearchPaths;
+use rustc::session::search_paths::SearchPath;
use rustc_driver;
use rustc_target::spec::TargetTriple;
use syntax::edition::Edition;
@@ -46,7 +46,7 @@
/// How to format errors and warnings.
pub error_format: ErrorOutputType,
/// Library search paths to hand to the compiler.
- pub libs: SearchPaths,
+ pub libs: Vec<SearchPath>,
/// The list of external crates to link against.
pub externs: Externs,
/// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
@@ -295,10 +295,9 @@
}
let input = PathBuf::from(&matches.free[0]);
- let mut libs = SearchPaths::new();
- for s in &matches.opt_strs("L") {
- libs.add_path(s, error_format);
- }
+ let libs = matches.opt_strs("L").iter()
+ .map(|s| SearchPath::from_cli_opt(s, error_format))
+ .collect();
let externs = match parse_externs(&matches) {
Ok(ex) => ex,
Err(err) => {
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 047d355..b85342f 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -51,7 +51,7 @@
use passes;
pub use rustc::session::config::{Input, Options, CodegenOptions};
-pub use rustc::session::search_paths::SearchPaths;
+pub use rustc::session::search_paths::SearchPath;
pub type ExternalPaths = FxHashMap<DefId, (Vec<String>, clean::TypeKind)>;
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index 6ce02c3..37ff693 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -54,6 +54,7 @@
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}light{suffix}.css\" \
id=\"themeStyle\">\
<script src=\"{root_path}storage{suffix}.js\"></script>\
+ <noscript><link rel=\"stylesheet\" href=\"{root_path}noscript{suffix}.css\"></noscript>\
{css_extension}\
{favicon}\
{in_header}\
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 00ca4fe..536ea39 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -806,6 +806,10 @@
}
pub fn plain_summary_line(md: &str) -> String {
+ plain_summary_line_full(md, false)
+}
+
+pub fn plain_summary_line_full(md: &str, limit_length: bool) -> String {
struct ParserWrapper<'a> {
inner: Parser<'a>,
is_in: isize,
@@ -852,7 +856,21 @@
s.push_str(&t);
}
}
- s
+ if limit_length && s.chars().count() > 60 {
+ let mut len = 0;
+ let mut ret = s.split_whitespace()
+ .take_while(|p| {
+ // + 1 for the added character after the word.
+ len += p.chars().count() + 1;
+ len < 60
+ })
+ .collect::<Vec<_>>()
+ .join(" ");
+ ret.push('…');
+ ret
+ } else {
+ s
+ }
}
pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 8d7942a..c9f3aa0 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -698,7 +698,7 @@
ty: item.type_(),
name: item.name.clone().unwrap(),
path: fqp[..fqp.len() - 1].join("::"),
- desc: plain_summary_line(item.doc_value()),
+ desc: plain_summary_line_short(item.doc_value()),
parent: Some(did),
parent_idx: None,
search_type: get_index_search_type(&item),
@@ -736,7 +736,7 @@
}
let crate_doc = krate.module.as_ref().map(|module| {
- plain_summary_line(module.doc_value())
+ plain_summary_line_short(module.doc_value())
}).unwrap_or(String::new());
let mut crate_data = BTreeMap::new();
@@ -772,6 +772,9 @@
write_minify(cx.dst.join(&format!("settings{}.css", cx.shared.resource_suffix)),
static_files::SETTINGS_CSS,
options.enable_minification)?;
+ write_minify(cx.dst.join(&format!("noscript{}.css", cx.shared.resource_suffix)),
+ static_files::NOSCRIPT_CSS,
+ options.enable_minification)?;
// To avoid "light.css" to be overwritten, we'll first run over the received themes and only
// then we'll run over the "official" styles.
@@ -865,9 +868,8 @@
}
{
- let mut data = format!("var resourcesSuffix = \"{}\";\n",
- cx.shared.resource_suffix);
- data.push_str(static_files::STORAGE_JS);
+ let mut data = static_files::STORAGE_JS.to_owned();
+ data.push_str(&format!("var resourcesSuffix = \"{}\";", cx.shared.resource_suffix));
write_minify(cx.dst.join(&format!("storage{}.js", cx.shared.resource_suffix)),
&data,
options.enable_minification)?;
@@ -1481,7 +1483,7 @@
ty: item.type_(),
name: s.to_string(),
path: path.join("::"),
- desc: plain_summary_line(item.doc_value()),
+ desc: plain_summary_line_short(item.doc_value()),
parent,
parent_idx: None,
search_type: get_index_search_type(&item),
@@ -1512,7 +1514,8 @@
clean::FunctionItem(..) | clean::ModuleItem(..) |
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
clean::ConstantItem(..) | clean::StaticItem(..) |
- clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..)
+ clean::UnionItem(..) | clean::ForeignTypeItem |
+ clean::MacroItem(..) | clean::ProcMacroItem(..)
if !self.stripped_mod => {
// Re-exported items mean that the same id can show up twice
// in the rustdoc ast that we're looking at. We know,
@@ -1673,7 +1676,7 @@
ty: item.type_(),
name: item_name.to_string(),
path: path.clone(),
- desc: plain_summary_line(item.doc_value()),
+ desc: plain_summary_line_short(item.doc_value()),
parent: None,
parent_idx: None,
search_type: get_index_search_type(&item),
@@ -2388,7 +2391,13 @@
#[inline]
fn plain_summary_line(s: Option<&str>) -> String {
let line = shorter(s).replace("\n", " ");
- markdown::plain_summary_line(&line[..])
+ markdown::plain_summary_line_full(&line[..], false)
+}
+
+#[inline]
+fn plain_summary_line_short(s: Option<&str>) -> String {
+ let line = shorter(s).replace("\n", " ");
+ markdown::plain_summary_line_full(&line[..], true)
}
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
@@ -3006,6 +3015,22 @@
// Trait documentation
document(w, cx, it)?;
+ fn write_small_section_header(
+ w: &mut fmt::Formatter,
+ id: &str,
+ title: &str,
+ extra_content: &str,
+ ) -> fmt::Result {
+ write!(w, "
+ <h2 id='{0}' class='small-section-header'>\
+ {1}<a href='#{0}' class='anchor'></a>\
+ </h2>{2}", id, title, extra_content)
+ }
+
+ fn write_loading_content(w: &mut fmt::Formatter, extra_content: &str) -> fmt::Result {
+ write!(w, "{}<span class='loading-content'>Loading content...</span>", extra_content)
+ }
+
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
-> fmt::Result {
let name = m.name.as_ref().unwrap();
@@ -3026,74 +3051,45 @@
}
if !types.is_empty() {
- write!(w, "
- <h2 id='associated-types' class='small-section-header'>
- Associated Types<a href='#associated-types' class='anchor'></a>
- </h2>
- <div class='methods'>
- ")?;
+ write_small_section_header(w, "associated-types", "Associated Types",
+ "<div class='methods'>")?;
for t in &types {
trait_item(w, cx, *t, it)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
}
if !consts.is_empty() {
- write!(w, "
- <h2 id='associated-const' class='small-section-header'>
- Associated Constants<a href='#associated-const' class='anchor'></a>
- </h2>
- <div class='methods'>
- ")?;
+ write_small_section_header(w, "associated-const", "Associated Constants",
+ "<div class='methods'>")?;
for t in &consts {
trait_item(w, cx, *t, it)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
}
// Output the documentation for each function individually
if !required.is_empty() {
- write!(w, "
- <h2 id='required-methods' class='small-section-header'>
- Required Methods<a href='#required-methods' class='anchor'></a>
- </h2>
- <div class='methods'>
- ")?;
+ write_small_section_header(w, "required-methods", "Required methods",
+ "<div class='methods'>")?;
for m in &required {
trait_item(w, cx, *m, it)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
}
if !provided.is_empty() {
- write!(w, "
- <h2 id='provided-methods' class='small-section-header'>
- Provided Methods<a href='#provided-methods' class='anchor'></a>
- </h2>
- <div class='methods'>
- ")?;
+ write_small_section_header(w, "provided-methods", "Provided methods",
+ "<div class='methods'>")?;
for m in &provided {
trait_item(w, cx, *m, it)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
}
// If there are methods directly on this trait object, render them here.
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?;
let cache = cache();
- let impl_header = "\
- <h2 id='implementors' class='small-section-header'>\
- Implementors<a href='#implementors' class='anchor'></a>\
- </h2>\
- <div class='item-list' id='implementors-list'>\
- ";
-
- let synthetic_impl_header = "\
- <h2 id='synthetic-implementors' class='small-section-header'>\
- Auto implementors<a href='#synthetic-implementors' class='anchor'></a>\
- </h2>\
- <div class='item-list' id='synthetic-implementors-list'>\
- ";
let mut synthetic_types = Vec::new();
@@ -3130,11 +3126,7 @@
concrete.sort_by(compare_impl);
if !foreign.is_empty() {
- write!(w, "
- <h2 id='foreign-impls' class='small-section-header'>
- Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
- </h2>
- ")?;
+ write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "")?;
for implementor in foreign {
let assoc_link = AssocItemLink::GotoSource(
@@ -3145,33 +3137,38 @@
RenderMode::Normal, implementor.impl_item.stable_since(), false,
None)?;
}
+ write_loading_content(w, "")?;
}
- write!(w, "{}", impl_header)?;
+ write_small_section_header(w, "implementors", "Implementors",
+ "<div class='item-list' id='implementors-list'>")?;
for implementor in concrete {
render_implementor(cx, implementor, w, &implementor_dups)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
if t.auto {
- write!(w, "{}", synthetic_impl_header)?;
+ write_small_section_header(w, "synthetic-implementors", "Auto implementors",
+ "<div class='item-list' id='synthetic-implementors-list'>")?;
for implementor in synthetic {
synthetic_types.extend(
collect_paths_for_type(implementor.inner_impl().for_.clone())
);
render_implementor(cx, implementor, w, &implementor_dups)?;
}
- write!(w, "</div>")?;
+ write_loading_content(w, "</div>")?;
}
} else {
// even without any implementations to write in, we still want the heading and list, so the
// implementors javascript file pulled in below has somewhere to write the impls into
- write!(w, "{}", impl_header)?;
- write!(w, "</div>")?;
+ write_small_section_header(w, "implementors", "Implementors",
+ "<div class='item-list' id='implementors-list'>")?;
+ write_loading_content(w, "</div>")?;
if t.auto {
- write!(w, "{}", synthetic_impl_header)?;
- write!(w, "</div>")?;
+ write_small_section_header(w, "synthetic-implementors", "Auto implementors",
+ "<div class='item-list' id='synthetic-implementors-list'>")?;
+ write_loading_content(w, "</div>")?;
}
}
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 1869969..51714c3 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -30,6 +30,27 @@
};
}
+if (!DOMTokenList.prototype.add) {
+ DOMTokenList.prototype.add = function(className) {
+ if (className && !hasClass(this, className)) {
+ if (this.className && this.className.length > 0) {
+ this.className += " " + className;
+ } else {
+ this.className = className;
+ }
+ }
+ };
+}
+
+if (!DOMTokenList.prototype.remove) {
+ DOMTokenList.prototype.remove = function(className) {
+ if (className && this.className) {
+ this.className = (" " + this.className + " ").replace(" " + className + " ", " ")
+ .trim();
+ }
+ };
+}
+
(function() {
"use strict";
@@ -61,7 +82,7 @@
"attr",
"derive"];
- var search_input = document.getElementsByClassName('search-input')[0];
+ var search_input = document.getElementsByClassName("search-input")[0];
// On the search screen, so you remain on the last tab you opened.
//
@@ -75,9 +96,9 @@
var titleBeforeSearch = document.title;
function getPageId() {
- var id = document.location.href.split('#')[1];
+ var id = document.location.href.split("#")[1];
if (id) {
- return id.split('?')[0].split('&')[0];
+ return id.split("?")[0].split("&")[0];
}
return null;
}
@@ -87,9 +108,9 @@
if (elems) {
addClass(elems, "show-it");
}
- var sidebar = document.getElementsByClassName('sidebar')[0];
+ var sidebar = document.getElementsByClassName("sidebar")[0];
if (sidebar) {
- addClass(sidebar, 'mobile');
+ addClass(sidebar, "mobile");
var filler = document.getElementById("sidebar-filler");
if (!filler) {
var div = document.createElement("div");
@@ -108,13 +129,13 @@
if (elems) {
removeClass(elems, "show-it");
}
- var sidebar = document.getElementsByClassName('sidebar')[0];
- removeClass(sidebar, 'mobile');
+ var sidebar = document.getElementsByClassName("sidebar")[0];
+ removeClass(sidebar, "mobile");
var filler = document.getElementById("sidebar-filler");
if (filler) {
filler.remove();
}
- document.getElementsByTagName("body")[0].style.marginTop = '';
+ document.getElementsByTagName("body")[0].style.marginTop = "";
var themePicker = document.getElementsByClassName("theme-picker");
if (themePicker && themePicker.length > 0) {
themePicker[0].style.display = null;
@@ -125,8 +146,8 @@
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
var TY_KEYWORD = itemTypes.indexOf("keyword");
- onEach(document.getElementsByClassName('js-only'), function(e) {
- removeClass(e, 'js-only');
+ onEachLazy(document.getElementsByClassName("js-only"), function(e) {
+ removeClass(e, "js-only");
});
function getQueryStringParams() {
@@ -145,16 +166,19 @@
window.history && typeof window.history.pushState === "function";
}
+ var main = document.getElementById("main");
+
function highlightSourceLines(ev) {
// If we're in mobile mode, we should add the sidebar in any case.
hideSidebar();
+ var elem;
var search = document.getElementById("search");
var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
if (match) {
from = parseInt(match[1], 10);
to = Math.min(50000, parseInt(match[2] || match[1], 10));
from = Math.min(from, to);
- var elem = document.getElementById(from);
+ elem = document.getElementById(from);
if (!elem) {
return;
}
@@ -164,22 +188,22 @@
x.scrollIntoView();
}
}
- onEach(document.getElementsByClassName('line-numbers'), function(e) {
- onEach(e.getElementsByTagName('span'), function(i_e) {
- removeClass(i_e, 'line-highlighted');
+ onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
+ onEachLazy(e.getElementsByTagName("span"), function(i_e) {
+ removeClass(i_e, "line-highlighted");
});
});
for (i = from; i <= to; ++i) {
- addClass(document.getElementById(i), 'line-highlighted');
+ addClass(document.getElementById(i), "line-highlighted");
}
} else if (ev !== null && search && !hasClass(search, "hidden") && ev.newURL) {
addClass(search, "hidden");
- removeClass(document.getElementById("main"), "hidden");
- var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
+ removeClass(main, "hidden");
+ var hash = ev.newURL.slice(ev.newURL.indexOf("#") + 1);
if (browserSupportsHistoryApi()) {
history.replaceState(hash, "", "?search=#" + hash);
}
- var elem = document.getElementById(hash);
+ elem = document.getElementById(hash);
if (elem) {
elem.scrollIntoView();
}
@@ -190,7 +214,7 @@
var elem = document.getElementById(id);
if (elem && isHidden(elem)) {
var h3 = elem.parentNode.previousSibling;
- if (h3 && h3.tagName !== 'H3') {
+ if (h3 && h3.tagName !== "H3") {
h3 = h3.previousSibling; // skip div.docblock
}
@@ -236,7 +260,7 @@
removeClass(help, "hidden");
addClass(document.body, "blur");
}
- } else if (!hasClass(help, "hidden")) {
+ } else if (hasClass(help, "hidden") === false) {
ev.preventDefault();
addClass(help, "hidden");
removeClass(document.body, "blur");
@@ -246,12 +270,12 @@
function handleEscape(ev, help) {
hideModal();
var search = document.getElementById("search");
- if (!hasClass(help, "hidden")) {
+ if (hasClass(help, "hidden") === false) {
displayHelp(false, ev);
- } else if (!hasClass(search, "hidden")) {
+ } else if (hasClass(search, "hidden") === false) {
ev.preventDefault();
addClass(search, "hidden");
- removeClass(document.getElementById("main"), "hidden");
+ removeClass(main, "hidden");
document.title = titleBeforeSearch;
}
defocusSearchBar();
@@ -305,26 +329,27 @@
if (elem && elem.tagName === tagName) {
return elem;
}
- } while (elem = elem.parentNode);
+ elem = elem.parentNode;
+ } while (elem);
return null;
}
document.onkeypress = handleShortcut;
document.onkeydown = handleShortcut;
document.onclick = function(ev) {
- if (hasClass(ev.target, 'collapse-toggle')) {
+ if (hasClass(ev.target, "collapse-toggle")) {
collapseDocs(ev.target, "toggle");
- } else if (hasClass(ev.target.parentNode, 'collapse-toggle')) {
+ } else if (hasClass(ev.target.parentNode, "collapse-toggle")) {
collapseDocs(ev.target.parentNode, "toggle");
- } else if (ev.target.tagName === 'SPAN' && hasClass(ev.target.parentNode, 'line-numbers')) {
+ } else if (ev.target.tagName === "SPAN" && hasClass(ev.target.parentNode, "line-numbers")) {
var prev_id = 0;
var set_fragment = function(name) {
if (browserSupportsHistoryApi()) {
- history.replaceState(null, null, '#' + name);
+ history.replaceState(null, null, "#" + name);
window.hashchange();
} else {
- location.replace('#' + name);
+ location.replace("#" + name);
}
};
@@ -337,31 +362,31 @@
cur_id = tmp;
}
- set_fragment(prev_id + '-' + cur_id);
+ set_fragment(prev_id + "-" + cur_id);
} else {
prev_id = cur_id;
set_fragment(cur_id);
}
- } else if (!hasClass(document.getElementById("help"), "hidden")) {
+ } else if (hasClass(document.getElementById("help"), "hidden") === false) {
addClass(document.getElementById("help"), "hidden");
removeClass(document.body, "blur");
} else {
// Making a collapsed element visible on onhashchange seems
// too late
- var a = findParentElement(ev.target, 'A');
+ var a = findParentElement(ev.target, "A");
if (a && a.hash) {
- expandSection(a.hash.replace(/^#/, ''));
+ expandSection(a.hash.replace(/^#/, ""));
}
}
};
- var x = document.getElementsByClassName('version-selector');
+ var x = document.getElementsByClassName("version-selector");
if (x.length > 0) {
x[0].onchange = function() {
var i, match,
url = document.location.href,
- stripped = '',
+ stripped = "",
len = rootPath.match(/\.\.\//g).length + 1;
for (i = 0; i < len; ++i) {
@@ -372,7 +397,7 @@
url = url.substring(0, url.length - match[0].length);
}
- url += '/' + document.getElementsByClassName('version-selector')[0].value + stripped;
+ url += "/" + document.getElementsByClassName("version-selector")[0].value + stripped;
document.location.href = url;
};
@@ -428,7 +453,7 @@
// where you start trying to do a search, and the index loads, and
// suddenly your search is gone!
if (search_input.value === "") {
- search_input.value = params.search || '';
+ search_input.value = params.search || "";
}
/**
@@ -441,7 +466,8 @@
*/
function execQuery(query, searchWords, filterCrates) {
function itemTypeFromName(typename) {
- for (var i = 0; i < itemTypes.length; ++i) {
+ var length = itemTypes.length;
+ for (var i = 0; i < length; ++i) {
if (itemTypes[i] === typename) {
return i;
}
@@ -455,7 +481,8 @@
results = {}, results_in_args = {}, results_returned = {},
split = valLower.split("::");
- for (var z = 0; z < split.length; ++z) {
+ var length = split.length;
+ for (var z = 0; z < length; ++z) {
if (split[z] === "") {
split.splice(z, 1);
z -= 1;
@@ -464,7 +491,8 @@
function transformResults(results, isType) {
var out = [];
- for (i = 0; i < results.length; ++i) {
+ var length = results.length;
+ for (var i = 0; i < length; ++i) {
if (results[i].id > -1) {
var obj = searchIndex[results[i].id];
obj.lev = results[i].lev;
@@ -473,7 +501,7 @@
obj.displayPath = pathSplitter(res[0]);
obj.fullPath = obj.displayPath + obj.name;
// To be sure than it some items aren't considered as duplicate.
- obj.fullPath += '|' + obj.ty;
+ obj.fullPath += "|" + obj.ty;
obj.href = res[1];
out.push(obj);
if (out.length >= MAX_RESULTS) {
@@ -493,8 +521,9 @@
}
}
results = ar;
+ var i;
var nresults = results.length;
- for (var i = 0; i < nresults; ++i) {
+ for (i = 0; i < nresults; ++i) {
results[i].word = searchWords[results[i].id];
results[i].item = searchIndex[results[i].id] || {};
}
@@ -552,8 +581,8 @@
}
// sort by description (no description goes later)
- a = (aaa.item.desc === '');
- b = (bbb.item.desc === '');
+ a = (aaa.item.desc === "");
+ b = (bbb.item.desc === "");
if (a !== b) { return a - b; }
// sort by type (later occurrence in `itemTypes` goes later)
@@ -570,7 +599,8 @@
return 0;
});
- for (var i = 0; i < results.length; ++i) {
+ var length = results.length;
+ for (i = 0; i < length; ++i) {
var result = results[i];
// this validation does not make sense when searching by types
@@ -592,10 +622,10 @@
function extractGenerics(val) {
val = val.toLowerCase();
- if (val.indexOf('<') !== -1) {
- var values = val.substring(val.indexOf('<') + 1, val.lastIndexOf('>'));
+ if (val.indexOf("<") !== -1) {
+ var values = val.substring(val.indexOf("<") + 1, val.lastIndexOf(">"));
return {
- name: val.substring(0, val.indexOf('<')),
+ name: val.substring(0, val.indexOf("<")),
generics: values.split(/\s*,\s*/),
};
}
@@ -617,9 +647,11 @@
var done = 0;
// We need to find the type that matches the most to remove it in order
// to move forward.
- for (var y = 0; y < val.generics.length; ++y) {
+ var vlength = val.generics.length;
+ for (var y = 0; y < vlength; ++y) {
var lev = { pos: -1, lev: MAX_LEV_DISTANCE + 1};
- for (var x = 0; x < elems.length; ++x) {
+ var elength = elems.length;
+ for (var x = 0; x < elength; ++x) {
var tmp_lev = levenshtein(elems[x], val.generics[y]);
if (tmp_lev < lev.lev) {
lev.lev = tmp_lev;
@@ -644,6 +676,7 @@
// Check for type name and type generics (if any).
function checkType(obj, val, literalSearch) {
var lev_distance = MAX_LEV_DISTANCE + 1;
+ var x;
if (obj[NAME] === val.name) {
if (literalSearch === true) {
if (val.generics && val.generics.length !== 0) {
@@ -651,7 +684,6 @@
obj[GENERICS_DATA].length >= val.generics.length) {
var elems = obj[GENERICS_DATA].slice(0);
var allFound = true;
- var x;
for (var y = 0; allFound === true && y < val.generics.length; ++y) {
allFound = false;
@@ -685,7 +717,8 @@
// Names didn't match so let's check if one of the generic types could.
if (literalSearch === true) {
if (obj.length > GENERICS_DATA && obj[GENERICS_DATA].length > 0) {
- for (var x = 0; x < obj[GENERICS_DATA].length; ++x) {
+ var length = obj[GENERICS_DATA].length;
+ for (x = 0; x < length; ++x) {
if (obj[GENERICS_DATA][x] === val.name) {
return true;
}
@@ -693,13 +726,13 @@
}
return false;
}
- var lev_distance = Math.min(levenshtein(obj[NAME], val.name),
- lev_distance);
+ lev_distance = Math.min(levenshtein(obj[NAME], val.name), lev_distance);
if (lev_distance <= MAX_LEV_DISTANCE) {
lev_distance = Math.min(checkGenerics(obj, val), lev_distance);
} else if (obj.length > GENERICS_DATA && obj[GENERICS_DATA].length > 0) {
// We can check if the type we're looking for is inside the generics!
- for (var x = 0; x < obj[GENERICS_DATA].length; ++x) {
+ var olength = obj[GENERICS_DATA].length;
+ for (x = 0; x < olength; ++x) {
lev_distance = Math.min(levenshtein(obj[GENERICS_DATA][x], val.name),
lev_distance);
}
@@ -714,7 +747,8 @@
if (obj && obj.type && obj.type[INPUTS_DATA] &&
obj.type[INPUTS_DATA].length > 0) {
- for (var i = 0; i < obj.type[INPUTS_DATA].length; i++) {
+ var length = obj.type[INPUTS_DATA].length;
+ for (var i = 0; i < length; i++) {
var tmp = checkType(obj.type[INPUTS_DATA][i], val, literalSearch);
if (literalSearch === true && tmp === true) {
return true;
@@ -755,16 +789,18 @@
path.push(ty.parent.name.toLowerCase());
}
- if (contains.length > path.length) {
+ var length = path.length;
+ var clength = contains.length;
+ if (clength > length) {
return MAX_LEV_DISTANCE + 1;
}
- for (var i = 0; i < path.length; ++i) {
- if (i + contains.length > path.length) {
+ for (var i = 0; i < length; ++i) {
+ if (i + clength > length) {
break;
}
var lev_total = 0;
var aborted = false;
- for (var x = 0; x < contains.length; ++x) {
+ for (var x = 0; x < clength; ++x) {
var lev = levenshtein(path[i + x], contains[x]);
if (lev > MAX_LEV_DISTANCE) {
aborted = true;
@@ -773,7 +809,7 @@
lev_total += lev;
}
if (aborted === false) {
- ret_lev = Math.min(ret_lev, Math.round(lev_total / contains.length));
+ ret_lev = Math.min(ret_lev, Math.round(lev_total / clength));
}
}
return ret_lev;
@@ -810,18 +846,23 @@
// quoted values mean literal search
var nSearchWords = searchWords.length;
+ var i;
+ var ty;
+ var fullId;
+ var returned;
+ var in_args;
if ((val.charAt(0) === "\"" || val.charAt(0) === "'") &&
val.charAt(val.length - 1) === val.charAt(0))
{
val = extractGenerics(val.substr(1, val.length - 2));
- for (var i = 0; i < nSearchWords; ++i) {
+ for (i = 0; i < nSearchWords; ++i) {
if (filterCrates !== undefined && searchIndex[i].crate !== filterCrates) {
continue;
}
- var in_args = findArg(searchIndex[i], val, true);
- var returned = checkReturned(searchIndex[i], val, true);
- var ty = searchIndex[i];
- var fullId = generateId(ty);
+ in_args = findArg(searchIndex[i], val, true);
+ returned = checkReturned(searchIndex[i], val, true);
+ ty = searchIndex[i];
+ fullId = generateId(ty);
if (searchWords[i] === val.name) {
// filter type: ... queries
@@ -866,27 +907,27 @@
var input = parts[0];
// sort inputs so that order does not matter
var inputs = input.split(",").map(trimmer).sort();
- for (var i = 0; i < inputs.length; ++i) {
+ for (i = 0; i < inputs.length; ++i) {
inputs[i] = extractGenerics(inputs[i]);
}
var output = extractGenerics(parts[1]);
- for (var i = 0; i < nSearchWords; ++i) {
+ for (i = 0; i < nSearchWords; ++i) {
if (filterCrates !== undefined && searchIndex[i].crate !== filterCrates) {
continue;
}
var type = searchIndex[i].type;
- var ty = searchIndex[i];
+ ty = searchIndex[i];
if (!type) {
continue;
}
- var fullId = generateId(ty);
+ fullId = generateId(ty);
// allow searching for void (no output) functions as well
var typeOutput = type.length > OUTPUT_DATA ? type[OUTPUT_DATA].name : "";
- var returned = checkReturned(ty, output, true);
+ returned = checkReturned(ty, output, true);
if (output.name === "*" || returned === true) {
- var in_args = false;
+ in_args = false;
var module = false;
if (input === "*") {
@@ -946,14 +987,16 @@
var contains = paths.slice(0, paths.length > 1 ? paths.length - 1 : 1);
for (j = 0; j < nSearchWords; ++j) {
- var ty = searchIndex[j];
+ var lev;
+ var lev_distance;
+ ty = searchIndex[j];
if (!ty || (filterCrates !== undefined && ty.crate !== filterCrates)) {
continue;
}
var lev_distance;
var lev_add = 0;
if (paths.length > 1) {
- var lev = checkPath(contains, paths[paths.length - 1], ty);
+ lev = checkPath(contains, paths[paths.length - 1], ty);
if (lev > MAX_LEV_DISTANCE) {
continue;
} else if (lev > 0) {
@@ -961,12 +1004,12 @@
}
}
- var returned = MAX_LEV_DISTANCE + 1;
- var in_args = MAX_LEV_DISTANCE + 1;
+ returned = MAX_LEV_DISTANCE + 1;
+ in_args = MAX_LEV_DISTANCE + 1;
var index = -1;
// we want lev results to go lower than others
- var lev = MAX_LEV_DISTANCE + 1;
- var fullId = generateId(ty);
+ lev = MAX_LEV_DISTANCE + 1;
+ fullId = generateId(ty);
if (searchWords[j].indexOf(split[i]) > -1 ||
searchWords[j].indexOf(val) > -1 ||
@@ -1042,14 +1085,14 @@
}
var ret = {
- 'in_args': sortResults(results_in_args, true),
- 'returned': sortResults(results_returned, true),
- 'others': sortResults(results),
+ "in_args": sortResults(results_in_args, true),
+ "returned": sortResults(results_returned, true),
+ "others": sortResults(results),
};
if (ALIASES && ALIASES[window.currentCrate] &&
ALIASES[window.currentCrate][query.raw]) {
var aliases = ALIASES[window.currentCrate][query.raw];
- for (var i = 0; i < aliases.length; ++i) {
+ for (i = 0; i < aliases.length; ++i) {
aliases[i].is_alias = true;
aliases[i].alias = query.raw;
aliases[i].path = aliases[i].p;
@@ -1057,9 +1100,9 @@
aliases[i].displayPath = pathSplitter(res[0]);
aliases[i].fullPath = aliases[i].displayPath + aliases[i].name;
aliases[i].href = res[1];
- ret['others'].unshift(aliases[i]);
- if (ret['others'].length > MAX_RESULTS) {
- ret['others'].pop();
+ ret.others.unshift(aliases[i]);
+ if (ret.others.length > MAX_RESULTS) {
+ ret.others.pop();
}
}
}
@@ -1106,7 +1149,7 @@
matches = query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i);
if (matches) {
- type = matches[1].replace(/^const$/, 'constant');
+ type = matches[1].replace(/^const$/, "constant");
query = query.substring(matches[0].length);
}
@@ -1124,38 +1167,38 @@
var click_func = function(e) {
var el = e.target;
// to retrieve the real "owner" of the event.
- while (el.tagName !== 'TR') {
+ while (el.tagName !== "TR") {
el = el.parentNode;
}
- var dst = e.target.getElementsByTagName('a');
+ var dst = e.target.getElementsByTagName("a");
if (dst.length < 1) {
return;
}
dst = dst[0];
if (window.location.pathname === dst.pathname) {
- addClass(document.getElementById('search'), 'hidden');
- removeClass(document.getElementById('main'), 'hidden');
+ addClass(document.getElementById("search"), "hidden");
+ removeClass(main, "hidden");
document.location.href = dst.href;
}
};
var mouseover_func = function(e) {
var el = e.target;
// to retrieve the real "owner" of the event.
- while (el.tagName !== 'TR') {
+ while (el.tagName !== "TR") {
el = el.parentNode;
}
clearTimeout(hoverTimeout);
hoverTimeout = setTimeout(function() {
- onEach(document.getElementsByClassName('search-results'), function(e) {
- onEach(e.getElementsByClassName('result'), function(i_e) {
- removeClass(i_e, 'highlighted');
+ onEachLazy(document.getElementsByClassName("search-results"), function(e) {
+ onEachLazy(e.getElementsByClassName("result"), function(i_e) {
+ removeClass(i_e, "highlighted");
});
});
- addClass(el, 'highlighted');
+ addClass(el, "highlighted");
}, 20);
};
- onEach(document.getElementsByClassName('search-results'), function(e) {
- onEach(e.getElementsByClassName('result'), function(i_e) {
+ onEachLazy(document.getElementsByClassName("search-results"), function(e) {
+ onEachLazy(e.getElementsByClassName("result"), function(i_e) {
i_e.onclick = click_func;
i_e.onmouseover = mouseover_func;
});
@@ -1167,8 +1210,8 @@
var actives = [[], [], []];
// "current" is used to know which tab we're looking into.
var current = 0;
- onEach(document.getElementsByClassName('search-results'), function(e) {
- onEach(e.getElementsByClassName('highlighted'), function(e) {
+ onEachLazy(document.getElementsByClassName("search-results"), function(e) {
+ onEachLazy(e.getElementsByClassName("highlighted"), function(e) {
actives[current].push(e);
});
current += 1;
@@ -1180,25 +1223,25 @@
return;
}
- addClass(actives[currentTab][0].previousElementSibling, 'highlighted');
- removeClass(actives[currentTab][0], 'highlighted');
+ addClass(actives[currentTab][0].previousElementSibling, "highlighted");
+ removeClass(actives[currentTab][0], "highlighted");
} else if (e.which === 40) { // down
if (!actives[currentTab].length) {
- var results = document.getElementsByClassName('search-results');
+ var results = document.getElementsByClassName("search-results");
if (results.length > 0) {
- var res = results[currentTab].getElementsByClassName('result');
+ var res = results[currentTab].getElementsByClassName("result");
if (res.length > 0) {
- addClass(res[0], 'highlighted');
+ addClass(res[0], "highlighted");
}
}
} else if (actives[currentTab][0].nextElementSibling) {
- addClass(actives[currentTab][0].nextElementSibling, 'highlighted');
- removeClass(actives[currentTab][0], 'highlighted');
+ addClass(actives[currentTab][0].nextElementSibling, "highlighted");
+ removeClass(actives[currentTab][0], "highlighted");
}
} else if (e.which === 13) { // return
if (actives[currentTab].length) {
document.location.href =
- actives[currentTab][0].getElementsByTagName('a')[0].href;
+ actives[currentTab][0].getElementsByTagName("a")[0].href;
}
} else if (e.which === 9) { // tab
if (e.shiftKey) {
@@ -1210,11 +1253,11 @@
} else if (e.which === 16) { // shift
// Does nothing, it's just to avoid losing "focus" on the highlighted element.
} else if (e.which === 27) { // escape
- removeClass(actives[currentTab][0], 'highlighted');
- search_input.value = '';
+ removeClass(actives[currentTab][0], "highlighted");
+ search_input.value = "";
defocusSearchBar();
} else if (actives[currentTab].length > 0) {
- removeClass(actives[currentTab][0], 'highlighted');
+ removeClass(actives[currentTab][0], "highlighted");
}
};
}
@@ -1225,46 +1268,46 @@
var type = itemTypes[item.ty];
var name = item.name;
- if (type === 'mod') {
- displayPath = item.path + '::';
- href = rootPath + item.path.replace(/::/g, '/') + '/' +
- name + '/index.html';
+ if (type === "mod") {
+ displayPath = item.path + "::";
+ href = rootPath + item.path.replace(/::/g, "/") + "/" +
+ name + "/index.html";
} else if (type === "primitive" || type === "keyword") {
displayPath = "";
- href = rootPath + item.path.replace(/::/g, '/') +
- '/' + type + '.' + name + '.html';
+ href = rootPath + item.path.replace(/::/g, "/") +
+ "/" + type + "." + name + ".html";
} else if (type === "externcrate") {
displayPath = "";
- href = rootPath + name + '/index.html';
+ href = rootPath + name + "/index.html";
} else if (item.parent !== undefined) {
var myparent = item.parent;
- var anchor = '#' + type + '.' + name;
+ var anchor = "#" + type + "." + name;
var parentType = itemTypes[myparent.ty];
if (parentType === "primitive") {
- displayPath = myparent.name + '::';
+ displayPath = myparent.name + "::";
} else {
- displayPath = item.path + '::' + myparent.name + '::';
+ displayPath = item.path + "::" + myparent.name + "::";
}
- href = rootPath + item.path.replace(/::/g, '/') +
- '/' + parentType +
- '.' + myparent.name +
- '.html' + anchor;
+ href = rootPath + item.path.replace(/::/g, "/") +
+ "/" + parentType +
+ "." + myparent.name +
+ ".html" + anchor;
} else {
- displayPath = item.path + '::';
- href = rootPath + item.path.replace(/::/g, '/') +
- '/' + type + '.' + name + '.html';
+ displayPath = item.path + "::";
+ href = rootPath + item.path.replace(/::/g, "/") +
+ "/" + type + "." + name + ".html";
}
return [displayPath, href];
}
function escape(content) {
- var h1 = document.createElement('h1');
+ var h1 = document.createElement("h1");
h1.textContent = content;
return h1.innerHTML;
}
function pathSplitter(path) {
- var tmp = '<span>' + path.replace(/::/g, '::</span><span>');
+ var tmp = "<span>" + path.replace(/::/g, "::</span><span>");
if (tmp.endsWith("<span>")) {
return tmp.slice(0, tmp.length - 6);
}
@@ -1272,16 +1315,16 @@
}
function addTab(array, query, display) {
- var extraStyle = '';
+ var extraStyle = "";
if (display === false) {
- extraStyle = ' style="display: none;"';
+ extraStyle = " style=\"display: none;\"";
}
- var output = '';
+ var output = "";
var duplicates = {};
var length = 0;
if (array.length > 0) {
- output = '<table class="search-results"' + extraStyle + '>';
+ output = "<table class=\"search-results\"" + extraStyle + ">";
array.forEach(function(item) {
var name, type;
@@ -1297,50 +1340,50 @@
}
length += 1;
- output += '<tr class="' + type + ' result"><td>' +
- '<a href="' + item.href + '">' +
+ output += "<tr class=\"" + type + " result\"><td>" +
+ "<a href=\"" + item.href + "\">" +
(item.is_alias === true ?
- ('<span class="alias"><b>' + item.alias + ' </b></span><span ' +
- 'class="grey"><i> - see </i></span>') : '') +
- item.displayPath + '<span class="' + type + '">' +
- name + '</span></a></td><td>' +
- '<a href="' + item.href + '">' +
- '<span class="desc">' + escape(item.desc) +
- ' </span></a></td></tr>';
+ ("<span class=\"alias\"><b>" + item.alias + " </b></span><span " +
+ "class=\"grey\"><i> - see </i></span>") : "") +
+ item.displayPath + "<span class=\"" + type + "\">" +
+ name + "</span></a></td><td>" +
+ "<a href=\"" + item.href + "\">" +
+ "<span class=\"desc\">" + escape(item.desc) +
+ " </span></a></td></tr>";
});
- output += '</table>';
+ output += "</table>";
} else {
- output = '<div class="search-failed"' + extraStyle + '>No results :(<br/>' +
- 'Try on <a href="https://duckduckgo.com/?q=' +
- encodeURIComponent('rust ' + query.query) +
- '">DuckDuckGo</a>?<br/><br/>' +
- 'Or try looking in one of these:<ul><li>The <a ' +
- 'href="https://doc.rust-lang.org/reference/index.html">Rust Reference</a> for' +
- ' technical details about the language.</li><li><a ' +
- 'href="https://doc.rust-lang.org/rust-by-example/index.html">Rust By Example' +
- '</a> for expository code examples.</a></li><li>The <a ' +
- 'href="https://doc.rust-lang.org/book/index.html">Rust Book</a> for ' +
- 'introductions to language features and the language itself.</li><li><a ' +
- 'href="https://docs.rs">Docs.rs</a> for documentation of crates released on ' +
- '<a href="https://crates.io/">crates.io</a>.</li></ul></div>';
+ output = "<div class=\"search-failed\"" + extraStyle + ">No results :(<br/>" +
+ "Try on <a href=\"https://duckduckgo.com/?q=" +
+ encodeURIComponent("rust " + query.query) +
+ "\">DuckDuckGo</a>?<br/><br/>" +
+ "Or try looking in one of these:<ul><li>The <a " +
+ "href=\"https://doc.rust-lang.org/reference/index.html\">Rust Reference</a> " +
+ " for technical details about the language.</li><li><a " +
+ "href=\"https://doc.rust-lang.org/rust-by-example/index.html\">Rust By " +
+ "Example</a> for expository code examples.</a></li><li>The <a " +
+ "href=\"https://doc.rust-lang.org/book/index.html\">Rust Book</a> for " +
+ "introductions to language features and the language itself.</li><li><a " +
+ "href=\"https://docs.rs\">Docs.rs</a> for documentation of crates released on" +
+ " <a href=\"https://crates.io/\">crates.io</a>.</li></ul></div>";
}
return [output, length];
}
function makeTabHeader(tabNb, text, nbElems) {
if (currentTab === tabNb) {
- return '<div class="selected">' + text +
- ' <div class="count">(' + nbElems + ')</div></div>';
+ return "<div class=\"selected\">" + text +
+ " <div class=\"count\">(" + nbElems + ")</div></div>";
}
- return '<div>' + text + ' <div class="count">(' + nbElems + ')</div></div>';
+ return "<div>" + text + " <div class=\"count\">(" + nbElems + ")</div></div>";
}
- function showResults(results, filterCrates) {
- if (results['others'].length === 1 &&
- getCurrentValue('rustdoc-go-to-only-result') === "true") {
- var elem = document.createElement('a');
- elem.href = results['others'][0].href;
- elem.style.display = 'none';
+ function showResults(results) {
+ if (results.others.length === 1 &&
+ getCurrentValue("rustdoc-go-to-only-result") === "true") {
+ var elem = document.createElement("a");
+ elem.href = results.others[0].href;
+ elem.style.display = "none";
// For firefox, we need the element to be in the DOM so it can be clicked.
document.body.appendChild(elem);
elem.click();
@@ -1349,39 +1392,34 @@
currentResults = query.id;
- var ret_others = addTab(results['others'], query);
- var ret_in_args = addTab(results['in_args'], query, false);
- var ret_returned = addTab(results['returned'], query, false);
+ var ret_others = addTab(results.others, query);
+ var ret_in_args = addTab(results.in_args, query, false);
+ var ret_returned = addTab(results.returned, query, false);
- var filter = "";
- if (filterCrates !== undefined) {
- filter = " (in <b>" + filterCrates + "</b> crate)";
- }
-
- var output = '<h1>Results for ' + escape(query.query) +
- (query.type ? ' (type: ' + escape(query.type) + ')' : '') + filter + '</h1>' +
- '<div id="titles">' +
+ var output = "<h1>Results for " + escape(query.query) +
+ (query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" +
+ "<div id=\"titles\">" +
makeTabHeader(0, "In Names", ret_others[1]) +
makeTabHeader(1, "In Parameters", ret_in_args[1]) +
makeTabHeader(2, "In Return Types", ret_returned[1]) +
- '</div><div id="results">' +
- ret_others[0] + ret_in_args[0] + ret_returned[0] + '</div>';
+ "</div><div id=\"results\">" +
+ ret_others[0] + ret_in_args[0] + ret_returned[0] + "</div>";
- addClass(document.getElementById('main'), 'hidden');
- var search = document.getElementById('search');
- removeClass(search, 'hidden');
+ addClass(main, "hidden");
+ var search = document.getElementById("search");
+ removeClass(search, "hidden");
search.innerHTML = output;
- var tds = search.getElementsByTagName('td');
+ var tds = search.getElementsByTagName("td");
var td_width = 0;
if (tds.length > 0) {
td_width = tds[0].offsetWidth;
}
var width = search.offsetWidth - 40 - td_width;
- onEach(search.getElementsByClassName('desc'), function(e) {
- e.style.width = width + 'px';
+ onEachLazy(search.getElementsByClassName("desc"), function(e) {
+ e.style.width = width + "px";
});
initSearchNav();
- var elems = document.getElementById('titles').childNodes;
+ var elems = document.getElementById("titles").childNodes;
elems[0].onclick = function() { printTab(0); };
elems[1].onclick = function() { printTab(1); };
elems[2].onclick = function() { printTab(2); };
@@ -1389,74 +1427,74 @@
}
function execSearch(query, searchWords, filterCrates) {
+ function getSmallest(arrays, positions, notDuplicates) {
+ var start = null;
+
+ for (var it = 0; it < positions.length; ++it) {
+ if (arrays[it].length > positions[it] &&
+ (start === null || start > arrays[it][positions[it]].lev) &&
+ !notDuplicates[arrays[it][positions[it]].fullPath]) {
+ start = arrays[it][positions[it]].lev;
+ }
+ }
+ return start;
+ }
+
+ function mergeArrays(arrays) {
+ var ret = [];
+ var positions = [];
+ var notDuplicates = {};
+
+ for (var x = 0; x < arrays.length; ++x) {
+ positions.push(0);
+ }
+ while (ret.length < MAX_RESULTS) {
+ var smallest = getSmallest(arrays, positions, notDuplicates);
+
+ if (smallest === null) {
+ break;
+ }
+ for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
+ if (arrays[x].length > positions[x] &&
+ arrays[x][positions[x]].lev === smallest &&
+ !notDuplicates[arrays[x][positions[x]].fullPath]) {
+ ret.push(arrays[x][positions[x]]);
+ notDuplicates[arrays[x][positions[x]].fullPath] = true;
+ positions[x] += 1;
+ }
+ }
+ }
+ return ret;
+ }
+
var queries = query.raw.split(",");
var results = {
- 'in_args': [],
- 'returned': [],
- 'others': [],
+ "in_args": [],
+ "returned": [],
+ "others": [],
};
for (var i = 0; i < queries.length; ++i) {
- var query = queries[i].trim();
+ query = queries[i].trim();
if (query.length !== 0) {
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
- results['in_args'].push(tmp['in_args']);
- results['returned'].push(tmp['returned']);
- results['others'].push(tmp['others']);
+ results.in_args.push(tmp.in_args);
+ results.returned.push(tmp.returned);
+ results.others.push(tmp.others);
}
}
if (queries.length > 1) {
- function getSmallest(arrays, positions, notDuplicates) {
- var start = null;
-
- for (var it = 0; it < positions.length; ++it) {
- if (arrays[it].length > positions[it] &&
- (start === null || start > arrays[it][positions[it]].lev) &&
- !notDuplicates[arrays[it][positions[it]].fullPath]) {
- start = arrays[it][positions[it]].lev;
- }
- }
- return start;
- }
-
- function mergeArrays(arrays) {
- var ret = [];
- var positions = [];
- var notDuplicates = {};
-
- for (var x = 0; x < arrays.length; ++x) {
- positions.push(0);
- }
- while (ret.length < MAX_RESULTS) {
- var smallest = getSmallest(arrays, positions, notDuplicates);
-
- if (smallest === null) {
- break;
- }
- for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
- if (arrays[x].length > positions[x] &&
- arrays[x][positions[x]].lev === smallest &&
- !notDuplicates[arrays[x][positions[x]].fullPath]) {
- ret.push(arrays[x][positions[x]]);
- notDuplicates[arrays[x][positions[x]].fullPath] = true;
- positions[x] += 1;
- }
- }
- }
- return ret;
- }
-
return {
- 'in_args': mergeArrays(results['in_args']),
- 'returned': mergeArrays(results['returned']),
- 'others': mergeArrays(results['others']),
+ "in_args": mergeArrays(results.in_args),
+ "returned": mergeArrays(results.returned),
+ "others": mergeArrays(results.others),
};
} else {
return {
- 'in_args': results['in_args'][0],
- 'returned': results['returned'][0],
- 'others': results['others'][0],
+ "in_args": results.in_args[0],
+ "returned": results.returned[0],
+ "others": results.others[0],
};
}
}
@@ -1508,6 +1546,8 @@
function buildIndex(rawSearchIndex) {
searchIndex = [];
var searchWords = [];
+ var i;
+
for (var crate in rawSearchIndex) {
if (!rawSearchIndex.hasOwnProperty(crate)) { continue; }
@@ -1534,7 +1574,7 @@
// convert `paths` into an object form
var len = paths.length;
- for (var i = 0; i < len; ++i) {
+ for (i = 0; i < len; ++i) {
paths[i] = {ty: paths[i][0], name: paths[i][1]};
}
@@ -1545,9 +1585,9 @@
// operation that is cached for the life of the page state so that
// all other search operations have access to this cached data for
// faster analysis operations
- var len = items.length;
+ len = items.length;
var lastPath = "";
- for (var i = 0; i < len; ++i) {
+ for (i = 0; i < len; ++i) {
var rawRow = items[i];
var row = {crate: crate, ty: rawRow[0], name: rawRow[1],
path: rawRow[2] || lastPath, desc: rawRow[3],
@@ -1573,13 +1613,12 @@
if (browserSupportsHistoryApi()) {
history.replaceState("", "std - Rust", "?search=");
}
- var main = document.getElementById('main');
- if (hasClass(main, 'content')) {
- removeClass(main, 'hidden');
+ if (hasClass(main, "content")) {
+ removeClass(main, "hidden");
}
- var search_c = document.getElementById('search');
- if (hasClass(search_c, 'content')) {
- addClass(search_c, 'hidden');
+ var search_c = document.getElementById("search");
+ if (hasClass(search_c, "content")) {
+ addClass(search_c, "hidden");
}
} else {
searchTimeout = setTimeout(search, 500);
@@ -1620,13 +1659,12 @@
// When browsing back from search results the main page
// visibility must be reset.
if (!params.search) {
- var main = document.getElementById('main');
- if (hasClass(main, 'content')) {
- removeClass(main, 'hidden');
+ if (hasClass(main, "content")) {
+ removeClass(main, "hidden");
}
- var search_c = document.getElementById('search');
- if (hasClass(search_c, 'content')) {
- addClass(search_c, 'hidden');
+ var search_c = document.getElementById("search");
+ if (hasClass(search_c, "content")) {
+ addClass(search_c, "hidden");
}
}
// Revert to the previous title manually since the History
@@ -1643,9 +1681,9 @@
if (params.search) {
search_input.value = params.search;
} else {
- search_input.value = '';
+ search_input.value = "";
}
- // Some browsers fire 'onpopstate' for every page load
+ // Some browsers fire "onpopstate" for every page load
// (Chrome), while others fire the event only when actually
// popping a state (Firefox), which is why search() is
// called both here and at the end of the startSearch()
@@ -1660,13 +1698,13 @@
startSearch();
// Draw a convenient sidebar of known crates if we have a listing
- if (rootPath === '../' || rootPath === "./") {
- var sidebar = document.getElementsByClassName('sidebar-elems')[0];
+ if (rootPath === "../" || rootPath === "./") {
+ var sidebar = document.getElementsByClassName("sidebar-elems")[0];
if (sidebar) {
- var div = document.createElement('div');
- div.className = 'block crate';
- div.innerHTML = '<h3>Crates</h3>';
- var ul = document.createElement('ul');
+ var div = document.createElement("div");
+ div.className = "block crate";
+ div.innerHTML = "<h3>Crates</h3>";
+ var ul = document.createElement("ul");
div.appendChild(ul);
var crates = [];
@@ -1678,17 +1716,17 @@
}
crates.sort();
for (var i = 0; i < crates.length; ++i) {
- var klass = 'crate';
+ var klass = "crate";
if (rootPath !== "./" && crates[i] === window.currentCrate) {
- klass += ' current';
+ klass += " current";
}
- var link = document.createElement('a');
- link.href = rootPath + crates[i] + '/index.html';
+ var link = document.createElement("a");
+ link.href = rootPath + crates[i] + "/index.html";
link.title = rawSearchIndex[crates[i]].doc;
link.className = klass;
link.textContent = crates[i];
- var li = document.createElement('li');
+ var li = document.createElement("li");
li.appendChild(link);
ul.appendChild(li);
}
@@ -1701,41 +1739,44 @@
// delayed sidebar rendering.
function initSidebarItems(items) {
- var sidebar = document.getElementsByClassName('sidebar-elems')[0];
+ var sidebar = document.getElementsByClassName("sidebar-elems")[0];
var current = window.sidebarCurrent;
function block(shortty, longty) {
var filtered = items[shortty];
- if (!filtered) { return; }
+ if (!filtered) {
+ return;
+ }
- var div = document.createElement('div');
- div.className = 'block ' + shortty;
- var h3 = document.createElement('h3');
+ var div = document.createElement("div");
+ div.className = "block " + shortty;
+ var h3 = document.createElement("h3");
h3.textContent = longty;
div.appendChild(h3);
- var ul = document.createElement('ul');
+ var ul = document.createElement("ul");
- for (var i = 0; i < filtered.length; ++i) {
+ var length = filtered.length;
+ for (var i = 0; i < length; ++i) {
var item = filtered[i];
var name = item[0];
var desc = item[1]; // can be null
var klass = shortty;
if (name === current.name && shortty === current.ty) {
- klass += ' current';
+ klass += " current";
}
var path;
- if (shortty === 'mod') {
- path = name + '/index.html';
+ if (shortty === "mod") {
+ path = name + "/index.html";
} else {
- path = shortty + '.' + name + '.html';
+ path = shortty + "." + name + ".html";
}
- var link = document.createElement('a');
+ var link = document.createElement("a");
link.href = current.relpath + path;
link.title = desc;
link.className = klass;
link.textContent = name;
- var li = document.createElement('li');
+ var li = document.createElement("li");
li.appendChild(link);
ul.appendChild(li);
}
@@ -1763,22 +1804,25 @@
window.initSidebarItems = initSidebarItems;
window.register_implementors = function(imp) {
- var implementors = document.getElementById('implementors-list');
- var synthetic_implementors = document.getElementById('synthetic-implementors-list');
+ var implementors = document.getElementById("implementors-list");
+ var synthetic_implementors = document.getElementById("synthetic-implementors-list");
var libs = Object.getOwnPropertyNames(imp);
- for (var i = 0; i < libs.length; ++i) {
+ var llength = libs.length;
+ for (var i = 0; i < llength; ++i) {
if (libs[i] === currentCrate) { continue; }
var structs = imp[libs[i]];
+ var slength = structs.length;
struct_loop:
- for (var j = 0; j < structs.length; ++j) {
+ for (var j = 0; j < slength; ++j) {
var struct = structs[j];
var list = struct.synthetic ? synthetic_implementors : implementors;
if (struct.synthetic) {
- for (var k = 0; k < struct.types.length; k++) {
+ var stlength = struct.types.length;
+ for (var k = 0; k < stlength; k++) {
if (window.inlined_types.has(struct.types[k])) {
continue struct_loop;
}
@@ -1786,21 +1830,22 @@
}
}
- var code = document.createElement('code');
+ var code = document.createElement("code");
code.innerHTML = struct.text;
- var x = code.getElementsByTagName('a');
- for (var k = 0; k < x.length; k++) {
- var href = x[k].getAttribute('href');
- if (href && href.indexOf('http') !== 0) {
- x[k].setAttribute('href', rootPath + href);
+ var x = code.getElementsByTagName("a");
+ var xlength = x.length;
+ for (var it = 0; it < xlength; it++) {
+ var href = x[it].getAttribute("href");
+ if (href && href.indexOf("http") !== 0) {
+ x[it].setAttribute("href", rootPath + href);
}
}
- var display = document.createElement('h3');
+ var display = document.createElement("h3");
addClass(display, "impl");
- display.innerHTML = '<span class="in-band"><table class="table-display"><tbody>\
- <tr><td><code>' + code.outerHTML + '</code></td><td></td></tr></tbody></table>\
- </span>';
+ display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
+ "<tbody><tr><td><code>" + code.outerHTML + "</code></td><td></td></tr>" +
+ "</tbody></table></span>";
list.appendChild(display);
}
}
@@ -1816,47 +1861,49 @@
}
// button will collapse the section
// note that this text is also set in the HTML template in render.rs
- return "\u2212"; // "\u2212" is '−' minus sign
+ return "\u2212"; // "\u2212" is "−" minus sign
}
function onEveryMatchingChild(elem, className, func) {
if (elem && className && func) {
- for (var i = 0; i < elem.childNodes.length; i++) {
- if (hasClass(elem.childNodes[i], className)) {
- func(elem.childNodes[i]);
+ var length = elem.childNodes.length;
+ var nodes = elem.childNodes;
+ for (var i = 0; i < length; ++i) {
+ if (hasClass(nodes[i], className)) {
+ func(nodes[i]);
} else {
- onEveryMatchingChild(elem.childNodes[i], className, func);
+ onEveryMatchingChild(nodes[i], className, func);
}
}
}
}
function toggleAllDocs(pageId, fromAutoCollapse) {
- var toggle = document.getElementById("toggle-all-docs");
- if (!toggle) {
+ var innerToggle = document.getElementById("toggle-all-docs");
+ if (!innerToggle) {
return;
}
- if (hasClass(toggle, "will-expand")) {
+ if (hasClass(innerToggle, "will-expand")) {
updateLocalStorage("rustdoc-collapse", "false");
- removeClass(toggle, "will-expand");
- onEveryMatchingChild(toggle, "inner", function(e) {
+ removeClass(innerToggle, "will-expand");
+ onEveryMatchingChild(innerToggle, "inner", function(e) {
e.innerHTML = labelForToggleButton(false);
});
- toggle.title = "collapse all docs";
+ innerToggle.title = "collapse all docs";
if (fromAutoCollapse !== true) {
- onEach(document.getElementsByClassName("collapse-toggle"), function(e) {
+ onEachLazy(document.getElementsByClassName("collapse-toggle"), function(e) {
collapseDocs(e, "show");
});
}
} else {
updateLocalStorage("rustdoc-collapse", "true");
- addClass(toggle, "will-expand");
- onEveryMatchingChild(toggle, "inner", function(e) {
+ addClass(innerToggle, "will-expand");
+ onEveryMatchingChild(innerToggle, "inner", function(e) {
e.innerHTML = labelForToggleButton(true);
});
- toggle.title = "expand all docs";
+ innerToggle.title = "expand all docs";
if (fromAutoCollapse !== true) {
- onEach(document.getElementsByClassName("collapse-toggle"), function(e) {
+ onEachLazy(document.getElementsByClassName("collapse-toggle"), function(e) {
collapseDocs(e, "hide", pageId);
});
}
@@ -1870,27 +1917,58 @@
function adjustToggle(arg) {
return function(e) {
- if (hasClass(e, 'toggle-label')) {
+ if (hasClass(e, "toggle-label")) {
if (arg) {
- e.style.display = 'inline-block';
+ e.style.display = "inline-block";
} else {
- e.style.display = 'none';
+ e.style.display = "none";
}
}
- if (hasClass(e, 'inner')) {
+ if (hasClass(e, "inner")) {
e.innerHTML = labelForToggleButton(arg);
}
};
- };
+ }
- if (!hasClass(toggle.parentNode, "impl")) {
- var relatedDoc = toggle.parentNode.nextElementSibling;
+ function implHider(addOrRemove) {
+ return function(n) {
+ var is_method = hasClass(n, "method");
+ if (is_method || hasClass(n, "type")) {
+ if (is_method === true) {
+ if (addOrRemove) {
+ addClass(n, "hidden-by-impl-hider");
+ } else {
+ removeClass(n, "hidden-by-impl-hider");
+ }
+ }
+ var ns = n.nextElementSibling;
+ while (true) {
+ if (ns && (
+ hasClass(ns, "docblock") ||
+ hasClass(ns, "stability"))) {
+ if (addOrRemove) {
+ addClass(ns, "hidden-by-impl-hider");
+ } else {
+ removeClass(ns, "hidden-by-impl-hider");
+ }
+ ns = ns.nextElementSibling;
+ continue;
+ }
+ break;
+ }
+ }
+ };
+ }
+
+ var relatedDoc;
+ var action = mode;
+ if (hasClass(toggle.parentNode, "impl") === false) {
+ relatedDoc = toggle.parentNode.nextElementSibling;
if (hasClass(relatedDoc, "stability")) {
relatedDoc = relatedDoc.nextElementSibling;
}
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
- var action = mode;
- if (action === "toggle") {
+ if (mode === "toggle") {
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
action = "show";
} else {
@@ -1899,67 +1977,35 @@
}
if (action === "hide") {
addClass(relatedDoc, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(true));
- addClass(toggle.parentNode, 'collapsed');
+ onEachLazy(toggle.childNodes, adjustToggle(true));
+ addClass(toggle.parentNode, "collapsed");
} else if (action === "show") {
removeClass(relatedDoc, "hidden-by-usual-hider");
- removeClass(toggle.parentNode, 'collapsed');
- onEach(toggle.childNodes, adjustToggle(false));
+ removeClass(toggle.parentNode, "collapsed");
+ onEachLazy(toggle.childNodes, adjustToggle(false));
}
}
} else {
// we are collapsing the impl block
- function implHider(addOrRemove) {
- return function(n) {
- var is_method = hasClass(n, "method");
- if (is_method || hasClass(n, "type")) {
- if (is_method === true) {
- if (addOrRemove) {
- addClass(n, "hidden-by-impl-hider");
- } else {
- removeClass(n, "hidden-by-impl-hider");
- }
- }
- var ns = n.nextElementSibling;
- while (true) {
- if (ns && (
- hasClass(ns, "docblock") ||
- hasClass(ns, "stability"))) {
- if (addOrRemove) {
- addClass(ns, "hidden-by-impl-hider");
- } else {
- removeClass(ns, "hidden-by-impl-hider");
- }
- ns = ns.nextElementSibling;
- continue;
- }
- break;
- }
- }
- }
- }
var parentElem = toggle.parentNode;
- var relatedDoc = parentElem;
+ relatedDoc = parentElem;
var docblock = relatedDoc.nextElementSibling;
- while (!hasClass(relatedDoc, "impl-items")) {
+ while (hasClass(relatedDoc, "impl-items") === false) {
relatedDoc = relatedDoc.nextElementSibling;
}
- if ((!relatedDoc && !hasClass(docblock, "docblock")) ||
- (pageId && onEach(relatedDoc.childNodes, function(e) {
- return e.id === pageId;
- }) === true)) {
+ if ((!relatedDoc && hasClass(docblock, "docblock") === false) ||
+ (pageId && document.getElementById(pageId))) {
return;
}
// Hide all functions, but not associated types/consts
- var action = mode;
- if (action === "toggle") {
+ if (mode === "toggle") {
if (hasClass(relatedDoc, "fns-now-collapsed") ||
- hasClass(docblock, "hidden-by-impl-hider")) {
+ hasClass(docblock, "hidden-by-impl-hider")) {
action = "show";
} else {
action = "hide";
@@ -1969,13 +2015,25 @@
if (action === "show") {
removeClass(relatedDoc, "fns-now-collapsed");
removeClass(docblock, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(false));
- onEach(relatedDoc.childNodes, implHider(false));
+ onEachLazy(toggle.childNodes, adjustToggle(false));
+ onEachLazy(relatedDoc.childNodes, implHider(false));
} else if (action === "hide") {
addClass(relatedDoc, "fns-now-collapsed");
addClass(docblock, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(true));
- onEach(relatedDoc.childNodes, implHider(true));
+ onEachLazy(toggle.childNodes, adjustToggle(true));
+ onEachLazy(relatedDoc.childNodes, implHider(true));
+ }
+ }
+ }
+
+ function collapser(e, collapse) {
+ // inherent impl ids are like "impl" or impl-<number>'.
+ // they will never be hidden by default.
+ var n = e.parentElement;
+ if (n.id.match(/^impl(?:-\d+)?$/) === null) {
+ // Automatically minimize all non-inherent impls
+ if (collapse || hasClass(n, "impl")) {
+ collapseDocs(e, "hide", pageId);
}
}
}
@@ -1983,88 +2041,112 @@
function autoCollapse(pageId, collapse) {
if (collapse) {
toggleAllDocs(pageId, true);
- }
- var collapser = function(e) {
- // inherent impl ids are like 'impl' or impl-<number>'.
- // they will never be hidden by default.
- var n = e.parentElement;
- if (n.id.match(/^impl(?:-\d+)?$/) === null) {
- // Automatically minimize all non-inherent impls
- if (collapse || hasClass(n, 'impl')) {
- collapseDocs(e, "hide", pageId);
- }
- }
- };
- if (getCurrentValue('rustdoc-trait-implementations') !== "false") {
- var impl_list = document.getElementById('implementations-list');
+ } else if (getCurrentValue("rustdoc-trait-implementations") !== "false") {
+ var impl_list = document.getElementById("implementations-list");
if (impl_list !== null) {
- onEach(impl_list.getElementsByClassName("collapse-toggle"), collapser);
- }
- }
- if (getCurrentValue('rustdoc-method-docs') !== "false") {
- var implItems = document.getElementsByClassName('impl-items');
-
- if (implItems && implItems.length > 0) {
- onEach(implItems, function(elem) {
- onEach(elem.getElementsByClassName("collapse-toggle"), collapser);
+ onEachLazy(impl_list.getElementsByClassName("collapse-toggle"), function(e) {
+ collapser(e, collapse);
});
}
}
}
- var x = document.getElementById('toggle-all-docs');
- if (x) {
- x.onclick = toggleAllDocs;
+ var toggles = document.getElementById("toggle-all-docs");
+ if (toggles) {
+ toggles.onclick = toggleAllDocs;
}
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
- function checkIfThereAreMethods(elems) {
- var areThereMethods = false;
-
- onEach(elems, function(e) {
- if (hasClass(e, "method")) {
- areThereMethods = true;
- return true;
- }
- });
- return areThereMethods;
+ function createSimpleToggle(sectionIsCollapsed) {
+ var toggle = document.createElement("a");
+ toggle.href = "javascript:void(0)";
+ toggle.className = "collapse-toggle";
+ toggle.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(sectionIsCollapsed) +
+ "</span>]";
+ return toggle;
}
- var toggle = document.createElement('a');
- toggle.href = 'javascript:void(0)';
- toggle.className = 'collapse-toggle';
- toggle.innerHTML = "[<span class='inner'>" + labelForToggleButton(false) + "</span>]";
+ var toggle = createSimpleToggle(false);
var func = function(e) {
var next = e.nextElementSibling;
- if (hasClass(e, 'impl') && next && hasClass(next, 'docblock')) {
+ if (!next) {
+ return;
+ }
+ if (hasClass(next, "docblock") ||
+ (hasClass(next, "stability") &&
+ hasClass(next.nextElementSibling, "docblock"))) {
+ insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
+ }
+ };
+
+ var funcImpl = function(e) {
+ var next = e.nextElementSibling;
+ if (next && hasClass(next, "docblock")) {
next = next.nextElementSibling;
}
if (!next) {
return;
}
- if ((hasClass(e, 'method') || hasClass(e, 'associatedconstant') ||
- checkIfThereAreMethods(next.childNodes)) &&
- (hasClass(next, 'docblock') ||
- hasClass(e, 'impl') ||
- (hasClass(next, 'stability') &&
- hasClass(next.nextElementSibling, 'docblock')))) {
+ if (next.getElementsByClassName("method").length > 0 && hasClass(e, "impl")) {
insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
}
};
- onEach(document.getElementsByClassName('method'), func);
- onEach(document.getElementsByClassName('associatedconstant'), func);
- onEach(document.getElementsByClassName('impl'), func);
- onEach(document.getElementsByClassName('impl-items'), function(e) {
- onEach(e.getElementsByClassName('associatedconstant'), func);
- var hiddenElems = e.getElementsByClassName('hidden');
+
+ onEachLazy(document.getElementsByClassName("method"), func);
+ onEachLazy(document.getElementsByClassName("associatedconstant"), func);
+ onEachLazy(document.getElementsByClassName("impl"), funcImpl);
+ var impl_call = function() {};
+ if (getCurrentValue("rustdoc-method-docs") !== "false") {
+ impl_call = function(e, newToggle, pageId) {
+ if (e.id.match(/^impl(?:-\d+)?$/) === null) {
+ // Automatically minimize all non-inherent impls
+ if (hasClass(e, "impl")) {
+ collapseDocs(newToggle, "hide", pageId);
+ }
+ }
+ };
+ }
+ var pageId = getPageId();
+ var newToggle = document.createElement("a");
+ newToggle.href = "javascript:void(0)";
+ newToggle.className = "collapse-toggle hidden-default collapsed";
+ newToggle.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
+ "</span>] Show hidden undocumented items";
+ function toggleClicked() {
+ if (hasClass(this, "collapsed")) {
+ removeClass(this, "collapsed");
+ onEachLazy(this.parentNode.getElementsByClassName("hidden"), function(x) {
+ if (hasClass(x, "content") === false) {
+ removeClass(x, "hidden");
+ addClass(x, "x");
+ }
+ }, true);
+ this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(false) +
+ "</span>] Hide undocumented items";
+ } else {
+ addClass(this, "collapsed");
+ onEachLazy(this.parentNode.getElementsByClassName("x"), function(x) {
+ if (hasClass(x, "content") === false) {
+ addClass(x, "hidden");
+ removeClass(x, "x");
+ }
+ }, true);
+ this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
+ "</span>] Show hidden undocumented items";
+ }
+ }
+ onEachLazy(document.getElementsByClassName("impl-items"), function(e) {
+ onEachLazy(e.getElementsByClassName("associatedconstant"), func);
+ var hiddenElems = e.getElementsByClassName("hidden");
var needToggle = false;
- for (var i = 0; i < hiddenElems.length; ++i) {
+ var hlength = hiddenElems.length;
+ for (var i = 0; i < hlength; ++i) {
if (hasClass(hiddenElems[i], "content") === false &&
hasClass(hiddenElems[i], "docblock") === false) {
needToggle = true;
@@ -2072,46 +2154,21 @@
}
}
if (needToggle === true) {
- var newToggle = document.createElement('a');
- newToggle.href = 'javascript:void(0)';
- newToggle.className = 'collapse-toggle hidden-default collapsed';
- newToggle.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) + "</span>" +
- "] Show hidden undocumented items";
- newToggle.onclick = function() {
- if (hasClass(this, "collapsed")) {
- removeClass(this, "collapsed");
- onEach(this.parentNode.getElementsByClassName("hidden"), function(x) {
- if (hasClass(x, "content") === false) {
- removeClass(x, "hidden");
- addClass(x, "x");
- }
- }, true);
- this.innerHTML = "[<span class='inner'>" + labelForToggleButton(false) +
- "</span>] Hide undocumented items"
- } else {
- addClass(this, "collapsed");
- onEach(this.parentNode.getElementsByClassName("x"), function(x) {
- if (hasClass(x, "content") === false) {
- addClass(x, "hidden");
- removeClass(x, "x");
- }
- }, true);
- this.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) +
- "</span>] Show hidden undocumented items";
- }
- };
- e.insertBefore(newToggle, e.firstChild);
+ var inner_toggle = newToggle.cloneNode(true);
+ inner_toggle.onclick = toggleClicked;
+ e.insertBefore(inner_toggle, e.firstChild);
+ impl_call(e, inner_toggle, pageId);
}
});
function createToggle(otherMessage, fontSize, extraClass, show) {
- var span = document.createElement('span');
- span.className = 'toggle-label';
+ var span = document.createElement("span");
+ span.className = "toggle-label";
if (show) {
- span.style.display = 'none';
+ span.style.display = "none";
}
if (!otherMessage) {
- span.innerHTML = ' Expand description';
+ span.innerHTML = " Expand description";
} else {
span.innerHTML = otherMessage;
}
@@ -2123,13 +2180,13 @@
var mainToggle = toggle.cloneNode(true);
mainToggle.appendChild(span);
- var wrapper = document.createElement('div');
- wrapper.className = 'toggle-wrapper';
+ var wrapper = document.createElement("div");
+ wrapper.className = "toggle-wrapper";
if (!show) {
- addClass(wrapper, 'collapsed');
- var inner = mainToggle.getElementsByClassName('inner');
+ addClass(wrapper, "collapsed");
+ var inner = mainToggle.getElementsByClassName("inner");
if (inner && inner.length > 0) {
- inner[0].innerHTML = '+';
+ inner[0].innerHTML = "+";
}
}
if (extraClass) {
@@ -2139,21 +2196,21 @@
return wrapper;
}
- var showItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
+ var showItemDeclarations = getCurrentValue("rustdoc-item-declarations") === "false";
function buildToggleWrapper(e) {
- if (hasClass(e, 'autohide')) {
+ if (hasClass(e, "autohide")) {
var wrap = e.previousElementSibling;
- if (wrap && hasClass(wrap, 'toggle-wrapper')) {
- var toggle = wrap.childNodes[0];
- var extra = e.childNodes[0].tagName === 'H3';
+ if (wrap && hasClass(wrap, "toggle-wrapper")) {
+ var inner_toggle = wrap.childNodes[0];
+ var extra = e.childNodes[0].tagName === "H3";
- e.style.display = 'none';
- addClass(wrap, 'collapsed');
- onEach(toggle.getElementsByClassName('inner'), function(e) {
+ e.style.display = "none";
+ addClass(wrap, "collapsed");
+ onEachLazy(inner_toggle.getElementsByClassName("inner"), function(e) {
e.innerHTML = labelForToggleButton(true);
});
- onEach(toggle.getElementsByClassName('toggle-label'), function(e) {
- e.style.display = 'inline-block';
+ onEachLazy(inner_toggle.getElementsByClassName("toggle-label"), function(e) {
+ e.style.display = "inline-block";
if (extra === true) {
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
}
@@ -2161,28 +2218,28 @@
}
}
if (e.parentNode.id === "main") {
- var otherMessage = '';
+ var otherMessage = "";
var fontSize;
var extraClass;
if (hasClass(e, "type-decl")) {
fontSize = "20px";
- otherMessage = ' Show declaration';
+ otherMessage = " Show declaration";
if (showItemDeclarations === false) {
- extraClass = 'collapsed';
+ extraClass = "collapsed";
}
} else if (hasClass(e, "sub-variant")) {
- otherMessage = ' Show fields';
+ otherMessage = " Show fields";
} else if (hasClass(e, "non-exhaustive")) {
- otherMessage = ' This ';
+ otherMessage = " This ";
if (hasClass(e, "non-exhaustive-struct")) {
- otherMessage += 'struct';
+ otherMessage += "struct";
} else if (hasClass(e, "non-exhaustive-enum")) {
- otherMessage += 'enum';
+ otherMessage += "enum";
} else if (hasClass(e, "non-exhaustive-type")) {
- otherMessage += 'type';
+ otherMessage += "type";
}
- otherMessage += ' is marked as non-exhaustive';
+ otherMessage += " is marked as non-exhaustive";
} else if (hasClass(e.childNodes[0], "impl-items")) {
extraClass = "marg-left";
}
@@ -2199,21 +2256,8 @@
}
}
- onEach(document.getElementsByClassName('docblock'), buildToggleWrapper);
- onEach(document.getElementsByClassName('sub-variant'), buildToggleWrapper);
-
- function createToggleWrapper(tog) {
- var span = document.createElement('span');
- span.className = 'toggle-label';
- span.style.display = 'none';
- span.innerHTML = ' Expand attributes';
- tog.appendChild(span);
-
- var wrapper = document.createElement('div');
- wrapper.className = 'toggle-wrapper toggle-attributes';
- wrapper.appendChild(tog);
- return wrapper;
- }
+ onEachLazy(document.getElementsByClassName("docblock"), buildToggleWrapper);
+ onEachLazy(document.getElementsByClassName("sub-variant"), buildToggleWrapper);
// In the search display, allows to switch between tabs.
function printTab(nb) {
@@ -2221,24 +2265,37 @@
currentTab = nb;
}
var nb_copy = nb;
- onEach(document.getElementById('titles').childNodes, function(elem) {
+ onEachLazy(document.getElementById("titles").childNodes, function(elem) {
if (nb_copy === 0) {
- addClass(elem, 'selected');
+ addClass(elem, "selected");
} else {
- removeClass(elem, 'selected');
+ removeClass(elem, "selected");
}
nb_copy -= 1;
});
- onEach(document.getElementById('results').childNodes, function(elem) {
+ onEachLazy(document.getElementById("results").childNodes, function(elem) {
if (nb === 0) {
- elem.style.display = '';
+ elem.style.display = "";
} else {
- elem.style.display = 'none';
+ elem.style.display = "none";
}
nb -= 1;
});
}
+ function createToggleWrapper(tog) {
+ var span = document.createElement("span");
+ span.className = "toggle-label";
+ span.style.display = "none";
+ span.innerHTML = " Expand attributes";
+ tog.appendChild(span);
+
+ var wrapper = document.createElement("div");
+ wrapper.className = "toggle-wrapper toggle-attributes";
+ wrapper.appendChild(tog);
+ return wrapper;
+ }
+
// To avoid checking on "rustdoc-item-attributes" value on every loop...
var itemAttributesFunc = function() {};
if (getCurrentValue("rustdoc-item-attributes") !== "false") {
@@ -2246,8 +2303,9 @@
collapseDocs(x.previousSibling.childNodes[0], "toggle");
};
}
- onEach(document.getElementById('main').getElementsByClassName('attributes'), function(i_e) {
- i_e.parentNode.insertBefore(createToggleWrapper(toggle.cloneNode(true)), i_e);
+ var attributesToggle = createToggleWrapper(createSimpleToggle(false));
+ onEachLazy(main.getElementsByClassName("attributes"), function(i_e) {
+ i_e.parentNode.insertBefore(attributesToggle.cloneNode(true), i_e);
itemAttributesFunc(i_e);
});
@@ -2255,45 +2313,45 @@
var lineNumbersFunc = function() {};
if (getCurrentValue("rustdoc-line-numbers") === "true") {
lineNumbersFunc = function(x) {
- var count = x.textContent.split('\n').length;
+ var count = x.textContent.split("\n").length;
var elems = [];
for (var i = 0; i < count; ++i) {
elems.push(i + 1);
}
- var node = document.createElement('pre');
- addClass(node, 'line-number');
- node.innerHTML = elems.join('\n');
+ var node = document.createElement("pre");
+ addClass(node, "line-number");
+ node.innerHTML = elems.join("\n");
x.parentNode.insertBefore(node, x);
};
}
- onEach(document.getElementsByClassName('rust-example-rendered'), function(e) {
- if (hasClass(e, 'compile_fail')) {
+ onEachLazy(document.getElementsByClassName("rust-example-rendered"), function(e) {
+ if (hasClass(e, "compile_fail")) {
e.addEventListener("mouseover", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '#f00';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "#f00";
});
e.addEventListener("mouseout", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "";
});
- } else if (hasClass(e, 'ignore')) {
+ } else if (hasClass(e, "ignore")) {
e.addEventListener("mouseover", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '#ff9200';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "#ff9200";
});
e.addEventListener("mouseout", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "";
});
}
lineNumbersFunc(e);
});
function showModal(content) {
- var modal = document.createElement('div');
+ var modal = document.createElement("div");
modal.id = "important";
- addClass(modal, 'modal');
- modal.innerHTML = '<div class="modal-content"><div class="close" id="modal-close">✕</div>' +
- '<div class="whiter"></div><span class="docblock">' + content +
- '</span></div>';
- document.getElementsByTagName('body')[0].appendChild(modal);
- document.getElementById('modal-close').onclick = hideModal;
+ addClass(modal, "modal");
+ modal.innerHTML = "<div class=\"modal-content\"><div class=\"close\" id=\"modal-close\">✕" +
+ "</div><div class=\"whiter\"></div><span class=\"docblock\">" + content +
+ "</span></div>";
+ document.getElementsByTagName("body")[0].appendChild(modal);
+ document.getElementById("modal-close").onclick = hideModal;
modal.onclick = hideModal;
}
@@ -2304,7 +2362,7 @@
}
}
- onEach(document.getElementsByClassName('important-traits'), function(e) {
+ onEachLazy(document.getElementsByClassName("important-traits"), function(e) {
e.onclick = function() {
showModal(e.lastElementChild.innerHTML);
};
@@ -2312,7 +2370,7 @@
function putBackSearch(search_input) {
if (search_input.value !== "") {
- addClass(document.getElementById("main"), "hidden");
+ addClass(main, "hidden");
removeClass(document.getElementById("search"), "hidden");
if (browserSupportsHistoryApi()) {
history.replaceState(search_input.value,
@@ -2330,16 +2388,16 @@
var params = getQueryStringParams();
if (params && params.search) {
- addClass(document.getElementById("main"), "hidden");
+ addClass(main, "hidden");
var search = document.getElementById("search");
removeClass(search, "hidden");
- search.innerHTML = '<h3 style="text-align: center;">Loading search results...</h3>';
+ search.innerHTML = "<h3 style=\"text-align: center;\">Loading search results...</h3>";
}
var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0];
if (sidebar_menu) {
sidebar_menu.onclick = function() {
- var sidebar = document.getElementsByClassName('sidebar')[0];
+ var sidebar = document.getElementsByClassName("sidebar")[0];
if (hasClass(sidebar, "mobile") === true) {
hideSidebar();
} else {
@@ -2355,7 +2413,18 @@
autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true");
if (window.location.hash && window.location.hash.length > 0) {
- expandSection(window.location.hash.replace(/^#/, ''));
+ expandSection(window.location.hash.replace(/^#/, ""));
+ }
+
+ if (main) {
+ onEachLazy(main.getElementsByClassName("loading-content"), function(e) {
+ e.remove();
+ });
+ onEachLazy(main.childNodes, function(e) {
+ if (e.tagName === "H2" || e.tagName === "H3") {
+ e.nextElementSibling.style.display = "block";
+ }
+ });
}
function addSearchOptions(crates) {
@@ -2394,10 +2463,10 @@
// Sets the focus on the search bar at the top of the page
function focusSearchBar() {
- document.getElementsByClassName('search-input')[0].focus();
+ document.getElementsByClassName("search-input")[0].focus();
}
// Removes the focus from the search bar
function defocusSearchBar() {
- document.getElementsByClassName('search-input')[0].blur();
+ document.getElementsByClassName("search-input")[0].blur();
}
diff --git a/src/librustdoc/html/static/noscript.css b/src/librustdoc/html/static/noscript.css
new file mode 100644
index 0000000..f4de75f
--- /dev/null
+++ b/src/librustdoc/html/static/noscript.css
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+ * file at the top-level directory of this distribution and at
+ * http://rust-lang.org/COPYRIGHT.
+ *
+ * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+ * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+ * <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+ * option. This file may not be copied, modified, or distributed
+ * except according to those terms.
+ */
+
+#main > h2 + div, #main > h2 + h3, #main > h3 + div {
+ display: block;
+}
+
+.loading-content {
+ display: none;
+}
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index cd5a8a7..d1336b1 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -368,6 +368,10 @@
#main > .docblock h2 { font-size: 1.15em; }
#main > .docblock h3, #main > .docblock h4, #main > .docblock h5 { font-size: 1em; }
+#main > h2 + div, #main > h2 + h3, #main > h3 + div {
+ display: none;
+}
+
.docblock h1 { font-size: 1em; }
.docblock h2 { font-size: 0.95em; }
.docblock h3, .docblock h4, .docblock h5 { font-size: 0.9em; }
diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js
index e8f0c03..d1c377b 100644
--- a/src/librustdoc/html/static/storage.js
+++ b/src/librustdoc/html/static/storage.js
@@ -19,55 +19,38 @@
var savedHref = [];
function hasClass(elem, className) {
- if (elem && className && elem.className) {
- var elemClass = elem.className;
- var start = elemClass.indexOf(className);
- if (start === -1) {
- return false;
- } else if (elemClass.length === className.length) {
- return true;
- } else {
- if (start > 0 && elemClass[start - 1] !== ' ') {
- return false;
- }
- var end = start + className.length;
- return !(end < elemClass.length && elemClass[end] !== ' ');
- }
- }
- return false;
+ return elem && elem.classList && elem.classList.contains(className);
}
function addClass(elem, className) {
- if (elem && className && !hasClass(elem, className)) {
- if (elem.className && elem.className.length > 0) {
- elem.className += ' ' + className;
- } else {
- elem.className = className;
- }
+ if (!elem || !elem.classList) {
+ return;
}
+ elem.classList.add(className);
}
function removeClass(elem, className) {
- if (elem && className && elem.className) {
- elem.className = (" " + elem.className + " ").replace(" " + className + " ", " ")
- .trim();
+ if (!elem || !elem.classList) {
+ return;
}
+ elem.classList.remove(className);
}
function isHidden(elem) {
- return (elem.offsetParent === null)
+ return elem.offsetParent === null;
}
function onEach(arr, func, reversed) {
if (arr && arr.length > 0 && func) {
+ var length = arr.length;
if (reversed !== true) {
- for (var i = 0; i < arr.length; ++i) {
+ for (var i = 0; i < length; ++i) {
if (func(arr[i]) === true) {
return true;
}
}
} else {
- for (var i = arr.length - 1; i >= 0; --i) {
+ for (var i = length - 1; i >= 0; --i) {
if (func(arr[i]) === true) {
return true;
}
@@ -77,6 +60,13 @@
return false;
}
+function onEachLazy(lazyArray, func, reversed) {
+ return onEach(
+ Array.prototype.slice.call(lazyArray),
+ func,
+ reversed);
+}
+
function usableLocalStorage() {
// Check if the browser supports localStorage at all:
if (typeof(Storage) === "undefined") {
@@ -133,8 +123,8 @@
});
if (found === true) {
styleElem.href = newHref;
- updateLocalStorage('rustdoc-theme', newTheme);
+ updateLocalStorage("rustdoc-theme", newTheme);
}
}
-switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'light');
+switchTheme(currentTheme, mainTheme, getCurrentValue("rustdoc-theme") || "light");
diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs
index a485fac..f71b2a8 100644
--- a/src/librustdoc/html/static_files.rs
+++ b/src/librustdoc/html/static_files.rs
@@ -23,6 +23,9 @@
/// The file contents of `settings.css`, responsible for the items on the settings page.
pub static SETTINGS_CSS: &'static str = include_str!("static/settings.css");
+/// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled.
+pub static NOSCRIPT_CSS: &'static str = include_str!("static/noscript.css");
+
/// The file contents of `normalize.css`, included to even out standard elements between browser
/// implementations.
pub static NORMALIZE_CSS: &'static str = include_str!("static/normalize.css");
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index e0e0be7..504567e 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -35,7 +35,7 @@
for line in s.lines() {
if line.starts_with("# ") || line.starts_with("%") {
// trim the whitespace after the symbol
- metadata.push(line[1..].trim_left());
+ metadata.push(line[1..].trim_start());
count += line.len() + 1;
} else {
return (metadata, &s[count..]);
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index 29062ba..2e8bfd8 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -294,23 +294,23 @@
"trait@", "union@"].iter()
.find(|p| link.starts_with(**p)) {
kind = PathKind::Type;
- link.trim_left_matches(prefix)
+ link.trim_start_matches(prefix)
} else if let Some(prefix) =
["const@", "static@",
"value@", "function@", "mod@",
"fn@", "module@", "method@"]
.iter().find(|p| link.starts_with(**p)) {
kind = PathKind::Value;
- link.trim_left_matches(prefix)
+ link.trim_start_matches(prefix)
} else if link.ends_with("()") {
kind = PathKind::Value;
- link.trim_right_matches("()")
+ link.trim_end_matches("()")
} else if link.starts_with("macro@") {
kind = PathKind::Macro;
- link.trim_left_matches("macro@")
+ link.trim_start_matches("macro@")
} else if link.ends_with('!') {
kind = PathKind::Macro;
- link.trim_right_matches('!')
+ link.trim_end_matches('!')
} else {
&link[..]
}.trim();
diff --git a/src/librustdoc/passes/unindent_comments.rs b/src/librustdoc/passes/unindent_comments.rs
index 6d875c1..5c565bf 100644
--- a/src/librustdoc/passes/unindent_comments.rs
+++ b/src/librustdoc/passes/unindent_comments.rs
@@ -95,7 +95,7 @@
});
if !lines.is_empty() {
- let mut unindented = vec![ lines[0].trim_left().to_string() ];
+ let mut unindented = vec![ lines[0].trim_start().to_string() ];
unindented.extend_from_slice(&lines[1..].iter().map(|&line| {
if line.chars().all(|c| c.is_whitespace()) {
line.to_string()
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index be9327c..50acde6 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -21,7 +21,7 @@
use rustc::hir::intravisit;
use rustc::session::{self, CompileIncomplete, config};
use rustc::session::config::{OutputType, OutputTypes, Externs, CodegenOptions};
-use rustc::session::search_paths::{SearchPaths, PathKind};
+use rustc::session::search_paths::{SearchPath, PathKind};
use syntax::ast;
use syntax::source_map::SourceMap;
use syntax::edition::Edition;
@@ -187,7 +187,7 @@
}
fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
- cfgs: Vec<String>, libs: SearchPaths,
+ cfgs: Vec<String>, libs: Vec<SearchPath>,
cg: CodegenOptions, externs: Externs,
should_panic: bool, no_run: bool, as_test_harness: bool,
compile_fail: bool, mut error_codes: Vec<String>, opts: &TestOptions,
@@ -556,7 +556,7 @@
names: Vec<String>,
cfgs: Vec<String>,
- libs: SearchPaths,
+ libs: Vec<SearchPath>,
cg: CodegenOptions,
externs: Externs,
use_headers: bool,
@@ -571,7 +571,7 @@
}
impl Collector {
- pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, cg: CodegenOptions,
+ pub fn new(cratename: String, cfgs: Vec<String>, libs: Vec<SearchPath>, cg: CodegenOptions,
externs: Externs, use_headers: bool, opts: TestOptions,
maybe_sysroot: Option<PathBuf>, source_map: Option<Lrc<SourceMap>>,
filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition) -> Collector {
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index 004be1c..287984c 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -424,10 +424,11 @@
hir::ItemKind::Use(ref path, kind) => {
let is_glob = kind == hir::UseKind::Glob;
- // Struct and variant constructors always show up alongside their definitions, we've
- // already processed them so just discard these.
+ // Struct and variant constructors and proc macro stubs always show up alongside
+ // their definitions, we've already processed them so just discard these.
match path.def {
- Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) => return,
+ Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) |
+ Def::Macro(_, MacroKind::ProcMacroStub) => return,
_ => {}
}
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 9439dc7..b0884e1 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -3493,7 +3493,7 @@
// Helper function for counting indents
fn indents(source: &str) -> usize {
- let trimmed = source.trim_left_matches(' ');
+ let trimmed = source.trim_start_matches(' ');
source.len() - trimmed.len()
}
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml
index 274d5be..41e778b 100644
--- a/src/libstd/Cargo.toml
+++ b/src/libstd/Cargo.toml
@@ -17,13 +17,13 @@
panic_unwind = { path = "../libpanic_unwind", optional = true }
panic_abort = { path = "../libpanic_abort" }
core = { path = "../libcore" }
-libc = { path = "../rustc/libc_shim" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+libc = { version = "0.2.44", default-features = false, features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "0.1.1" }
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
unwind = { path = "../libunwind" }
[dev-dependencies]
-rand = "0.5"
+rand = "0.6.1"
[target.x86_64-apple-darwin.dependencies]
rustc_asan = { path = "../librustc_asan" }
@@ -36,10 +36,10 @@
rustc_tsan = { path = "../librustc_tsan" }
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))'.dependencies]
-dlmalloc = { path = '../rustc/dlmalloc_shim' }
+dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
[target.x86_64-fortanix-unknown-sgx.dependencies]
-fortanix-sgx-abi = { path = "../rustc/fortanix-sgx-abi_shim" }
+fortanix-sgx-abi = { version = "0.3.1", features = ['rustc-dep-of-std'] }
[build-dependencies]
cc = "1.0"
diff --git a/src/libstd/build.rs b/src/libstd/build.rs
index 9d6e8c4..7143de5 100644
--- a/src/libstd/build.rs
+++ b/src/libstd/build.rs
@@ -68,7 +68,6 @@
println!("cargo:rustc-link-lib=advapi32");
println!("cargo:rustc-link-lib=ws2_32");
println!("cargo:rustc-link-lib=userenv");
- println!("cargo:rustc-link-lib=shell32");
} else if target.contains("fuchsia") {
println!("cargo:rustc-link-lib=zircon");
println!("cargo:rustc-link-lib=fdio");
@@ -82,7 +81,12 @@
}
fn build_libbacktrace(target: &str) -> Result<(), ()> {
- let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", "")?;
+ let native = native_lib_boilerplate(
+ "../libbacktrace".as_ref(),
+ "libbacktrace",
+ "backtrace",
+ "",
+ )?;
let mut build = cc::Build::new();
build
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index a9b2711..e5c5ab8 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -533,6 +533,7 @@
Error::description(&**self)
}
+ #[allow(deprecated)]
fn cause(&self) -> Option<&dyn Error> {
Error::cause(&**self)
}
diff --git a/src/libstd/ffi/mod.rs b/src/libstd/ffi/mod.rs
index 99da73a..7e15539 100644
--- a/src/libstd/ffi/mod.rs
+++ b/src/libstd/ffi/mod.rs
@@ -72,32 +72,32 @@
//!
//! * **From Rust to C:** [`CString`] represents an owned, C-friendly
//! string: it is nul-terminated, and has no internal nul characters.
-//! Rust code can create a `CString` out of a normal string (provided
+//! Rust code can create a [`CString`] out of a normal string (provided
//! that the string doesn't have nul characters in the middle), and
-//! then use a variety of methods to obtain a raw `*mut u8` that can
+//! then use a variety of methods to obtain a raw `*mut `[`u8`] that can
//! then be passed as an argument to functions which use the C
//! conventions for strings.
//!
//! * **From C to Rust:** [`CStr`] represents a borrowed C string; it
-//! is what you would use to wrap a raw `*const u8` that you got from
-//! a C function. A `CStr` is guaranteed to be a nul-terminated array
-//! of bytes. Once you have a `CStr`, you can convert it to a Rust
-//! `&str` if it's valid UTF-8, or lossily convert it by adding
+//! is what you would use to wrap a raw `*const `[`u8`] that you got from
+//! a C function. A [`CStr`] is guaranteed to be a nul-terminated array
+//! of bytes. Once you have a [`CStr`], you can convert it to a Rust
+//! [`&str`][`str`] if it's valid UTF-8, or lossily convert it by adding
//! replacement characters.
//!
//! [`OsString`] and [`OsStr`] are useful when you need to transfer
//! strings to and from the operating system itself, or when capturing
-//! the output of external commands. Conversions between `OsString`,
-//! `OsStr` and Rust strings work similarly to those for [`CString`]
+//! the output of external commands. Conversions between [`OsString`],
+//! [`OsStr`] and Rust strings work similarly to those for [`CString`]
//! and [`CStr`].
//!
//! * [`OsString`] represents an owned string in whatever
//! representation the operating system prefers. In the Rust standard
//! library, various APIs that transfer strings to/from the operating
-//! system use `OsString` instead of plain strings. For example,
+//! system use [`OsString`] instead of plain strings. For example,
//! [`env::var_os()`] is used to query environment variables; it
-//! returns an `Option<OsString>`. If the environment variable exists
-//! you will get a `Some(os_string)`, which you can *then* try to
+//! returns an [`Option`]`<`[`OsString`]`>`. If the environment variable
+//! exists you will get a [`Some`]`(os_string)`, which you can *then* try to
//! convert to a Rust string. This yields a [`Result<>`], so that
//! your code can detect errors in case the environment variable did
//! not in fact contain valid Unicode data.
@@ -105,7 +105,7 @@
//! * [`OsStr`] represents a borrowed reference to a string in a
//! format that can be passed to the operating system. It can be
//! converted into an UTF-8 Rust string slice in a similar way to
-//! `OsString`.
+//! [`OsString`].
//!
//! # Conversions
//!
@@ -131,7 +131,7 @@
//! Additionally, on Windows [`OsString`] implements the
//! `std::os::windows:ffi::`[`OsStringExt`][windows.OsStringExt]
//! trait, which provides a [`from_wide`] method. The result of this
-//! method is an `OsString` which can be round-tripped to a Windows
+//! method is an [`OsString`] which can be round-tripped to a Windows
//! string losslessly.
//!
//! [`String`]: ../string/struct.String.html
@@ -160,6 +160,8 @@
//! [`collect`]: ../iter/trait.Iterator.html#method.collect
//! [windows.OsStringExt]: ../os/windows/ffi/trait.OsStringExt.html
//! [`from_wide`]: ../os/windows/ffi/trait.OsStringExt.html#tymethod.from_wide
+//! [`Option`]: ../option/enum.Option.html
+//! [`Some`]: ../option/enum.Option.html#variant.Some
#![stable(feature = "rust1", since = "1.0.0")]
@@ -174,7 +176,6 @@
#[stable(feature = "raw_os", since = "1.1.0")]
pub use core::ffi::c_void;
-#[cfg(not(stage0))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index 8289721..766142f 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -536,17 +536,42 @@
///
/// # Examples
///
- /// Calling `to_string_lossy` on an `OsStr` with valid unicode:
+ /// Calling `to_string_lossy` on an `OsStr` with invalid unicode:
///
/// ```
- /// use std::ffi::OsStr;
+ /// // Note, due to differences in how Unix and Windows represent strings,
+ /// // we are forced to complicate this example, setting up example `OsStr`s
+ /// // with different source data and via different platform extensions.
+ /// // Understand that in reality you could end up with such example invalid
+ /// // sequences simply through collecting user command line arguments, for
+ /// // example.
///
- /// let os_str = OsStr::new("foo");
- /// assert_eq!(os_str.to_string_lossy(), "foo");
+ /// #[cfg(any(unix, target_os = "redox"))] {
+ /// use std::ffi::OsStr;
+ /// use std::os::unix::ffi::OsStrExt;
+ ///
+ /// // Here, the values 0x66 and 0x6f correspond to 'f' and 'o'
+ /// // respectively. The value 0x80 is a lone continuation byte, invalid
+ /// // in a UTF-8 sequence.
+ /// let source = [0x66, 0x6f, 0x80, 0x6f];
+ /// let os_str = OsStr::from_bytes(&source[..]);
+ ///
+ /// assert_eq!(os_str.to_string_lossy(), "fo�o");
+ /// }
+ /// #[cfg(windows)] {
+ /// use std::ffi::OsString;
+ /// use std::os::windows::prelude::*;
+ ///
+ /// // Here the values 0x0066 and 0x006f correspond to 'f' and 'o'
+ /// // respectively. The value 0xD800 is a lone surrogate half, invalid
+ /// // in a UTF-16 sequence.
+ /// let source = [0x0066, 0x006f, 0xD800, 0x006f];
+ /// let os_string = OsString::from_wide(&source[..]);
+ /// let os_str = os_string.as_os_str();
+ ///
+ /// assert_eq!(os_str.to_string_lossy(), "fo�o");
+ /// }
/// ```
- ///
- /// Had `os_str` contained invalid unicode, the `to_string_lossy` call might
- /// have returned `"fo�"`.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn to_string_lossy(&self) -> Cow<str> {
self.inner.to_string_lossy()
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index b6a0ce6..d581ba1 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -2089,7 +2089,7 @@
use fs::{self, File, OpenOptions};
use io::{ErrorKind, SeekFrom};
use path::Path;
- use rand::{StdRng, FromEntropy, RngCore};
+ use rand::{rngs::StdRng, FromEntropy, RngCore};
use str;
use sys_common::io::test::{TempDir, tmpdir};
use thread;
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index 32e2996..d3844eb 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -555,6 +555,7 @@
}
}
+ #[allow(deprecated)]
fn cause(&self) -> Option<&dyn error::Error> {
match self.repr {
Repr::Os(..) => None,
diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs
index c2aaeb9..24965ff 100644
--- a/src/libstd/io/lazy.rs
+++ b/src/libstd/io/lazy.rs
@@ -26,7 +26,6 @@
unsafe impl<T> Sync for Lazy<T> {}
impl<T> Lazy<T> {
- #[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Lazy<T> {
Lazy {
lock: Mutex::new(),
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 90c8eaf..0febbe5 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -271,6 +271,7 @@
#![feature(libc)]
#![feature(link_args)]
#![feature(linkage)]
+#![cfg_attr(not(stage0), feature(min_const_unsafe_fn))]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![feature(nll)]
@@ -317,10 +318,6 @@
#![default_lib_allocator]
-#[cfg(stage0)]
-#[global_allocator]
-static ALLOC: alloc::System = alloc::System;
-
// Explicitly import the prelude. The compiler uses this same unstable attribute
// to import the prelude implicitly when building crates that depend on std.
#[prelude_import]
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs
index 099b4d6..3eacc7a 100644
--- a/src/libstd/panic.rs
+++ b/src/libstd/panic.rs
@@ -264,7 +264,7 @@
#[cfg(target_has_atomic = "64")]
#[unstable(feature = "integer_atomics", issue = "32976")]
impl RefUnwindSafe for atomic::AtomicI64 {}
-#[cfg(all(not(stage0), target_has_atomic = "128"))]
+#[cfg(target_has_atomic = "128")]
#[unstable(feature = "integer_atomics", issue = "32976")]
impl RefUnwindSafe for atomic::AtomicI128 {}
@@ -283,7 +283,7 @@
#[cfg(target_has_atomic = "64")]
#[unstable(feature = "integer_atomics", issue = "32976")]
impl RefUnwindSafe for atomic::AtomicU64 {}
-#[cfg(all(not(stage0), target_has_atomic = "128"))]
+#[cfg(target_has_atomic = "128")]
#[unstable(feature = "integer_atomics", issue = "32976")]
impl RefUnwindSafe for atomic::AtomicU128 {}
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index 6b47ba6..b6180fb 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -209,7 +209,8 @@
if let Some(format) = log_backtrace {
let _ = backtrace::print(err, format);
} else if FIRST_PANIC.compare_and_swap(true, false, Ordering::SeqCst) {
- let _ = writeln!(err, "note: Run with `RUST_BACKTRACE=1` for a backtrace.");
+ let _ = writeln!(err, "note: Run with `RUST_BACKTRACE=1` \
+ environment variable to display a backtrace.");
}
}
};
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index 3b2366a..7c1654f 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -426,7 +426,7 @@
/// ## 3. Get it from C.
///
/// ```
-/// # #![feature(libc)]
+/// # #![feature(rustc_private)]
/// extern crate libc;
///
/// use std::mem;
diff --git a/src/libstd/sys/cloudabi/condvar.rs b/src/libstd/sys/cloudabi/condvar.rs
index ccf848a..3229d98 100644
--- a/src/libstd/sys/cloudabi/condvar.rs
+++ b/src/libstd/sys/cloudabi/condvar.rs
@@ -13,7 +13,7 @@
use sync::atomic::{AtomicU32, Ordering};
use sys::cloudabi::abi;
use sys::mutex::{self, Mutex};
-use sys::time::dur2intervals;
+use sys::time::checked_dur2intervals;
use time::Duration;
extern "C" {
@@ -114,6 +114,8 @@
// Call into the kernel to wait on the condition variable.
let condvar = self.condvar.get();
+ let timeout = checked_dur2intervals(&dur)
+ .expect("overflow converting duration to nanoseconds");
let subscriptions = [
abi::subscription {
type_: abi::eventtype::CONDVAR,
@@ -132,7 +134,7 @@
union: abi::subscription_union {
clock: abi::subscription_clock {
clock_id: abi::clockid::MONOTONIC,
- timeout: dur2intervals(&dur),
+ timeout,
..mem::zeroed()
},
},
diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs
index a76e1fa..1773214 100644
--- a/src/libstd/sys/cloudabi/thread.rs
+++ b/src/libstd/sys/cloudabi/thread.rs
@@ -16,7 +16,7 @@
use mem;
use ptr;
use sys::cloudabi::abi;
-use sys::time::dur2intervals;
+use sys::time::checked_dur2intervals;
use sys_common::thread::*;
use time::Duration;
@@ -70,13 +70,15 @@
}
pub fn sleep(dur: Duration) {
+ let timeout = checked_dur2intervals(&dur)
+ .expect("overflow converting duration to nanoseconds");
unsafe {
let subscription = abi::subscription {
type_: abi::eventtype::CLOCK,
union: abi::subscription_union {
clock: abi::subscription_clock {
clock_id: abi::clockid::MONOTONIC,
- timeout: dur2intervals(&dur),
+ timeout,
..mem::zeroed()
},
},
diff --git a/src/libstd/sys/cloudabi/time.rs b/src/libstd/sys/cloudabi/time.rs
index a442d1e..c9fea18 100644
--- a/src/libstd/sys/cloudabi/time.rs
+++ b/src/libstd/sys/cloudabi/time.rs
@@ -19,15 +19,10 @@
t: abi::timestamp,
}
-fn checked_dur2intervals(dur: &Duration) -> Option<abi::timestamp> {
+pub fn checked_dur2intervals(dur: &Duration) -> Option<abi::timestamp> {
dur.as_secs()
- .checked_mul(NSEC_PER_SEC)
- .and_then(|nanos| nanos.checked_add(dur.subsec_nanos() as abi::timestamp))
-}
-
-pub fn dur2intervals(dur: &Duration) -> abi::timestamp {
- checked_dur2intervals(dur)
- .expect("overflow converting duration to nanoseconds")
+ .checked_mul(NSEC_PER_SEC)?
+ .checked_add(dur.subsec_nanos() as abi::timestamp)
}
impl Instant {
@@ -47,20 +42,16 @@
Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32)
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant {
- t: self.t
- .checked_add(dur2intervals(other))
- .expect("overflow when adding duration to instant"),
- }
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant {
+ t: self.t.checked_add(checked_dur2intervals(other)?)?,
+ })
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant {
- t: self.t
- .checked_sub(dur2intervals(other))
- .expect("overflow when subtracting duration from instant"),
- }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant {
+ t: self.t.checked_sub(checked_dur2intervals(other)?)?,
+ })
}
}
@@ -95,23 +86,16 @@
}
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- self.checked_add_duration(other)
- .expect("overflow when adding duration to instant")
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- checked_dur2intervals(other)
- .and_then(|d| self.t.checked_add(d))
- .map(|t| SystemTime {t})
+ Some(SystemTime {
+ t: self.t.checked_add(checked_dur2intervals(other)?)?,
+ })
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime {
- t: self.t
- .checked_sub(dur2intervals(other))
- .expect("overflow when subtracting duration from instant"),
- }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime {
+ t: self.t.checked_sub(checked_dur2intervals(other)?)?,
+ })
}
}
diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs
index beff8d2..cb2eab5 100644
--- a/src/libstd/sys/redox/time.rs
+++ b/src/libstd/sys/redox/time.rs
@@ -41,10 +41,6 @@
}
}
- fn add_duration(&self, other: &Duration) -> Timespec {
- self.checked_add_duration(other).expect("overflow when adding duration to time")
- }
-
fn checked_add_duration(&self, other: &Duration) -> Option<Timespec> {
let mut secs = other
.as_secs()
@@ -67,27 +63,25 @@
})
}
- fn sub_duration(&self, other: &Duration) -> Timespec {
+ fn checked_sub_duration(&self, other: &Duration) -> Option<Timespec> {
let mut secs = other
.as_secs()
.try_into() // <- target type would be `i64`
.ok()
- .and_then(|secs| self.t.tv_sec.checked_sub(secs))
- .expect("overflow when subtracting duration from time");
+ .and_then(|secs| self.t.tv_sec.checked_sub(secs))?;
// Similar to above, nanos can't overflow.
let mut nsec = self.t.tv_nsec as i32 - other.subsec_nanos() as i32;
if nsec < 0 {
nsec += NSEC_PER_SEC as i32;
- secs = secs.checked_sub(1).expect("overflow when subtracting \
- duration from time");
+ secs = secs.checked_sub(1)?;
}
- Timespec {
+ Some(Timespec {
t: syscall::TimeSpec {
tv_sec: secs,
tv_nsec: nsec as i32,
},
- }
+ })
}
}
@@ -150,12 +144,12 @@
})
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant { t: self.t.add_duration(other) }
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant { t: self.t.checked_add_duration(other)? })
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant { t: self.t.sub_duration(other) }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant { t: self.t.checked_sub_duration(other)? })
}
}
@@ -178,16 +172,12 @@
self.t.sub_timespec(&other.t)
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.add_duration(other) }
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- self.t.checked_add_duration(other).map(|t| SystemTime { t })
+ Some(SystemTime { t: self.t.checked_add_duration(other)? })
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.sub_duration(other) }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime { t: self.t.checked_sub_duration(other)? })
}
}
diff --git a/src/libstd/sys/sgx/abi/mem.rs b/src/libstd/sys/sgx/abi/mem.rs
index 508f2ff..bf32c71 100644
--- a/src/libstd/sys/sgx/abi/mem.rs
+++ b/src/libstd/sys/sgx/abi/mem.rs
@@ -34,13 +34,6 @@
base
}
-pub fn is_enclave_range(p: *const u8, len: usize) -> bool {
- let start=p as u64;
- let end=start + (len as u64);
- start >= image_base() &&
- end <= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant
-}
-
pub fn is_user_range(p: *const u8, len: usize) -> bool {
let start=p as u64;
let end=start + (len as u64);
diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs
index 2bc32c9..d1d180e 100644
--- a/src/libstd/sys/sgx/abi/usercalls/mod.rs
+++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs
@@ -33,14 +33,6 @@
}
}
-pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
- unsafe {
- let mut userbuf = alloc::User::<ByteBuffer>::uninitialized();
- raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?;
- Ok(copy_user_buffer(&userbuf))
- }
-}
-
pub fn write(fd: Fd, buf: &[u8]) -> IoResult<usize> {
unsafe {
let userbuf = alloc::User::new_from_enclave(buf);
diff --git a/src/libstd/sys/sgx/condvar.rs b/src/libstd/sys/sgx/condvar.rs
index d3e8165..940f50f 100644
--- a/src/libstd/sys/sgx/condvar.rs
+++ b/src/libstd/sys/sgx/condvar.rs
@@ -18,7 +18,6 @@
}
impl Condvar {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Condvar {
Condvar { inner: SpinMutex::new(WaitVariable::new(())) }
}
diff --git a/src/libstd/sys/sgx/mutex.rs b/src/libstd/sys/sgx/mutex.rs
index 6633611..994cf91 100644
--- a/src/libstd/sys/sgx/mutex.rs
+++ b/src/libstd/sys/sgx/mutex.rs
@@ -20,7 +20,6 @@
// Implementation according to “Operating Systems: Three Easy Pieces”, chapter 28
impl Mutex {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Mutex {
Mutex { inner: SpinMutex::new(WaitVariable::new(false)) }
}
@@ -79,7 +78,6 @@
}
impl ReentrantMutex {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn uninitialized() -> ReentrantMutex {
ReentrantMutex {
inner: SpinMutex::new(WaitVariable::new(ReentrantLock { owner: None, count: 0 }))
diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs
index 7b6970b..a1551db 100644
--- a/src/libstd/sys/sgx/rwlock.rs
+++ b/src/libstd/sys/sgx/rwlock.rs
@@ -21,7 +21,6 @@
//unsafe impl Sync for RWLock {} // FIXME
impl RWLock {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> RWLock {
RWLock {
readers: SpinMutex::new(WaitVariable::new(None)),
diff --git a/src/libstd/sys/sgx/time.rs b/src/libstd/sys/sgx/time.rs
index b01c992..196e1a9 100644
--- a/src/libstd/sys/sgx/time.rs
+++ b/src/libstd/sys/sgx/time.rs
@@ -28,12 +28,12 @@
self.0 - other.0
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant(self.0 + *other)
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant(self.0.checked_add(*other)?))
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant(self.0 - *other)
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant(self.0.checked_sub(*other)?))
}
}
@@ -47,15 +47,11 @@
self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0)
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- SystemTime(self.0 + *other)
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- self.0.checked_add(*other).map(|d| SystemTime(d))
+ Some(SystemTime(self.0.checked_add(*other)?))
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime(self.0 - *other)
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime(self.0.checked_sub(*other)?))
}
}
diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs
index ec1135b..ef0def1 100644
--- a/src/libstd/sys/sgx/waitqueue.rs
+++ b/src/libstd/sys/sgx/waitqueue.rs
@@ -50,7 +50,6 @@
}
impl<T> WaitVariable<T> {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new(var: T) -> Self {
WaitVariable {
queue: WaitQueue::new(),
@@ -137,7 +136,6 @@
}
impl WaitQueue {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Self {
WaitQueue {
inner: UnsafeList::new()
@@ -255,7 +253,6 @@
}
impl<T> UnsafeList<T> {
- #[unstable(feature = "sgx_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Self {
unsafe {
UnsafeList {
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs
index 7e65bbd..af2f199 100644
--- a/src/libstd/sys/unix/ext/fs.rs
+++ b/src/libstd/sys/unix/ext/fs.rs
@@ -348,7 +348,7 @@
/// # Examples
///
/// ```no_run
- /// # #![feature(libc)]
+ /// # #![feature(rustc_private)]
/// extern crate libc;
/// use std::fs::OpenOptions;
/// use std::os::unix::fs::OpenOptionsExt;
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs
index 1f9539c..8f8aaa8 100644
--- a/src/libstd/sys/unix/time.rs
+++ b/src/libstd/sys/unix/time.rs
@@ -42,10 +42,6 @@
}
}
- fn add_duration(&self, other: &Duration) -> Timespec {
- self.checked_add_duration(other).expect("overflow when adding duration to time")
- }
-
fn checked_add_duration(&self, other: &Duration) -> Option<Timespec> {
let mut secs = other
.as_secs()
@@ -68,27 +64,25 @@
})
}
- fn sub_duration(&self, other: &Duration) -> Timespec {
+ fn checked_sub_duration(&self, other: &Duration) -> Option<Timespec> {
let mut secs = other
.as_secs()
.try_into() // <- target type would be `libc::time_t`
.ok()
- .and_then(|secs| self.t.tv_sec.checked_sub(secs))
- .expect("overflow when subtracting duration from time");
+ .and_then(|secs| self.t.tv_sec.checked_sub(secs))?;
// Similar to above, nanos can't overflow.
let mut nsec = self.t.tv_nsec as i32 - other.subsec_nanos() as i32;
if nsec < 0 {
nsec += NSEC_PER_SEC as i32;
- secs = secs.checked_sub(1).expect("overflow when subtracting \
- duration from time");
+ secs = secs.checked_sub(1)?;
}
- Timespec {
+ Some(Timespec {
t: libc::timespec {
tv_sec: secs,
tv_nsec: nsec as _,
},
- }
+ })
}
}
@@ -165,18 +159,16 @@
Duration::new(nanos / NSEC_PER_SEC, (nanos % NSEC_PER_SEC) as u32)
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant {
- t: self.t.checked_add(dur2intervals(other))
- .expect("overflow when adding duration to instant"),
- }
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant {
+ t: self.t.checked_add(checked_dur2intervals(other)?)?,
+ })
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant {
- t: self.t.checked_sub(dur2intervals(other))
- .expect("overflow when subtracting duration from instant"),
- }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant {
+ t: self.t.checked_sub(checked_dur2intervals(other)?)?,
+ })
}
}
@@ -199,16 +191,12 @@
self.t.sub_timespec(&other.t)
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.add_duration(other) }
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- self.t.checked_add_duration(other).map(|t| SystemTime { t })
+ Some(SystemTime { t: self.t.checked_add_duration(other)? })
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.sub_duration(other) }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime { t: self.t.checked_sub_duration(other)? })
}
}
@@ -236,12 +224,12 @@
}
}
- fn dur2intervals(dur: &Duration) -> u64 {
+ fn checked_dur2intervals(dur: &Duration) -> Option<u64> {
+ let nanos = dur.as_secs()
+ .checked_mul(NSEC_PER_SEC)?
+ .checked_add(dur.subsec_nanos() as u64)?;
let info = info();
- let nanos = dur.as_secs().checked_mul(NSEC_PER_SEC).and_then(|nanos| {
- nanos.checked_add(dur.subsec_nanos() as u64)
- }).expect("overflow converting duration to nanoseconds");
- mul_div_u64(nanos, info.denom as u64, info.numer as u64)
+ Some(mul_div_u64(nanos, info.denom as u64, info.numer as u64))
}
fn info() -> &'static libc::mach_timebase_info {
@@ -299,12 +287,12 @@
})
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant { t: self.t.add_duration(other) }
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant { t: self.t.checked_add_duration(other)? })
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant { t: self.t.sub_duration(other) }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant { t: self.t.checked_sub_duration(other)? })
}
}
@@ -327,16 +315,12 @@
self.t.sub_timespec(&other.t)
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.add_duration(other) }
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- self.t.checked_add_duration(other).map(|t| SystemTime { t })
+ Some(SystemTime { t: self.t.checked_add_duration(other)? })
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime { t: self.t.sub_duration(other) }
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime { t: self.t.checked_sub_duration(other)? })
}
}
diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs
index 991e817..cc56773 100644
--- a/src/libstd/sys/wasm/time.rs
+++ b/src/libstd/sys/wasm/time.rs
@@ -28,12 +28,12 @@
self.0 - other.0
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
- Instant(self.0 + *other)
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant(self.0.checked_add(*other)?))
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
- Instant(self.0 - *other)
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
+ Some(Instant(self.0.checked_sub(*other)?))
}
}
@@ -47,15 +47,11 @@
self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0)
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- SystemTime(self.0 + *other)
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- self.0.checked_add(*other).map(|d| SystemTime(d))
+ Some(SystemTime(self.0.checked_add(*other)?))
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- SystemTime(self.0 - *other)
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ Some(SystemTime(self.0.checked_sub(*other)?))
}
}
diff --git a/src/libstd/sys/windows/args.rs b/src/libstd/sys/windows/args.rs
index 4784633..9e9198e 100644
--- a/src/libstd/sys/windows/args.rs
+++ b/src/libstd/sys/windows/args.rs
@@ -11,12 +11,14 @@
#![allow(dead_code)] // runtime init functions not used during testing
use os::windows::prelude::*;
+use sys::windows::os::current_exe;
use sys::c;
-use slice;
-use ops::Range;
use ffi::OsString;
-use libc::{c_int, c_void};
use fmt;
+use vec;
+use core::iter;
+use slice;
+use path::PathBuf;
pub unsafe fn init(_argc: isize, _argv: *const *const u8) { }
@@ -24,20 +26,146 @@
pub fn args() -> Args {
unsafe {
- let mut nArgs: c_int = 0;
- let lpCmdLine = c::GetCommandLineW();
- let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs);
+ let lp_cmd_line = c::GetCommandLineW();
+ let parsed_args_list = parse_lp_cmd_line(
+ lp_cmd_line as *const u16,
+ || current_exe().map(PathBuf::into_os_string).unwrap_or_else(|_| OsString::new()));
- // szArcList can be NULL if CommandLinToArgvW failed,
- // but in that case nArgs is 0 so we won't actually
- // try to read a null pointer
- Args { cur: szArgList, range: 0..(nArgs as isize) }
+ Args { parsed_args_list: parsed_args_list.into_iter() }
}
}
+/// Implements the Windows command-line argument parsing algorithm.
+///
+/// Microsoft's documentation for the Windows CLI argument format can be found at
+/// <https://docs.microsoft.com/en-us/previous-versions//17w5ykft(v=vs.85)>.
+///
+/// Windows includes a function to do this in shell32.dll,
+/// but linking with that DLL causes the process to be registered as a GUI application.
+/// GUI applications add a bunch of overhead, even if no windows are drawn. See
+/// <https://randomascii.wordpress.com/2018/12/03/a-not-called-function-can-cause-a-5x-slowdown/>.
+///
+/// This function was tested for equivalence to the shell32.dll implementation in
+/// Windows 10 Pro v1803, using an exhaustive test suite available at
+/// <https://gist.github.com/notriddle/dde431930c392e428055b2dc22e638f5> or
+/// <https://paste.gg/p/anonymous/47d6ed5f5bd549168b1c69c799825223>.
+unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_name: F)
+ -> Vec<OsString> {
+ const BACKSLASH: u16 = '\\' as u16;
+ const QUOTE: u16 = '"' as u16;
+ const TAB: u16 = '\t' as u16;
+ const SPACE: u16 = ' ' as u16;
+ let mut ret_val = Vec::new();
+ if lp_cmd_line.is_null() || *lp_cmd_line == 0 {
+ ret_val.push(exe_name());
+ return ret_val;
+ }
+ let mut cmd_line = {
+ let mut end = 0;
+ while *lp_cmd_line.offset(end) != 0 {
+ end += 1;
+ }
+ slice::from_raw_parts(lp_cmd_line, end as usize)
+ };
+ // The executable name at the beginning is special.
+ cmd_line = match cmd_line[0] {
+ // The executable name ends at the next quote mark,
+ // no matter what.
+ QUOTE => {
+ let args = {
+ let mut cut = cmd_line[1..].splitn(2, |&c| c == QUOTE);
+ if let Some(exe) = cut.next() {
+ ret_val.push(OsString::from_wide(exe));
+ }
+ cut.next()
+ };
+ if let Some(args) = args {
+ args
+ } else {
+ return ret_val;
+ }
+ }
+ // Implement quirk: when they say whitespace here,
+ // they include the entire ASCII control plane:
+ // "However, if lpCmdLine starts with any amount of whitespace, CommandLineToArgvW
+ // will consider the first argument to be an empty string. Excess whitespace at the
+ // end of lpCmdLine is ignored."
+ 0...SPACE => {
+ ret_val.push(OsString::new());
+ &cmd_line[1..]
+ },
+ // The executable name ends at the next whitespace,
+ // no matter what.
+ _ => {
+ let args = {
+ let mut cut = cmd_line.splitn(2, |&c| c > 0 && c <= SPACE);
+ if let Some(exe) = cut.next() {
+ ret_val.push(OsString::from_wide(exe));
+ }
+ cut.next()
+ };
+ if let Some(args) = args {
+ args
+ } else {
+ return ret_val;
+ }
+ }
+ };
+ let mut cur = Vec::new();
+ let mut in_quotes = false;
+ let mut was_in_quotes = false;
+ let mut backslash_count: usize = 0;
+ for &c in cmd_line {
+ match c {
+ // backslash
+ BACKSLASH => {
+ backslash_count += 1;
+ was_in_quotes = false;
+ },
+ QUOTE if backslash_count % 2 == 0 => {
+ cur.extend(iter::repeat(b'\\' as u16).take(backslash_count / 2));
+ backslash_count = 0;
+ if was_in_quotes {
+ cur.push('"' as u16);
+ was_in_quotes = false;
+ } else {
+ was_in_quotes = in_quotes;
+ in_quotes = !in_quotes;
+ }
+ }
+ QUOTE if backslash_count % 2 != 0 => {
+ cur.extend(iter::repeat(b'\\' as u16).take(backslash_count / 2));
+ backslash_count = 0;
+ was_in_quotes = false;
+ cur.push(b'"' as u16);
+ }
+ SPACE | TAB if !in_quotes => {
+ cur.extend(iter::repeat(b'\\' as u16).take(backslash_count));
+ if !cur.is_empty() || was_in_quotes {
+ ret_val.push(OsString::from_wide(&cur[..]));
+ cur.truncate(0);
+ }
+ backslash_count = 0;
+ was_in_quotes = false;
+ }
+ _ => {
+ cur.extend(iter::repeat(b'\\' as u16).take(backslash_count));
+ backslash_count = 0;
+ was_in_quotes = false;
+ cur.push(c);
+ }
+ }
+ }
+ cur.extend(iter::repeat(b'\\' as u16).take(backslash_count));
+ // include empty quoted strings at the end of the arguments list
+ if !cur.is_empty() || was_in_quotes || in_quotes {
+ ret_val.push(OsString::from_wide(&cur[..]));
+ }
+ ret_val
+}
+
pub struct Args {
- range: Range<isize>,
- cur: *mut *mut u16,
+ parsed_args_list: vec::IntoIter<OsString>,
}
pub struct ArgsInnerDebug<'a> {
@@ -46,19 +174,7 @@
impl<'a> fmt::Debug for ArgsInnerDebug<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("[")?;
- let mut first = true;
- for i in self.args.range.clone() {
- if !first {
- f.write_str(", ")?;
- }
- first = false;
-
- // Here we do allocation which could be avoided.
- fmt::Debug::fmt(&unsafe { os_string_from_ptr(*self.args.cur.offset(i)) }, f)?;
- }
- f.write_str("]")?;
- Ok(())
+ self.args.parsed_args_list.as_slice().fmt(f)
}
}
@@ -70,38 +186,82 @@
}
}
-unsafe fn os_string_from_ptr(ptr: *mut u16) -> OsString {
- let mut len = 0;
- while *ptr.offset(len) != 0 { len += 1; }
-
- // Push it onto the list.
- let ptr = ptr as *const u16;
- let buf = slice::from_raw_parts(ptr, len as usize);
- OsStringExt::from_wide(buf)
-}
-
impl Iterator for Args {
type Item = OsString;
- fn next(&mut self) -> Option<OsString> {
- self.range.next().map(|i| unsafe { os_string_from_ptr(*self.cur.offset(i)) } )
- }
- fn size_hint(&self) -> (usize, Option<usize>) { self.range.size_hint() }
+ fn next(&mut self) -> Option<OsString> { self.parsed_args_list.next() }
+ fn size_hint(&self) -> (usize, Option<usize>) { self.parsed_args_list.size_hint() }
}
impl DoubleEndedIterator for Args {
- fn next_back(&mut self) -> Option<OsString> {
- self.range.next_back().map(|i| unsafe { os_string_from_ptr(*self.cur.offset(i)) } )
- }
+ fn next_back(&mut self) -> Option<OsString> { self.parsed_args_list.next_back() }
}
impl ExactSizeIterator for Args {
- fn len(&self) -> usize { self.range.len() }
+ fn len(&self) -> usize { self.parsed_args_list.len() }
}
-impl Drop for Args {
- fn drop(&mut self) {
- // self.cur can be null if CommandLineToArgvW previously failed,
- // but LocalFree ignores NULL pointers
- unsafe { c::LocalFree(self.cur as *mut c_void); }
+#[cfg(test)]
+mod tests {
+ use sys::windows::args::*;
+ use ffi::OsString;
+
+ fn chk(string: &str, parts: &[&str]) {
+ let mut wide: Vec<u16> = OsString::from(string).encode_wide().collect();
+ wide.push(0);
+ let parsed = unsafe {
+ parse_lp_cmd_line(wide.as_ptr() as *const u16, || OsString::from("TEST.EXE"))
+ };
+ let expected: Vec<OsString> = parts.iter().map(|k| OsString::from(k)).collect();
+ assert_eq!(parsed.as_slice(), expected.as_slice());
+ }
+
+ #[test]
+ fn empty() {
+ chk("", &["TEST.EXE"]);
+ chk("\0", &["TEST.EXE"]);
+ }
+
+ #[test]
+ fn single_words() {
+ chk("EXE one_word", &["EXE", "one_word"]);
+ chk("EXE a", &["EXE", "a"]);
+ chk("EXE 😅", &["EXE", "😅"]);
+ chk("EXE 😅🤦", &["EXE", "😅🤦"]);
+ }
+
+ #[test]
+ fn official_examples() {
+ chk(r#"EXE "abc" d e"#, &["EXE", "abc", "d", "e"]);
+ chk(r#"EXE a\\\b d"e f"g h"#, &["EXE", r#"a\\\b"#, "de fg", "h"]);
+ chk(r#"EXE a\\\"b c d"#, &["EXE", r#"a\"b"#, "c", "d"]);
+ chk(r#"EXE a\\\\"b c" d e"#, &["EXE", r#"a\\b c"#, "d", "e"]);
+ }
+
+ #[test]
+ fn whitespace_behavior() {
+ chk(r#" test"#, &["", "test"]);
+ chk(r#" test"#, &["", "test"]);
+ chk(r#" test test2"#, &["", "test", "test2"]);
+ chk(r#" test test2"#, &["", "test", "test2"]);
+ chk(r#"test test2 "#, &["test", "test2"]);
+ chk(r#"test test2 "#, &["test", "test2"]);
+ chk(r#"test "#, &["test"]);
+ }
+
+ #[test]
+ fn genius_quotes() {
+ chk(r#"EXE "" """#, &["EXE", "", ""]);
+ chk(r#"EXE "" """"#, &["EXE", "", "\""]);
+ chk(
+ r#"EXE "this is """all""" in the same argument""#,
+ &["EXE", "this is \"all\" in the same argument"]
+ );
+ chk(r#"EXE "a"""#, &["EXE", "a\""]);
+ chk(r#"EXE "a"" a"#, &["EXE", "a\"", "a"]);
+ // quotes cannot be escaped in command names
+ chk(r#""EXE" check"#, &["EXE", "check"]);
+ chk(r#""EXE check""#, &["EXE check"]);
+ chk(r#""EXE """for""" check"#, &["EXE ", r#"for""#, "check"]);
+ chk(r#""EXE \"for\" check"#, &[r#"EXE \"#, r#"for""#, "check"]);
}
}
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs
index c84874a..fa21f45 100644
--- a/src/libstd/sys/windows/c.rs
+++ b/src/libstd/sys/windows/c.rs
@@ -1035,9 +1035,6 @@
pub fn SetLastError(dwErrCode: DWORD);
pub fn GetCommandLineW() -> *mut LPCWSTR;
- pub fn LocalFree(ptr: *mut c_void);
- pub fn CommandLineToArgvW(lpCmdLine: *mut LPCWSTR,
- pNumArgs: *mut c_int) -> *mut *mut u16;
pub fn GetTempPathW(nBufferLength: DWORD,
lpBuffer: LPCWSTR) -> DWORD;
pub fn OpenProcessToken(ProcessHandle: HANDLE,
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 2be30e6..84ef62e 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -76,7 +76,7 @@
match String::from_utf16(&buf[..res]) {
Ok(mut msg) => {
// Trim trailing CRLF inserted by FormatMessageW
- let len = msg.trim_right().len();
+ let len = msg.trim_end().len();
msg.truncate(len);
msg
},
diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs
index c809a0b..bb2c97e 100644
--- a/src/libstd/sys/windows/time.rs
+++ b/src/libstd/sys/windows/time.rs
@@ -68,30 +68,27 @@
Duration::new(nanos / NANOS_PER_SEC, (nanos % NANOS_PER_SEC) as u32)
}
- pub fn add_duration(&self, other: &Duration) -> Instant {
+ pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
let freq = frequency() as u64;
- let t = other.as_secs().checked_mul(freq).and_then(|i| {
- (self.t as u64).checked_add(i)
- }).and_then(|i| {
- i.checked_add(mul_div_u64(other.subsec_nanos() as u64, freq,
- NANOS_PER_SEC))
- }).expect("overflow when adding duration to time");
- Instant {
+ let t = other.as_secs()
+ .checked_mul(freq)?
+ .checked_add(mul_div_u64(other.subsec_nanos() as u64, freq, NANOS_PER_SEC))?
+ .checked_add(self.t as u64)?;
+ Some(Instant {
t: t as c::LARGE_INTEGER,
- }
+ })
}
- pub fn sub_duration(&self, other: &Duration) -> Instant {
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
let freq = frequency() as u64;
let t = other.as_secs().checked_mul(freq).and_then(|i| {
(self.t as u64).checked_sub(i)
}).and_then(|i| {
- i.checked_sub(mul_div_u64(other.subsec_nanos() as u64, freq,
- NANOS_PER_SEC))
- }).expect("overflow when subtracting duration from time");
- Instant {
+ i.checked_sub(mul_div_u64(other.subsec_nanos() as u64, freq, NANOS_PER_SEC))
+ })?;
+ Some(Instant {
t: t as c::LARGE_INTEGER,
- }
+ })
}
}
@@ -127,20 +124,14 @@
}
}
- pub fn add_duration(&self, other: &Duration) -> SystemTime {
- self.checked_add_duration(other).expect("overflow when adding duration to time")
- }
-
pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
- checked_dur2intervals(other)
- .and_then(|d| self.intervals().checked_add(d))
- .map(|i| SystemTime::from_intervals(i))
+ let intervals = self.intervals().checked_add(checked_dur2intervals(other)?)?;
+ Some(SystemTime::from_intervals(intervals))
}
- pub fn sub_duration(&self, other: &Duration) -> SystemTime {
- let intervals = self.intervals().checked_sub(dur2intervals(other))
- .expect("overflow when subtracting from time");
- SystemTime::from_intervals(intervals)
+ pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> {
+ let intervals = self.intervals().checked_sub(checked_dur2intervals(other)?)?;
+ Some(SystemTime::from_intervals(intervals))
}
}
@@ -184,16 +175,12 @@
}
}
-fn checked_dur2intervals(d: &Duration) -> Option<i64> {
- d.as_secs()
- .checked_mul(INTERVALS_PER_SEC)
- .and_then(|i| i.checked_add(d.subsec_nanos() as u64 / 100))
- .and_then(|i| i.try_into().ok())
-}
-
-fn dur2intervals(d: &Duration) -> i64 {
- checked_dur2intervals(d)
- .expect("overflow when converting duration to intervals")
+fn checked_dur2intervals(dur: &Duration) -> Option<i64> {
+ dur.as_secs()
+ .checked_mul(INTERVALS_PER_SEC)?
+ .checked_add(dur.subsec_nanos() as u64 / 100)?
+ .try_into()
+ .ok()
}
fn intervals2dur(intervals: u64) -> Duration {
diff --git a/src/libstd/sys_common/condvar.rs b/src/libstd/sys_common/condvar.rs
index 16bf080..b6f29dd 100644
--- a/src/libstd/sys_common/condvar.rs
+++ b/src/libstd/sys_common/condvar.rs
@@ -25,7 +25,6 @@
///
/// Behavior is undefined if the condition variable is moved after it is
/// first used with any of the functions below.
- #[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Condvar { Condvar(imp::Condvar::new()) }
/// Prepares the condition variable for use.
diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs
index 8768423..c6d531c 100644
--- a/src/libstd/sys_common/mutex.rs
+++ b/src/libstd/sys_common/mutex.rs
@@ -27,7 +27,6 @@
/// Also, until `init` is called, behavior is undefined if this
/// mutex is ever used reentrantly, i.e., `raw_lock` or `try_lock`
/// are called by the thread currently holding the lock.
- #[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Mutex { Mutex(imp::Mutex::new()) }
/// Prepare the mutex for use.
diff --git a/src/libstd/sys_common/rwlock.rs b/src/libstd/sys_common/rwlock.rs
index a430c25..71a4f01 100644
--- a/src/libstd/sys_common/rwlock.rs
+++ b/src/libstd/sys_common/rwlock.rs
@@ -22,7 +22,6 @@
///
/// Behavior is undefined if the reader-writer lock is moved after it is
/// first used with any of the functions below.
- #[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> RWLock { RWLock(imp::RWLock::new()) }
/// Acquires shared access to the underlying lock, blocking the current
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 6678104..63cede7 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -208,6 +208,22 @@
pub fn elapsed(&self) -> Duration {
Instant::now() - *self
}
+
+ /// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as
+ /// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
+ /// otherwise.
+ #[unstable(feature = "time_checked_add", issue = "55940")]
+ pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
+ self.0.checked_add_duration(&duration).map(|t| Instant(t))
+ }
+
+ /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
+ /// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
+ /// otherwise.
+ #[unstable(feature = "time_checked_add", issue = "55940")]
+ pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
+ self.0.checked_sub_duration(&duration).map(|t| Instant(t))
+ }
}
#[stable(feature = "time2", since = "1.8.0")]
@@ -215,7 +231,8 @@
type Output = Instant;
fn add(self, other: Duration) -> Instant {
- Instant(self.0.add_duration(&other))
+ self.checked_add(other)
+ .expect("overflow when adding duration to instant")
}
}
@@ -231,7 +248,8 @@
type Output = Instant;
fn sub(self, other: Duration) -> Instant {
- Instant(self.0.sub_duration(&other))
+ self.checked_sub(other)
+ .expect("overflow when subtracting duration from instant")
}
}
@@ -365,6 +383,14 @@
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime> {
self.0.checked_add_duration(&duration).map(|t| SystemTime(t))
}
+
+ /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
+ /// `SystemTime` (which means it's inside the bounds of the underlying data structure), `None`
+ /// otherwise.
+ #[unstable(feature = "time_checked_add", issue = "55940")]
+ pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime> {
+ self.0.checked_sub_duration(&duration).map(|t| SystemTime(t))
+ }
}
#[stable(feature = "time2", since = "1.8.0")]
@@ -372,7 +398,8 @@
type Output = SystemTime;
fn add(self, dur: Duration) -> SystemTime {
- SystemTime(self.0.add_duration(&dur))
+ self.checked_add(dur)
+ .expect("overflow when adding duration to instant")
}
}
@@ -388,7 +415,8 @@
type Output = SystemTime;
fn sub(self, dur: Duration) -> SystemTime {
- SystemTime(self.0.sub_duration(&dur))
+ self.checked_sub(dur)
+ .expect("overflow when subtracting duration from instant")
}
}
@@ -521,6 +549,20 @@
let second = Duration::new(1, 0);
assert_almost_eq!(a - second + second, a);
+ assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a);
+
+ // checked_add_duration will not panic on overflow
+ let mut maybe_t = Some(Instant::now());
+ let max_duration = Duration::from_secs(u64::max_value());
+ // in case `Instant` can store `>= now + max_duration`.
+ for _ in 0..2 {
+ maybe_t = maybe_t.and_then(|t| t.checked_add(max_duration));
+ }
+ assert_eq!(maybe_t, None);
+
+ // checked_add_duration calculates the right time and will work for another year
+ let year = Duration::from_secs(60 * 60 * 24 * 365);
+ assert_eq!(a + year, a.checked_add(year).unwrap());
}
#[test]
@@ -557,6 +599,7 @@
.duration(), second);
assert_almost_eq!(a - second + second, a);
+ assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a);
// A difference of 80 and 800 years cannot fit inside a 32-bit time_t
if !(cfg!(unix) && ::mem::size_of::<::libc::time_t>() <= 4) {
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs
index 1229db9..3b88767 100644
--- a/src/libsyntax/diagnostics/plugin.rs
+++ b/src/libsyntax/diagnostics/plugin.rs
@@ -141,6 +141,7 @@
])
}
+#[allow(deprecated)]
pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
span: Span,
token_tree: &[TokenTree])
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index eb71003..10c451e 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -15,7 +15,7 @@
use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
use source_map::{SourceMap, FilePathMapping};
use syntax_pos::{Span, SourceFile, FileName, MultiSpan};
-use errors::{Handler, ColorConfig, Diagnostic, DiagnosticBuilder};
+use errors::{FatalError, Level, Handler, ColorConfig, Diagnostic, DiagnosticBuilder};
use feature_gate::UnstableFeatures;
use parse::parser::Parser;
use ptr::P;
@@ -192,6 +192,14 @@
source_file_to_parser(sess, file_to_source_file(sess, path, None))
}
+/// Create a new parser, returning buffered diagnostics if the file doesn't
+/// exist or from lexing the initial token stream.
+pub fn maybe_new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path)
+ -> Result<Parser<'a>, Vec<Diagnostic>> {
+ let file = try_file_to_source_file(sess, path, None).map_err(|db| vec![db])?;
+ maybe_source_file_to_parser(sess, file)
+}
+
/// Given a session, a crate config, a path, and a span, add
/// the file at the given path to the source_map, and return a parser.
/// On an error, use the given span as the source of the problem.
@@ -237,17 +245,30 @@
// base abstractions
/// Given a session and a path and an optional span (for error reporting),
+/// add the path to the session's source_map and return the new source_file or
+/// error when a file can't be read.
+fn try_file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
+ -> Result<Lrc<SourceFile>, Diagnostic> {
+ sess.source_map().load_file(path)
+ .map_err(|e| {
+ let msg = format!("couldn't read {}: {}", path.display(), e);
+ let mut diag = Diagnostic::new(Level::Fatal, &msg);
+ if let Some(sp) = spanopt {
+ diag.set_span(sp);
+ }
+ diag
+ })
+}
+
+/// Given a session and a path and an optional span (for error reporting),
/// add the path to the session's source_map and return the new source_file.
fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
-> Lrc<SourceFile> {
- match sess.source_map().load_file(path) {
+ match try_file_to_source_file(sess, path, spanopt) {
Ok(source_file) => source_file,
- Err(e) => {
- let msg = format!("couldn't read {}: {}", path.display(), e);
- match spanopt {
- Some(sp) => sess.span_diagnostic.span_fatal(sp, &msg).raise(),
- None => sess.span_diagnostic.fatal(&msg).raise()
- }
+ Err(d) => {
+ DiagnosticBuilder::new_diagnostic(&sess.span_diagnostic, d).emit();
+ FatalError.raise();
}
}
}
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 8e4d3c0..ed74665 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -207,6 +207,10 @@
Eof,
}
+// `Token` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(target_arch = "x86_64")]
+static_assert!(MEM_SIZE_OF_STATEMENT: mem::size_of::<Token>() == 16);
+
impl Token {
pub fn interpolated(nt: Nonterminal) -> Token {
Token::Interpolated(Lrc::new((nt, LazyTokenStream::new())))
diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs
index 4500812..9a34312 100644
--- a/src/libsyntax/source_map.rs
+++ b/src/libsyntax/source_map.rs
@@ -579,7 +579,7 @@
match self.span_to_prev_source(sp) {
Err(_) => None,
Ok(source) => source.split('\n').last().map(|last_line| {
- last_line.len() - last_line.trim_left().len()
+ last_line.len() - last_line.trim_start().len()
})
}
}
@@ -593,7 +593,7 @@
/// if no character could be found or if an error occurred while retrieving the code snippet.
pub fn span_extend_to_prev_char(&self, sp: Span, c: char) -> Span {
if let Ok(prev_source) = self.span_to_prev_source(sp) {
- let prev_source = prev_source.rsplit(c).nth(0).unwrap_or("").trim_left();
+ let prev_source = prev_source.rsplit(c).nth(0).unwrap_or("").trim_start();
if !prev_source.is_empty() && !prev_source.contains('\n') {
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
}
@@ -613,7 +613,7 @@
for ws in &[" ", "\t", "\n"] {
let pat = pat.to_owned() + ws;
if let Ok(prev_source) = self.span_to_prev_source(sp) {
- let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_left();
+ let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_start();
if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) {
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
}
@@ -627,7 +627,7 @@
pub fn span_until_char(&self, sp: Span, c: char) -> Span {
match self.span_to_snippet(sp) {
Ok(snippet) => {
- let snippet = snippet.split(c).nth(0).unwrap_or("").trim_right();
+ let snippet = snippet.split(c).nth(0).unwrap_or("").trim_end();
if !snippet.is_empty() && !snippet.contains('\n') {
sp.with_hi(BytePos(sp.lo().0 + snippet.len() as u32))
} else {
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 8b7ffa4..9aafb9f 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -24,10 +24,13 @@
#![feature(nll)]
#![feature(non_exhaustive)]
#![feature(optin_builtin_traits)]
+#![feature(rustc_attrs)]
#![feature(specialization)]
+#![feature(step_trait)]
#![cfg_attr(not(stage0), feature(stdsimd))]
extern crate arena;
+#[macro_use]
extern crate rustc_data_structures;
#[macro_use]
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index 05c5387..b720db8 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -14,6 +14,7 @@
use arena::DroplessArena;
use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::indexed_vec::Idx;
use serialize::{Decodable, Decoder, Encodable, Encoder};
use std::fmt;
@@ -57,7 +58,7 @@
}
pub fn without_first_quote(self) -> Ident {
- Ident::new(Symbol::intern(self.as_str().trim_left_matches('\'')), self.span)
+ Ident::new(Symbol::intern(self.as_str().trim_start_matches('\'')), self.span)
}
/// "Normalize" ident for use in comparisons using "item hygiene".
@@ -143,9 +144,18 @@
}
}
-/// A symbol is an interned or gensymed string.
+/// A symbol is an interned or gensymed string. The use of newtype_index! means
+/// that Option<Symbol> only takes up 4 bytes, because newtype_index! reserves
+/// the last 256 values for tagging purposes.
+///
+/// Note that Symbol cannot be a newtype_index! directly because it implements
+/// fmt::Debug, Encodable, and Decodable in special ways.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
-pub struct Symbol(u32);
+pub struct Symbol(SymbolIndex);
+
+newtype_index! {
+ pub struct SymbolIndex { .. }
+}
// The interner is pointed to by a thread local value which is only set on the main thread
// with parallelization is disabled. So we don't allow `Symbol` to transfer between threads
@@ -156,6 +166,10 @@
impl !Sync for Symbol { }
impl Symbol {
+ const fn new(n: u32) -> Self {
+ Symbol(SymbolIndex::from_u32_const(n))
+ }
+
/// Maps a string to its interned representation.
pub fn intern(string: &str) -> Self {
with_interner(|interner| interner.intern(string))
@@ -189,7 +203,7 @@
}
pub fn as_u32(self) -> u32 {
- self.0
+ self.0.as_u32()
}
}
@@ -197,7 +211,7 @@
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let is_gensymed = with_interner(|interner| interner.is_gensymed(*self));
if is_gensymed {
- write!(f, "{}({})", self, self.0)
+ write!(f, "{}({:?})", self, self.0)
} else {
write!(f, "{}", self)
}
@@ -229,6 +243,9 @@
}
// The `&'static str`s in this type actually point into the arena.
+//
+// Note that normal symbols are indexed upward from 0, and gensyms are indexed
+// downward from SymbolIndex::MAX_AS_U32.
#[derive(Default)]
pub struct Interner {
arena: DroplessArena,
@@ -243,7 +260,7 @@
for &string in init {
if string == "" {
// We can't allocate empty strings in the arena, so handle this here.
- let name = Symbol(this.strings.len() as u32);
+ let name = Symbol::new(this.strings.len() as u32);
this.names.insert("", name);
this.strings.push("");
} else {
@@ -258,7 +275,7 @@
return name;
}
- let name = Symbol(self.strings.len() as u32);
+ let name = Symbol::new(self.strings.len() as u32);
// `from_utf8_unchecked` is safe since we just allocated a `&str` which is known to be
// UTF-8.
@@ -276,10 +293,10 @@
}
pub fn interned(&self, symbol: Symbol) -> Symbol {
- if (symbol.0 as usize) < self.strings.len() {
+ if (symbol.0.as_usize()) < self.strings.len() {
symbol
} else {
- self.interned(self.gensyms[(!0 - symbol.0) as usize])
+ self.interned(self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize])
}
}
@@ -290,17 +307,17 @@
fn gensymed(&mut self, symbol: Symbol) -> Symbol {
self.gensyms.push(symbol);
- Symbol(!0 - self.gensyms.len() as u32 + 1)
+ Symbol::new(SymbolIndex::MAX_AS_U32 - self.gensyms.len() as u32 + 1)
}
fn is_gensymed(&mut self, symbol: Symbol) -> bool {
- symbol.0 as usize >= self.strings.len()
+ symbol.0.as_usize() >= self.strings.len()
}
pub fn get(&self, symbol: Symbol) -> &str {
- match self.strings.get(symbol.0 as usize) {
+ match self.strings.get(symbol.0.as_usize()) {
Some(string) => string,
- None => self.get(self.gensyms[(!0 - symbol.0) as usize]),
+ None => self.get(self.gensyms[(SymbolIndex::MAX_AS_U32 - symbol.0.as_u32()) as usize]),
}
}
}
@@ -324,7 +341,7 @@
$(
#[allow(non_upper_case_globals)]
pub const $konst: Keyword = Keyword {
- ident: Ident::with_empty_ctxt(super::Symbol($index))
+ ident: Ident::with_empty_ctxt(super::Symbol::new($index))
};
)*
@@ -709,19 +726,19 @@
fn interner_tests() {
let mut i: Interner = Interner::default();
// first one is zero:
- assert_eq!(i.intern("dog"), Symbol(0));
+ assert_eq!(i.intern("dog"), Symbol::new(0));
// re-use gets the same entry:
- assert_eq!(i.intern("dog"), Symbol(0));
+ assert_eq!(i.intern("dog"), Symbol::new(0));
// different string gets a different #:
- assert_eq!(i.intern("cat"), Symbol(1));
- assert_eq!(i.intern("cat"), Symbol(1));
+ assert_eq!(i.intern("cat"), Symbol::new(1));
+ assert_eq!(i.intern("cat"), Symbol::new(1));
// dog is still at zero
- assert_eq!(i.intern("dog"), Symbol(0));
- assert_eq!(i.gensym("zebra"), Symbol(4294967295));
- // gensym of same string gets new number :
- assert_eq!(i.gensym("zebra"), Symbol(4294967294));
+ assert_eq!(i.intern("dog"), Symbol::new(0));
+ assert_eq!(i.gensym("zebra"), Symbol::new(SymbolIndex::MAX_AS_U32));
+ // gensym of same string gets new number:
+ assert_eq!(i.gensym("zebra"), Symbol::new(SymbolIndex::MAX_AS_U32 - 1));
// gensym of *existing* string gets new number:
- assert_eq!(i.gensym("dog"), Symbol(4294967293));
+ assert_eq!(i.gensym("dog"), Symbol::new(SymbolIndex::MAX_AS_U32 - 2));
}
#[test]
diff --git a/src/libunwind/Cargo.toml b/src/libunwind/Cargo.toml
index 4760461..2577d6d 100644
--- a/src/libunwind/Cargo.toml
+++ b/src/libunwind/Cargo.toml
@@ -13,5 +13,5 @@
[dependencies]
core = { path = "../libcore" }
-libc = { path = "../rustc/libc_shim" }
-compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
+libc = { version = "0.2.43", features = ['rustc-dep-of-std'], default-features = false }
+compiler_builtins = "0.1.0"
diff --git a/src/rust-sgx b/src/rust-sgx
deleted file mode 160000
index 9656260..0000000
--- a/src/rust-sgx
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 9656260888095f44830641ca7bb3da609a793451
diff --git a/src/rustc/compiler_builtins_shim/Cargo.toml b/src/rustc/compiler_builtins_shim/Cargo.toml
deleted file mode 100644
index 9804177..0000000
--- a/src/rustc/compiler_builtins_shim/Cargo.toml
+++ /dev/null
@@ -1,40 +0,0 @@
-[package]
-name = "compiler_builtins"
-authors = ["The Rust Project Developers"]
-version = "0.0.0"
-build = "../../libcompiler_builtins/build.rs"
-
-[lib]
-path = "../../libcompiler_builtins/src/lib.rs"
-test = false
-doctest = false
-
-[dependencies]
-# Specify the path to libcore; at the time of writing, removing this shim in
-# favor of using compiler-builtins from git results in a compilation failure:
-#
-# Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
-# Compiling compiler_builtins v0.1.0 (https://github.com/rust-lang-nursery/compiler-builtins.git#23f14d3f)
-# error[E0463]: can't find crate for `core`
-#
-# error: aborting due to previous error
-#
-# error: Could not compile `compiler_builtins`.
-#
-# Caused by:
-# process didn't exit successfully: `/Users/tamird/src/rust/build/bootstrap/debug/rustc --crate-name compiler_builtins /Users/tamird/.cargo/git/checkouts/compiler-builtins-ec094dc45a0179c8/23f14d3/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 --cfg feature="c" --cfg feature="compiler-builtins" --cfg feature="default" --cfg feature="gcc" -C metadata=876d429e8d7eae1f -C extra-filename=-876d429e8d7eae1f --out-dir /Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/release/deps --cap-lints allow -L native=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/build/compiler_builtins-f18fab55928102ad/out -l static=compiler-rt` (exit code: 101)
-# thread 'main' panicked at 'command did not execute successfully: "/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-apple-darwin" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/Users/tamird/src/rust/src/libstd/Cargo.toml" "--message-format" "json"
-# expected success, got: exit code: 101', src/bootstrap/compile.rs:883:8
-#
-# See https://github.com/rust-lang/rfcs/pull/1133.
-core = { path = "../../libcore" }
-
-[build-dependencies]
-cc = "1.0.1"
-
-[features]
-c = []
-default = ["rustbuild", "compiler-builtins"]
-mem = []
-rustbuild = []
-compiler-builtins = []
diff --git a/src/rustc/compiler_builtins_shim/build.rs b/src/rustc/compiler_builtins_shim/build.rs
deleted file mode 100644
index b37543e..0000000
--- a/src/rustc/compiler_builtins_shim/build.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This file is left intentionally empty (and not removed) to avoid an issue
-// where this crate is always considered dirty due to compiler-builtins'
-// `cargo:rerun-if-changed=build.rs` directive; since the path is relative, it
-// refers to this file when this shim crate is being built, and the absence of
-// this file is considered by cargo to be equivalent to it having changed.
diff --git a/src/rustc/dlmalloc_shim/Cargo.toml b/src/rustc/dlmalloc_shim/Cargo.toml
deleted file mode 100644
index b6f8550..0000000
--- a/src/rustc/dlmalloc_shim/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "dlmalloc"
-version = "0.0.0"
-authors = ["The Rust Project Developers"]
-
-[lib]
-path = "../../dlmalloc/src/lib.rs"
-test = false
-bench = false
-doc = false
-
-[dependencies]
-core = { path = "../../libcore" }
-compiler_builtins = { path = "../../rustc/compiler_builtins_shim" }
diff --git a/src/rustc/fortanix-sgx-abi_shim/Cargo.toml b/src/rustc/fortanix-sgx-abi_shim/Cargo.toml
deleted file mode 100644
index fd81d3d..0000000
--- a/src/rustc/fortanix-sgx-abi_shim/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "fortanix-sgx-abi"
-version = "0.0.0"
-authors = ["The Rust Project Developers"]
-
-[lib]
-path = "../../rust-sgx/fortanix-sgx-abi/src/lib.rs"
-test = false
-bench = false
-doc = false
-
-[dependencies]
-core = { path = "../../libcore" }
-compiler_builtins = { path = "../../rustc/compiler_builtins_shim" }
diff --git a/src/rustc/libc_shim/Cargo.toml b/src/rustc/libc_shim/Cargo.toml
deleted file mode 100644
index ee037ac..0000000
--- a/src/rustc/libc_shim/Cargo.toml
+++ /dev/null
@@ -1,40 +0,0 @@
-[package]
-name = "libc"
-version = "0.0.0"
-authors = ["The Rust Project Developers"]
-
-[lib]
-name = "libc"
-path = "../../liblibc/src/lib.rs"
-test = false
-bench = false
-doc = false
-
-[dependencies]
-# Specify the path to libcore; at the time of writing, removing this shim in
-# favor of using libc from git results in a compilation failure:
-#
-# Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
-# Compiling libc v0.0.0 (file:///Users/tamird/src/rust/src/rustc/libc_shim)
-# error[E0463]: can't find crate for `core`
-#
-# error: aborting due to previous error
-#
-# error: Could not compile `libc`.
-#
-# Caused by:
-# process didn't exit successfully: `/Users/tamird/src/rust/build/bootstrap/debug/rustc --crate-name libc src/rustc/libc_shim/../../liblibc/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 --cfg feature="default" --cfg feature="no_std" --cfg feature="stdbuild" -C metadata=d758f87058112d7d -C extra-filename=-d758f87058112d7d --out-dir /Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/release/deps` (exit code: 101)
-# thread 'main' panicked at 'command did not execute successfully: "/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-apple-darwin" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/Users/tamird/src/rust/src/libstd/Cargo.toml" "--message-format" "json"
-# expected success, got: exit code: 101', src/bootstrap/compile.rs:883:8
-#
-# See https://github.com/rust-lang/rfcs/pull/1133.
-core = { path = "../../libcore" }
-compiler_builtins = { path = "../compiler_builtins_shim" }
-
-
-[features]
-# Certain parts of libc are conditionally compiled differently than when used
-# outside rustc. See https://github.com/rust-lang/libc/search?l=Rust&q=stdbuild&type=&utf8=%E2%9C%93.
-stdbuild = []
-default = ["stdbuild", "align"]
-align = []
diff --git a/src/stage0.txt b/src/stage0.txt
index 9326e22..843ecae 100644
--- a/src/stage0.txt
+++ b/src/stage0.txt
@@ -12,7 +12,7 @@
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
# `0.x.0` for Cargo where they were released on `date`.
-date: 2018-10-30
+date: 2018-12-09
rustc: beta
cargo: beta
diff --git a/src/test/codegen/nounwind-extern.rs b/src/test/codegen/nounwind-extern.rs
new file mode 100644
index 0000000..ed07cf1
--- /dev/null
+++ b/src/test/codegen/nounwind-extern.rs
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// CHECK: Function Attrs: norecurse nounwind
+pub extern fn foo() {}
diff --git a/src/test/codegen/simd-intrinsic-generic-select.rs b/src/test/codegen/simd-intrinsic-generic-select.rs
index 8a64d74..24a4b2b 100644
--- a/src/test/codegen/simd-intrinsic-generic-select.rs
+++ b/src/test/codegen/simd-intrinsic-generic-select.rs
@@ -21,10 +21,15 @@
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
+pub struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);
+
+#[repr(simd)]
+#[derive(Copy, Clone, PartialEq, Debug)]
pub struct b8x4(pub i8, pub i8, pub i8, pub i8);
extern "platform-intrinsic" {
fn simd_select<T, U>(x: T, a: U, b: U) -> U;
+ fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
}
// CHECK-LABEL: @select
@@ -33,3 +38,10 @@
// CHECK: select <4 x i1>
simd_select(m, a, b)
}
+
+// CHECK-LABEL: @select_bitmask
+#[no_mangle]
+pub unsafe fn select_bitmask(m: i8, a: f32x8, b: f32x8) -> f32x8 {
+ // CHECK: select <8 x i1>
+ simd_select_bitmask(m, a, b)
+}
diff --git a/src/test/compile-fail/issue-10755.rs b/src/test/compile-fail/issue-10755.rs
index 57915bc..bb77748 100644
--- a/src/test/compile-fail/issue-10755.rs
+++ b/src/test/compile-fail/issue-10755.rs
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// compile-flags: -C linker=llllll -Z linker-flavor=ld
+// compile-flags: -C linker=llllll -C linker-flavor=ld
// error-pattern: linker `llllll` not found
fn main() {
diff --git a/src/test/compile-fail/nolink-with-link-args.rs b/src/test/compile-fail/nolink-with-link-args.rs
index 6dfd74f..95f827e 100644
--- a/src/test/compile-fail/nolink-with-link-args.rs
+++ b/src/test/compile-fail/nolink-with-link-args.rs
@@ -9,7 +9,7 @@
// except according to those terms.
// error-pattern:aFdEfSeVEE
-// compile-flags: -Z linker-flavor=ld
+// compile-flags: -C linker-flavor=ld
/* We're testing that link_args are indeed passed when nolink is specified.
So we try to compile with junk link_args and make sure they are visible in
diff --git a/src/test/debuginfo/pretty-std-collections.rs b/src/test/debuginfo/pretty-std-collections.rs
index a51be37..350b30d 100644
--- a/src/test/debuginfo/pretty-std-collections.rs
+++ b/src/test/debuginfo/pretty-std-collections.rs
@@ -13,7 +13,11 @@
// ignore-freebsd: gdb package too new
// ignore-android: FIXME(#10381)
// compile-flags:-g
-// min-gdb-version 7.7
+
+// The pretty printers being tested here require the patch from
+// https://sourceware.org/bugzilla/show_bug.cgi?id=21763
+// min-gdb-version 8.1
+
// min-lldb-version: 310
// === GDB TESTS ===================================================================================
diff --git a/src/test/incremental/foreign.rs b/src/test/incremental/foreign.rs
index dbdebef..648e89b 100644
--- a/src/test/incremental/foreign.rs
+++ b/src/test/incremental/foreign.rs
@@ -13,7 +13,7 @@
// revisions: rpass1
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs
index 90ad601..0254c7c 100644
--- a/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs
+++ b/src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs
@@ -10,7 +10,7 @@
#![crate_type = "staticlib"]
#![feature(c_variadic)]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-make-fulldeps/issue-25581/test.rs b/src/test/run-make-fulldeps/issue-25581/test.rs
index 6717d16..b084092 100644
--- a/src/test/run-make-fulldeps/issue-25581/test.rs
+++ b/src/test/run-make-fulldeps/issue-25581/test.rs
@@ -8,14 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(libc)]
-
-extern crate libc;
-
#[link(name = "test", kind = "static")]
extern {
- fn slice_len(s: &[u8]) -> libc::size_t;
- fn slice_elem(s: &[u8], idx: libc::size_t) -> u8;
+ fn slice_len(s: &[u8]) -> usize;
+ fn slice_elem(s: &[u8], idx: usize) -> u8;
}
fn main() {
diff --git a/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs
index b1d07d5..1427250 100644
--- a/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs
+++ b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs
@@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
fn main(){}
diff --git a/src/test/run-make-fulldeps/libtest-json/output.json b/src/test/run-make-fulldeps/libtest-json/output.json
index 80e75c8..2b831ea 100644
--- a/src/test/run-make-fulldeps/libtest-json/output.json
+++ b/src/test/run-make-fulldeps/libtest-json/output.json
@@ -2,7 +2,7 @@
{ "type": "test", "event": "started", "name": "a" }
{ "type": "test", "name": "a", "event": "ok" }
{ "type": "test", "event": "started", "name": "b" }
-{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n" }
+{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" }
{ "type": "test", "event": "started", "name": "c" }
{ "type": "test", "name": "c", "event": "ok" }
{ "type": "test", "event": "started", "name": "d" }
diff --git a/src/test/run-make-fulldeps/link-path-order/main.rs b/src/test/run-make-fulldeps/link-path-order/main.rs
index f3502e8..4d38dc8 100644
--- a/src/test/run-make-fulldeps/link-path-order/main.rs
+++ b/src/test/run-make-fulldeps/link-path-order/main.rs
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk
index 3de358f..7939928 100644
--- a/src/test/run-make-fulldeps/tools.mk
+++ b/src/test/run-make-fulldeps/tools.mk
@@ -76,7 +76,7 @@
# Extra flags needed to compile a working executable with the standard library
ifdef IS_WINDOWS
ifdef IS_MSVC
- EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib
+ EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib
else
EXTRACFLAGS := -lws2_32 -luserenv
endif
diff --git a/src/test/run-pass-valgrind/osx-frameworks.rs b/src/test/run-pass-valgrind/osx-frameworks.rs
index 468a20d..afa9374 100644
--- a/src/test/run-pass-valgrind/osx-frameworks.rs
+++ b/src/test/run-pass-valgrind/osx-frameworks.rs
@@ -11,7 +11,7 @@
// no-prefer-dynamic
// pretty-expanded FIXME #23616
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/abort-on-c-abi.rs b/src/test/run-pass/abort-on-c-abi.rs
index 17b2ee3..12b5b78 100644
--- a/src/test/run-pass/abort-on-c-abi.rs
+++ b/src/test/run-pass/abort-on-c-abi.rs
@@ -15,14 +15,11 @@
// ignore-cloudabi no env and process
// ignore-emscripten no processes
-#![feature(unwind_attributes)]
-
use std::{env, panic};
use std::io::prelude::*;
use std::io;
use std::process::{Command, Stdio};
-#[unwind(aborts)]
extern "C" fn panic_in_ffi() {
panic!("Test");
}
diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs
index 16ca7bc..daa2bd6 100644
--- a/src/test/run-pass/anon-extern-mod.rs
+++ b/src/test/run-pass/anon-extern-mod.rs
@@ -11,7 +11,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs b/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs
index 5091674..7a90a02 100644
--- a/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs
+++ b/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs
@@ -12,7 +12,7 @@
// ignore-emscripten no no_std executables
-#![feature(lang_items, start, libc, alloc)]
+#![feature(lang_items, start, rustc_private, alloc)]
#![no_std]
extern crate std as other;
diff --git a/src/test/run-pass/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/run-pass/auxiliary/anon-extern-mod-cross-crate-1.rs
index 741ce35..6b464c5 100644
--- a/src/test/run-pass/auxiliary/anon-extern-mod-cross-crate-1.rs
+++ b/src/test/run-pass/auxiliary/anon-extern-mod-cross-crate-1.rs
@@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/auxiliary/check_static_recursion_foreign_helper.rs b/src/test/run-pass/auxiliary/check_static_recursion_foreign_helper.rs
index cd36a8e..4d1acf3 100644
--- a/src/test/run-pass/auxiliary/check_static_recursion_foreign_helper.rs
+++ b/src/test/run-pass/auxiliary/check_static_recursion_foreign_helper.rs
@@ -10,7 +10,7 @@
// Helper definition for test/run-pass/check-static-recursion-foreign.rs.
-#![feature(libc)]
+#![feature(rustc_private)]
#![crate_name = "check_static_recursion_foreign_helper"]
#![crate_type = "lib"]
diff --git a/src/test/run-pass/auxiliary/foreign_lib.rs b/src/test/run-pass/auxiliary/foreign_lib.rs
index cef3627..465feb8 100644
--- a/src/test/run-pass/auxiliary/foreign_lib.rs
+++ b/src/test/run-pass/auxiliary/foreign_lib.rs
@@ -10,7 +10,7 @@
#![crate_name="foreign_lib"]
-#![feature(libc)]
+#![feature(rustc_private)]
pub mod rustrt {
extern crate libc;
diff --git a/src/test/run-pass/c-stack-as-value.rs b/src/test/run-pass/c-stack-as-value.rs
index df4989d..1f29a52 100644
--- a/src/test/run-pass/c-stack-as-value.rs
+++ b/src/test/run-pass/c-stack-as-value.rs
@@ -11,7 +11,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
mod rustrt {
extern crate libc;
diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs
index 56a0437..7dd3b9a 100644
--- a/src/test/run-pass/c-stack-returning-int64.rs
+++ b/src/test/run-pass/c-stack-returning-int64.rs
@@ -10,7 +10,7 @@
// ignore-wasm32-bare no libc to test with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/check-static-recursion-foreign.rs b/src/test/run-pass/check-static-recursion-foreign.rs
index a95870c..15f509a 100644
--- a/src/test/run-pass/check-static-recursion-foreign.rs
+++ b/src/test/run-pass/check-static-recursion-foreign.rs
@@ -16,7 +16,7 @@
// pretty-expanded FIXME #23616
-#![feature(custom_attribute, libc)]
+#![feature(custom_attribute, rustc_private)]
extern crate check_static_recursion_foreign_helper;
extern crate libc;
diff --git a/src/test/run-pass/command-before-exec.rs b/src/test/run-pass/command-before-exec.rs
index 5d8bc31..b78fa84 100644
--- a/src/test/run-pass/command-before-exec.rs
+++ b/src/test/run-pass/command-before-exec.rs
@@ -13,7 +13,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
-#![feature(process_exec, libc)]
+#![feature(process_exec, rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs
index 741ce35..6b464c5 100644
--- a/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs
+++ b/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs
@@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs
index 51e26ff..9023326 100644
--- a/src/test/run-pass/core-run-destroy.rs
+++ b/src/test/run-pass/core-run-destroy.rs
@@ -20,7 +20,7 @@
// memory, which makes for some *confusing* logs. That's why these are here
// instead of in std.
-#![feature(libc, duration)]
+#![feature(rustc_private, duration)]
extern crate libc;
diff --git a/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
index 741ce35..6b464c5 100644
--- a/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
+++ b/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
@@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/ctfe/references.rs b/src/test/run-pass/ctfe/references.rs
index 946ed24..421f354 100644
--- a/src/test/run-pass/ctfe/references.rs
+++ b/src/test/run-pass/ctfe/references.rs
@@ -28,6 +28,7 @@
_ => panic!("c"),
}
+ #[allow(unreachable_patterns)]
match &43 {
&42 => panic!(),
BOO => panic!(),
diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs
index 12e1cbe..7e7899c 100644
--- a/src/test/run-pass/env-funky-keys.rs
+++ b/src/test/run-pass/env-funky-keys.rs
@@ -16,7 +16,7 @@
// ignore-emscripten no execve
// no-prefer-dynamic
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/env-null-vars.rs b/src/test/run-pass/env-null-vars.rs
index 9a46199..cdbecf1 100644
--- a/src/test/run-pass/env-null-vars.rs
+++ b/src/test/run-pass/env-null-vars.rs
@@ -15,7 +15,7 @@
// issue-53200
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use std::env;
diff --git a/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs b/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs
index 150dffe..d20d9db 100644
--- a/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs
+++ b/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs
@@ -10,7 +10,7 @@
#![crate_name="externcallback"]
#![crate_type = "lib"]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/extern/extern-call-deep.rs b/src/test/run-pass/extern/extern-call-deep.rs
index 6e8d94b..12df0f3 100644
--- a/src/test/run-pass/extern/extern-call-deep.rs
+++ b/src/test/run-pass/extern/extern-call-deep.rs
@@ -10,8 +10,9 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
+// ignore-emscripten blows the JS stack
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/extern/extern-call-deep2.rs b/src/test/run-pass/extern/extern-call-deep2.rs
index 28157c5..8cb0477 100644
--- a/src/test/run-pass/extern/extern-call-deep2.rs
+++ b/src/test/run-pass/extern/extern-call-deep2.rs
@@ -12,7 +12,7 @@
#![allow(unused_must_use)]
// ignore-emscripten no threads support
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use std::thread;
diff --git a/src/test/run-pass/extern/extern-call-indirect.rs b/src/test/run-pass/extern/extern-call-indirect.rs
index 1badb10..d20721f 100644
--- a/src/test/run-pass/extern/extern-call-indirect.rs
+++ b/src/test/run-pass/extern/extern-call-indirect.rs
@@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/extern/extern-call-scrub.rs b/src/test/run-pass/extern/extern-call-scrub.rs
index ea18069..5e158c2 100644
--- a/src/test/run-pass/extern/extern-call-scrub.rs
+++ b/src/test/run-pass/extern/extern-call-scrub.rs
@@ -16,7 +16,7 @@
// ignore-emscripten no threads support
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use std::thread;
diff --git a/src/test/run-pass/extern/extern-crosscrate.rs b/src/test/run-pass/extern/extern-crosscrate.rs
index c6fccbe..b99e27a 100644
--- a/src/test/run-pass/extern/extern-crosscrate.rs
+++ b/src/test/run-pass/extern/extern-crosscrate.rs
@@ -12,7 +12,7 @@
// aux-build:extern-crosscrate-source.rs
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate externcallback;
extern crate libc;
diff --git a/src/test/run-pass/fds-are-cloexec.rs b/src/test/run-pass/fds-are-cloexec.rs
index a5ae0ae..33e64d8 100644
--- a/src/test/run-pass/fds-are-cloexec.rs
+++ b/src/test/run-pass/fds-are-cloexec.rs
@@ -14,7 +14,7 @@
// ignore-emscripten no processes
// ignore-haiku
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/foreign/auxiliary/foreign_lib.rs b/src/test/run-pass/foreign/auxiliary/foreign_lib.rs
index cef3627..465feb8 100644
--- a/src/test/run-pass/foreign/auxiliary/foreign_lib.rs
+++ b/src/test/run-pass/foreign/auxiliary/foreign_lib.rs
@@ -10,7 +10,7 @@
#![crate_name="foreign_lib"]
-#![feature(libc)]
+#![feature(rustc_private)]
pub mod rustrt {
extern crate libc;
diff --git a/src/test/run-pass/foreign/foreign-call-no-runtime.rs b/src/test/run-pass/foreign/foreign-call-no-runtime.rs
index 4837f78..e35ec88 100644
--- a/src/test/run-pass/foreign/foreign-call-no-runtime.rs
+++ b/src/test/run-pass/foreign/foreign-call-no-runtime.rs
@@ -11,7 +11,7 @@
// run-pass
// ignore-emscripten no threads support
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/foreign/foreign-fn-linkname.rs b/src/test/run-pass/foreign/foreign-fn-linkname.rs
index 7587660..8fe90b7 100644
--- a/src/test/run-pass/foreign/foreign-fn-linkname.rs
+++ b/src/test/run-pass/foreign/foreign-fn-linkname.rs
@@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use std::ffi::CString;
diff --git a/src/test/run-pass/foreign/foreign-no-abi.rs b/src/test/run-pass/foreign/foreign-no-abi.rs
index 1d35f08..49ddd09 100644
--- a/src/test/run-pass/foreign/foreign-no-abi.rs
+++ b/src/test/run-pass/foreign/foreign-no-abi.rs
@@ -14,7 +14,7 @@
// ignore-wasm32-bare no libc to test ffi with
// pretty-expanded FIXME #23616
-#![feature(libc)]
+#![feature(rustc_private)]
mod rustrt {
extern crate libc;
diff --git a/src/test/run-pass/foreign/foreign2.rs b/src/test/run-pass/foreign/foreign2.rs
index bd6c8e6..f8942bc 100644
--- a/src/test/run-pass/foreign/foreign2.rs
+++ b/src/test/run-pass/foreign/foreign2.rs
@@ -13,7 +13,7 @@
// ignore-wasm32-bare no libc to test ffi with
// pretty-expanded FIXME #23616
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/invalid_const_promotion.rs b/src/test/run-pass/invalid_const_promotion.rs
index 0f354e1..3b8a265 100644
--- a/src/test/run-pass/invalid_const_promotion.rs
+++ b/src/test/run-pass/invalid_const_promotion.rs
@@ -15,7 +15,7 @@
// compile-flags: -C debug_assertions=yes
#![stable(feature = "rustc", since = "1.0.0")]
-#![feature(const_fn, libc, staged_api, rustc_attrs)]
+#![feature(const_fn, rustc_private, staged_api, rustc_attrs)]
#![allow(const_err)]
extern crate libc;
diff --git a/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs b/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs
index de18e09..9c983ea 100644
--- a/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs
+++ b/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs
@@ -9,7 +9,7 @@
// except according to those terms.
// run-pass
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/issues/issue-2214.rs b/src/test/run-pass/issues/issue-2214.rs
index 8329847..f3795c2 100644
--- a/src/test/run-pass/issues/issue-2214.rs
+++ b/src/test/run-pass/issues/issue-2214.rs
@@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/issues/issue-30490.rs b/src/test/run-pass/issues/issue-30490.rs
index 500999c..47f60fb 100644
--- a/src/test/run-pass/issues/issue-30490.rs
+++ b/src/test/run-pass/issues/issue-30490.rs
@@ -18,7 +18,7 @@
// where the descriptors to inherit were already stdio descriptors.
// This test checks to avoid that regression.
-#![cfg_attr(unix, feature(libc))]
+#![cfg_attr(unix, feature(rustc_private))]
#![cfg_attr(windows, allow(unused_imports))]
#[cfg(unix)]
diff --git a/src/test/run-pass/issues/issue-3656.rs b/src/test/run-pass/issues/issue-3656.rs
index 63b2740..99a7244 100644
--- a/src/test/run-pass/issues/issue-3656.rs
+++ b/src/test/run-pass/issues/issue-3656.rs
@@ -19,7 +19,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use libc::{c_uint, uint32_t, c_void};
diff --git a/src/test/run-pass/multi-panic.rs b/src/test/run-pass/multi-panic.rs
index 2e6e109..03e58fc 100644
--- a/src/test/run-pass/multi-panic.rs
+++ b/src/test/run-pass/multi-panic.rs
@@ -17,7 +17,8 @@
let mut it = err.lines();
assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
- assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace."));
+ assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` \
+ environment variable to display a backtrace."));
assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
assert_eq!(it.next(), None);
}
diff --git a/src/test/run-pass/no-stdio.rs b/src/test/run-pass/no-stdio.rs
index d342417..2f5bfbb 100644
--- a/src/test/run-pass/no-stdio.rs
+++ b/src/test/run-pass/no-stdio.rs
@@ -12,7 +12,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs
index cd0f7cd..1c714e7 100644
--- a/src/test/run-pass/out-of-stack.rs
+++ b/src/test/run-pass/out-of-stack.rs
@@ -16,7 +16,7 @@
// ignore-emscripten no processes
#![feature(asm)]
-#![feature(libc)]
+#![feature(rustc_private)]
#[cfg(unix)]
extern crate libc;
diff --git a/src/test/run-pass/rfcs/rfc-1014-2.rs b/src/test/run-pass/rfcs/rfc-1014-2.rs
index 7fbc0d1..257c7f5 100644
--- a/src/test/run-pass/rfcs/rfc-1014-2.rs
+++ b/src/test/run-pass/rfcs/rfc-1014-2.rs
@@ -11,7 +11,7 @@
// run-pass
#![allow(dead_code)]
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/rfcs/rfc-1014.rs b/src/test/run-pass/rfcs/rfc-1014.rs
index d101c3c..578a7f4 100644
--- a/src/test/run-pass/rfcs/rfc-1014.rs
+++ b/src/test/run-pass/rfcs/rfc-1014.rs
@@ -13,7 +13,7 @@
// ignore-cloudabi stdout does not map to file descriptor 1 by default
// ignore-wasm32-bare no libc
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs
index a85fe67..961b802 100644
--- a/src/test/run-pass/segfault-no-out-of-stack.rs
+++ b/src/test/run-pass/segfault-no-out-of-stack.rs
@@ -12,7 +12,7 @@
// ignore-cloudabi can't run commands
// ignore-emscripten can't run commands
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/signal-alternate-stack-cleanup.rs b/src/test/run-pass/signal-alternate-stack-cleanup.rs
index ad099f8..a79ab20 100644
--- a/src/test/run-pass/signal-alternate-stack-cleanup.rs
+++ b/src/test/run-pass/signal-alternate-stack-cleanup.rs
@@ -16,7 +16,7 @@
// ignore-wasm32-bare no libc
// ignore-windows
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
use libc::*;
diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
index 590a299..74b99ca 100644
--- a/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
+++ b/src/test/run-pass/simd/simd-intrinsic-generic-select.rs
@@ -28,6 +28,10 @@
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
+struct u32x8(u32, u32, u32, u32, u32, u32, u32, u32);
+
+#[repr(simd)]
+#[derive(Copy, Clone, PartialEq, Debug)]
struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[repr(simd)]
@@ -36,6 +40,7 @@
extern "platform-intrinsic" {
fn simd_select<T, U>(x: T, a: U, b: U) -> U;
+ fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
}
fn main() {
@@ -146,4 +151,29 @@
let e = b8x4(t, f, t, t);
assert_eq!(r, e);
}
+
+ unsafe {
+ let a = u32x8(0, 1, 2, 3, 4, 5, 6, 7);
+ let b = u32x8(8, 9, 10, 11, 12, 13, 14, 15);
+
+ let r: u32x8 = simd_select_bitmask(0u8, a, b);
+ let e = b;
+ assert_eq!(r, e);
+
+ let r: u32x8 = simd_select_bitmask(0xffu8, a, b);
+ let e = a;
+ assert_eq!(r, e);
+
+ let r: u32x8 = simd_select_bitmask(0b01010101u8, a, b);
+ let e = u32x8(0, 9, 2, 11, 4, 13, 6, 15);
+ assert_eq!(r, e);
+
+ let r: u32x8 = simd_select_bitmask(0b10101010u8, a, b);
+ let e = u32x8(8, 1, 10, 3, 12, 5, 14, 7);
+ assert_eq!(r, e);
+
+ let r: u32x8 = simd_select_bitmask(0b11110000u8, a, b);
+ let e = u32x8(8, 9, 10, 11, 4, 5, 6, 7);
+ assert_eq!(r, e);
+ }
}
diff --git a/src/test/run-pass/statics/static-mut-foreign.rs b/src/test/run-pass/statics/static-mut-foreign.rs
index d9e43dd..460d66a 100644
--- a/src/test/run-pass/statics/static-mut-foreign.rs
+++ b/src/test/run-pass/statics/static-mut-foreign.rs
@@ -15,7 +15,7 @@
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/run-pass/wait-forked-but-failed-child.rs b/src/test/run-pass/wait-forked-but-failed-child.rs
index dc47108..d822b67 100644
--- a/src/test/run-pass/wait-forked-but-failed-child.rs
+++ b/src/test/run-pass/wait-forked-but-failed-child.rs
@@ -11,7 +11,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout
index cd19099..bd6fa1f 100644
--- a/src/test/rustdoc-ui/failed-doctest-output.stdout
+++ b/src/test/rustdoc-ui/failed-doctest-output.stdout
@@ -13,13 +13,13 @@
| ^^ not found in this scope
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 27)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:326:13
-note: Run with `RUST_BACKTRACE=1` for a backtrace.
+note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
---- $DIR/failed-doctest-output.rs - SomeStruct (line 21) stdout ----
thread '$DIR/failed-doctest-output.rs - SomeStruct (line 21)' panicked at 'test executable failed:
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
-note: Run with `RUST_BACKTRACE=1` for a backtrace.
+note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
', src/librustdoc/test.rs:361:17
diff --git a/src/test/rustdoc/proc-macro.rs b/src/test/rustdoc/proc-macro.rs
index 23d0d00..05d64f8 100644
--- a/src/test/rustdoc/proc-macro.rs
+++ b/src/test/rustdoc/proc-macro.rs
@@ -61,3 +61,16 @@
pub fn some_derive(_item: TokenStream) -> TokenStream {
TokenStream::new()
}
+
+// @has some_macros/foo/index.html
+pub mod foo {
+ // @has - '//code' 'pub use some_proc_macro;'
+ // @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
+ pub use some_proc_macro;
+ // @has - '//code' 'pub use some_proc_attr;'
+ // @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
+ pub use some_proc_attr;
+ // @has - '//code' 'pub use some_derive;'
+ // @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'
+ pub use some_derive;
+}
diff --git a/src/test/ui/error-codes/E0259.rs b/src/test/ui/error-codes/E0259.rs
index 5a47541..b3e633a 100644
--- a/src/test/ui/error-codes/E0259.rs
+++ b/src/test/ui/error-codes/E0259.rs
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(alloc, libc)]
+#![feature(alloc, rustc_private)]
#![allow(unused_extern_crates)]
extern crate alloc;
diff --git a/src/test/ui/error-codes/E0424.rs b/src/test/ui/error-codes/E0424.rs
index 445d0c5..20d42da 100644
--- a/src/test/ui/error-codes/E0424.rs
+++ b/src/test/ui/error-codes/E0424.rs
@@ -19,4 +19,5 @@
}
fn main () {
+ let self = "self"; //~ ERROR E0424
}
diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr
index a1b7a5f..5eccd7d 100644
--- a/src/test/ui/error-codes/E0424.stderr
+++ b/src/test/ui/error-codes/E0424.stderr
@@ -4,6 +4,12 @@
LL | self.bar(); //~ ERROR E0424
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
-error: aborting due to previous error
+error[E0424]: expected unit struct/variant or constant, found module `self`
+ --> $DIR/E0424.rs:22:9
+ |
+LL | let self = "self"; //~ ERROR E0424
+ | ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0424`.
diff --git a/src/test/ui/extern/extern-const.fixed b/src/test/ui/extern/extern-const.fixed
index dca5698..fb17934 100644
--- a/src/test/ui/extern/extern-const.fixed
+++ b/src/test/ui/extern/extern-const.fixed
@@ -7,7 +7,7 @@
// run-rustfix
// ignore-wasm32 no external library to link to.
// compile-flags: -g -Z continue-parse-after-error
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
diff --git a/src/test/ui/extern/extern-const.rs b/src/test/ui/extern/extern-const.rs
index 07dbe54..f2585f5 100644
--- a/src/test/ui/extern/extern-const.rs
+++ b/src/test/ui/extern/extern-const.rs
@@ -7,7 +7,7 @@
// run-rustfix
// ignore-wasm32 no external library to link to.
// compile-flags: -g -Z continue-parse-after-error
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
diff --git a/src/test/ui/feature-gates/feature-gate-linker-flavor.rs b/src/test/ui/feature-gates/feature-gate-linker-flavor.rs
deleted file mode 100644
index 56ede01..0000000
--- a/src/test/ui/feature-gates/feature-gate-linker-flavor.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This is a fake compile fail test as there's no way to generate a
-// `#![feature(linker_flavor)]` error. The only reason we have a `linker_flavor`
-// feature gate is to be able to document `-Z linker-flavor` in the unstable
-// book
-
-#[used]
-//~^ ERROR attribute must be applied to a `static` variable
-fn foo() {}
-
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-linker-flavor.stderr b/src/test/ui/feature-gates/feature-gate-linker-flavor.stderr
deleted file mode 100644
index 7019a66..0000000
--- a/src/test/ui/feature-gates/feature-gate-linker-flavor.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: attribute must be applied to a `static` variable
- --> $DIR/feature-gate-linker-flavor.rs:16:1
- |
-LL | #[used]
- | ^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/issues/issue-1251.rs b/src/test/ui/issues/issue-1251.rs
index b42404c..125f6e1 100644
--- a/src/test/ui/issues/issue-1251.rs
+++ b/src/test/ui/issues/issue-1251.rs
@@ -14,7 +14,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
#![crate_id="rust_get_test_int"]
diff --git a/src/test/ui/issues/issue-22034.rs b/src/test/ui/issues/issue-22034.rs
index 2708de2..bee324f 100644
--- a/src/test/ui/issues/issue-22034.rs
+++ b/src/test/ui/issues/issue-22034.rs
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/ui/issues/issue-37887.stderr b/src/test/ui/issues/issue-37887.stderr
index 48fb6c2..7a5a5cd 100644
--- a/src/test/ui/issues/issue-37887.stderr
+++ b/src/test/ui/issues/issue-37887.stderr
@@ -4,13 +4,13 @@
LL | use libc::*; //~ ERROR unresolved import
| ^^^^ maybe a missing `extern crate libc;`?
-error[E0658]: use of unstable library feature 'libc': use `libc` from crates.io (see issue #27783)
+error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? (see issue #27812)
--> $DIR/issue-37887.rs:12:5
|
LL | extern crate libc; //~ ERROR use of unstable
| ^^^^^^^^^^^^^^^^^^
|
- = help: add #![feature(libc)] to the crate attributes to enable
+ = help: add #![feature(rustc_private)] to the crate attributes to enable
error: aborting due to 2 previous errors
diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs
index e09aaba..4c9f1f9 100644
--- a/src/test/ui/lint/lint-ctypes.rs
+++ b/src/test/ui/lint/lint-ctypes.rs
@@ -9,7 +9,7 @@
// except according to those terms.
#![deny(improper_ctypes)]
-#![feature(libc)]
+#![feature(rustc_private)]
#![allow(private_in_public)]
diff --git a/src/test/ui/lint/lint-unexported-no-mangle.stderr b/src/test/ui/lint/lint-unexported-no-mangle.stderr
index 063915d..1df2d7b 100644
--- a/src/test/ui/lint/lint-unexported-no-mangle.stderr
+++ b/src/test/ui/lint/lint-unexported-no-mangle.stderr
@@ -1,8 +1,8 @@
-warning: lint `private_no_mangle_fns` has been removed: `no longer an warning, #[no_mangle] functions always exported`
+warning: lint `private_no_mangle_fns` has been removed: `no longer a warning, #[no_mangle] functions always exported`
|
= note: requested on the command line with `-F private_no_mangle_fns`
-warning: lint `private_no_mangle_statics` has been removed: `no longer an warning, #[no_mangle] statics always exported`
+warning: lint `private_no_mangle_statics` has been removed: `no longer a warning, #[no_mangle] statics always exported`
|
= note: requested on the command line with `-F private_no_mangle_statics`
diff --git a/src/test/ui/non-copyable-void.rs b/src/test/ui/non-copyable-void.rs
index 63e5f96..3599190 100644
--- a/src/test/ui/non-copyable-void.rs
+++ b/src/test/ui/non-copyable-void.rs
@@ -10,7 +10,7 @@
// ignore-wasm32-bare no libc to test ffi with
-#![feature(libc)]
+#![feature(rustc_private)]
extern crate libc;
diff --git a/src/test/ui/pattern/const-pat-ice.rs b/src/test/ui/pattern/const-pat-ice.rs
new file mode 100644
index 0000000..6496a2a
--- /dev/null
+++ b/src/test/ui/pattern/const-pat-ice.rs
@@ -0,0 +1,13 @@
+// failure-status: 101
+
+// This is a repro test for an ICE in our pattern handling of constants.
+
+const FOO: &&&u32 = &&&42;
+
+fn main() {
+ match unimplemented!() {
+ &&&42 => {},
+ FOO => {},
+ _ => {},
+ }
+}
diff --git a/src/test/ui/pattern/irrefutable-exhaustive-integer-binding.rs b/src/test/ui/pattern/irrefutable-exhaustive-integer-binding.rs
new file mode 100644
index 0000000..ff06588
--- /dev/null
+++ b/src/test/ui/pattern/irrefutable-exhaustive-integer-binding.rs
@@ -0,0 +1,8 @@
+// run-pass
+
+fn main() {
+ let -2147483648..=2147483647 = 1;
+ let 0..=255 = 0u8;
+ let -128..=127 = 0i8;
+ let '\u{0000}'..='\u{10FFFF}' = 'v';
+}
diff --git a/src/test/ui/pattern/slice-pattern-const-2.rs b/src/test/ui/pattern/slice-pattern-const-2.rs
index 6f9501d..6cfef11 100644
--- a/src/test/ui/pattern/slice-pattern-const-2.rs
+++ b/src/test/ui/pattern/slice-pattern-const-2.rs
@@ -1,4 +1,4 @@
-// compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
@@ -6,19 +6,26 @@
match s {
MAGIC_TEST => (),
[0x00, 0x00, 0x00, 0x00] => (),
- [4, 5, 6, 7] => (), // this should warn
+ [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
MAGIC_TEST => (),
- [4, 5, 6, 7] => (), // this should warn
+ [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
[4, 5, 6, 7] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
+ _ => (),
+ }
+ const FOO: [u32; 1] = [4];
+ match [99] {
+ [0x00] => (),
+ [4] => (),
+ FOO => (), //~ ERROR unreachable pattern
_ => (),
}
}
diff --git a/src/test/ui/pattern/slice-pattern-const-2.stderr b/src/test/ui/pattern/slice-pattern-const-2.stderr
new file mode 100644
index 0000000..95651cc
--- /dev/null
+++ b/src/test/ui/pattern/slice-pattern-const-2.stderr
@@ -0,0 +1,26 @@
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:9:9
+ |
+LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const-2.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:15:9
+ |
+LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/ui/pattern/slice-pattern-const-3.rs b/src/test/ui/pattern/slice-pattern-const-3.rs
index e7a30ce..8805c43 100644
--- a/src/test/ui/pattern/slice-pattern-const-3.rs
+++ b/src/test/ui/pattern/slice-pattern-const-3.rs
@@ -1,4 +1,4 @@
-// compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &["0x00"; 4][..]; //Slice of any value
@@ -6,19 +6,26 @@
match s {
MAGIC_TEST => (),
["0x00", "0x00", "0x00", "0x00"] => (),
- ["4", "5", "6", "7"] => (), // this should warn
+ ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
MAGIC_TEST => (),
- ["4", "5", "6", "7"] => (), // this should warn
+ ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
["4", "5", "6", "7"] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
+ _ => (),
+ }
+ const FOO: [&str; 1] = ["boo"];
+ match ["baa"] {
+ ["0x00"] => (),
+ ["boo"] => (),
+ FOO => (), //~ ERROR unreachable pattern
_ => (),
}
}
diff --git a/src/test/ui/pattern/slice-pattern-const-3.stderr b/src/test/ui/pattern/slice-pattern-const-3.stderr
new file mode 100644
index 0000000..531bbbc
--- /dev/null
+++ b/src/test/ui/pattern/slice-pattern-const-3.stderr
@@ -0,0 +1,14 @@
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-3.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const-3.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pattern/slice-pattern-const.rs b/src/test/ui/pattern/slice-pattern-const.rs
index d353f6c..f0a0451 100644
--- a/src/test/ui/pattern/slice-pattern-const.rs
+++ b/src/test/ui/pattern/slice-pattern-const.rs
@@ -1,4 +1,4 @@
-//compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
@@ -6,19 +6,42 @@
match s {
MAGIC_TEST => (),
[0x00, 0x00, 0x00, 0x00] => (),
- [84, 69, 83, 84] => (), // this should warn
+ [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
MAGIC_TEST => (),
- [84, 69, 83, 84] => (), // this should warn
+ [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
[84, 69, 83, 84] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), //~ ERROR unreachable pattern
_ => (),
}
+ const FOO: [u8; 1] = [4];
+ match [99] {
+ [0x00] => (),
+ [4] => (),
+ FOO => (), //~ ERROR unreachable pattern
+ _ => (),
+ }
+ const BAR: &[u8; 1] = &[4];
+ match &[99] {
+ [0x00] => (),
+ [4] => (),
+ BAR => (), //~ ERROR unreachable pattern
+ b"a" => (),
+ _ => (),
+ }
+
+ const BOO: &[u8; 0] = &[];
+ match &[] {
+ [] => (),
+ BOO => (), //~ ERROR unreachable pattern
+ b"" => (), //~ ERROR unreachable pattern
+ _ => (), //~ ERROR unreachable pattern
+ }
}
diff --git a/src/test/ui/pattern/slice-pattern-const.stderr b/src/test/ui/pattern/slice-pattern-const.stderr
new file mode 100644
index 0000000..412e015
--- /dev/null
+++ b/src/test/ui/pattern/slice-pattern-const.stderr
@@ -0,0 +1,56 @@
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:9:9
+ |
+LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:15:9
+ |
+LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:21:9
+ |
+LL | MAGIC_TEST => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:35:9
+ |
+LL | BAR => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:43:9
+ |
+LL | BOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:44:9
+ |
+LL | b"" => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:45:9
+ |
+LL | _ => (), //~ ERROR unreachable pattern
+ | ^
+
+error: aborting due to 8 previous errors
+
diff --git a/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs
new file mode 100644
index 0000000..24676fe
--- /dev/null
+++ b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs
@@ -0,0 +1,74 @@
+// This is a collection of examples where a function's formal
+// parameter has an explicit lifetime and a closure within that
+// function returns that formal parameter. The closure's return type,
+// to be correctly inferred, needs to include the lifetime introduced
+// by the function.
+//
+// This works today, which precludes changing things so that closures
+// follow the same lifetime-elision rules used elsehwere. See
+// rust-lang/rust#56537
+
+// compile-pass
+// We are already testing NLL explicitly via the revision system below.
+// ignore-compare-mode-nll
+
+// revisions: ll nll migrate
+//[ll] compile-flags:-Zborrowck=ast
+//[nll] compile-flags:-Zborrowck=mir -Z two-phase-borrows
+//[migrate] compile-flags:-Zborrowck=migrate -Z two-phase-borrows
+
+fn willy_no_annot<'w>(p: &'w str, q: &str) -> &'w str {
+ let free_dumb = |_x| { p }; // no type annotation at all
+ let hello = format!("Hello");
+ free_dumb(&hello)
+}
+
+fn willy_ret_type_annot<'w>(p: &'w str, q: &str) -> &'w str {
+ let free_dumb = |_x| -> &str { p }; // type annotation on the return type
+ let hello = format!("Hello");
+ free_dumb(&hello)
+}
+
+fn willy_ret_region_annot<'w>(p: &'w str, q: &str) -> &'w str {
+ let free_dumb = |_x| -> &'w str { p }; // type+region annotation on return type
+ let hello = format!("Hello");
+ free_dumb(&hello)
+}
+
+fn willy_arg_type_ret_type_annot<'w>(p: &'w str, q: &str) -> &'w str {
+ let free_dumb = |_x: &str| -> &str { p }; // type annotation on arg and return types
+ let hello = format!("Hello");
+ free_dumb(&hello)
+}
+
+fn willy_arg_type_ret_region_annot<'w>(p: &'w str, q: &str) -> &'w str {
+ let free_dumb = |_x: &str| -> &'w str { p }; // fully annotated
+ let hello = format!("Hello");
+ free_dumb(&hello)
+}
+
+fn main() {
+ let world = format!("World");
+ let w1: &str = {
+ let hello = format!("He11o");
+ willy_no_annot(&world, &hello)
+ };
+ let w2: &str = {
+ let hello = format!("He22o");
+ willy_ret_type_annot(&world, &hello)
+ };
+ let w3: &str = {
+ let hello = format!("He33o");
+ willy_ret_region_annot(&world, &hello)
+ };
+ let w4: &str = {
+ let hello = format!("He44o");
+ willy_arg_type_ret_type_annot(&world, &hello)
+ };
+ let w5: &str = {
+ let hello = format!("He55o");
+ willy_arg_type_ret_region_annot(&world, &hello)
+ };
+ assert_eq!((w1, w2, w3, w4, w5),
+ ("World","World","World","World","World"));
+}
diff --git a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.rs b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.rs
index d74d681..2a2d35e 100644
--- a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.rs
+++ b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.rs
@@ -33,6 +33,7 @@
extern "platform-intrinsic" {
fn simd_select<T, U>(x: T, a: U, b: U) -> U;
+ fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
}
fn main() {
@@ -52,5 +53,14 @@
simd_select(z, z, z);
//~^ ERROR mask element type is `f32`, expected `i_`
+
+ simd_select_bitmask(0u8, x, x);
+ //~^ ERROR mask length `8` != other vector length `4`
+
+ simd_select_bitmask(0.0f32, x, x);
+ //~^ ERROR `f32` is not an integral type
+
+ simd_select_bitmask("x", x, x);
+ //~^ ERROR `&str` is not an integral type
}
}
diff --git a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.stderr b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.stderr
index 61e4202..584f3d5 100644
--- a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.stderr
+++ b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.stderr
@@ -1,21 +1,39 @@
error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4`
- --> $DIR/simd-intrinsic-generic-select.rs:47:9
+ --> $DIR/simd-intrinsic-generic-select.rs:48:9
|
LL | simd_select(m8, x, x);
| ^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_`
- --> $DIR/simd-intrinsic-generic-select.rs:50:9
+ --> $DIR/simd-intrinsic-generic-select.rs:51:9
|
LL | simd_select(x, x, x);
| ^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_`
- --> $DIR/simd-intrinsic-generic-select.rs:53:9
+ --> $DIR/simd-intrinsic-generic-select.rs:54:9
|
LL | simd_select(z, z, z);
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 3 previous errors
+error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `8` != other vector length `4`
+ --> $DIR/simd-intrinsic-generic-select.rs:57:9
+ |
+LL | simd_select_bitmask(0u8, x, x);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `f32` is not an integral type
+ --> $DIR/simd-intrinsic-generic-select.rs:60:9
+ |
+LL | simd_select_bitmask(0.0f32, x, x);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `&str` is not an integral type
+ --> $DIR/simd-intrinsic-generic-select.rs:63:9
+ |
+LL | simd_select_bitmask("x", x, x);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0511`.
diff --git a/src/test/ui/unnecessary-extern-crate.rs b/src/test/ui/unnecessary-extern-crate.rs
index 110cfef..4eb3c3d 100644
--- a/src/test/ui/unnecessary-extern-crate.rs
+++ b/src/test/ui/unnecessary-extern-crate.rs
@@ -11,7 +11,7 @@
// edition:2018
#![deny(unused_extern_crates)]
-#![feature(alloc, test, libc, crate_visibility_modifier)]
+#![feature(alloc, test, rustc_private, crate_visibility_modifier)]
extern crate libc;
//~^ ERROR unused extern crate
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
index 896b380..ea6c711 100644
--- a/src/tools/build-manifest/src/main.rs
+++ b/src/tools/build-manifest/src/main.rs
@@ -621,8 +621,10 @@
let asc = self.output.join(format!("{}.asc", filename));
println!("signing: {:?}", path);
let mut cmd = Command::new("gpg");
- cmd.arg("--no-tty")
+ cmd.arg("--pinentry-mode=loopback")
+ .arg("--no-tty")
.arg("--yes")
+ .arg("--batch")
.arg("--passphrase-fd").arg("0")
.arg("--personal-digest-preferences").arg("SHA512")
.arg("--armor")
diff --git a/src/tools/cargo b/src/tools/cargo
index 28fb200..2cf1f5d 160000
--- a/src/tools/cargo
+++ b/src/tools/cargo
@@ -1 +1 @@
-Subproject commit 28fb20034a5bb42ea589664de2617dd1840506d3
+Subproject commit 2cf1f5dda2f7ed84e94c4d32f643e0f1f15352f0
diff --git a/src/tools/clippy b/src/tools/clippy
index a3c77f6..b7a431e 160000
--- a/src/tools/clippy
+++ b/src/tools/clippy
@@ -1 +1 @@
-Subproject commit a3c77f6ad1c1c185e561e9cd7fdec7db569169d1
+Subproject commit b7a431ea1ddb96a396921bf9b5f2f6d8690cd474
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 65f6bff..9aefd15 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -511,7 +511,11 @@
test::TestOpts {
filter: config.filter.clone(),
filter_exact: config.filter_exact,
- run_ignored: config.run_ignored,
+ run_ignored: if config.run_ignored {
+ test::RunIgnored::Yes
+ } else {
+ test::RunIgnored::No
+ },
format: if config.quiet {
test::OutputFormat::Terse
} else {
diff --git a/src/tools/rustc-std-workspace-core/Cargo.toml b/src/tools/rustc-std-workspace-core/Cargo.toml
new file mode 100644
index 0000000..f000d63
--- /dev/null
+++ b/src/tools/rustc-std-workspace-core/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "rustc-std-workspace-core"
+version = "1.0.0"
+authors = ["Alex Crichton <alex@alexcrichton.com>"]
+license = 'MIT/Apache-2.0'
+description = """
+Hack for the compiler's own build system
+"""
+
+[lib]
+path = "lib.rs"
+
+[dependencies]
+core = { path = "../../libcore" }
diff --git a/src/tools/rustc-std-workspace-core/README.md b/src/tools/rustc-std-workspace-core/README.md
new file mode 100644
index 0000000..9c2b1fa
--- /dev/null
+++ b/src/tools/rustc-std-workspace-core/README.md
@@ -0,0 +1,29 @@
+# The `rustc-std-workspace-core` crate
+
+This crate is a shim and empty crate which simply depends on `libcore` and
+reexports all of its contents. The crate is the crux of empowering the standard
+library to depend on crates from crates.io
+
+Crates on crates.io that the standard library depend on the
+`rustc-std-workspace-core` crate from crates.io. On crates.io, however, this
+crate is empty. We use `[patch]` to override it to this crate in this
+repository. As a result, crates on crates.io will draw a dependency edge to
+`libcore`, the version defined in this repository. That should draw all the
+dependency edges to ensure Cargo builds crates successfully!
+
+Note that crates on crates.io need to depend on this crate with the name `core`
+for everything to work correctly. To do that they can use:
+
+```toml
+core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' }
+```
+
+Through the use of the `package` key the crate is renamed to `core`, meaning
+it'll look like
+
+```
+--extern core=.../librustc_std_workspace_core-XXXXXXX.rlib
+```
+
+when Cargo invokes the compiler, satisfying the implicit `extern crate core`
+directive injected by the compiler.
diff --git a/src/tools/rustc-std-workspace-core/lib.rs b/src/tools/rustc-std-workspace-core/lib.rs
new file mode 100644
index 0000000..e2946fe
--- /dev/null
+++ b/src/tools/rustc-std-workspace-core/lib.rs
@@ -0,0 +1,6 @@
+#![feature(no_core)]
+#![no_core]
+
+extern crate core;
+
+pub use core::*;
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index e275892..2b5cff6 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -53,6 +53,7 @@
"bytesize", // Apache-2.0, cargo
"im-rc", // MPL-2.0+, cargo
"adler32", // BSD-3-Clause AND Zlib, cargo dep that isn't used
+ "fortanix-sgx-abi", // MPL-2.0+, libstd but only for sgx target
];
/// Which crates to check against the whitelist?
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index 53db589..614d205 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -56,15 +56,11 @@
fn filter_dirs(path: &Path) -> bool {
let skip = [
- "src/dlmalloc",
"src/llvm",
"src/llvm-emscripten",
"src/libbacktrace",
- "src/libcompiler_builtins",
"src/librustc_data_structures/owning_ref",
- "src/compiler-rt",
- "src/liblibc",
- "src/rt/hoedown",
+ "src/vendor",
"src/tools/cargo",
"src/tools/clang",
"src/tools/rls",
diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs
index 822db25..acf7202 100644
--- a/src/tools/tidy/src/pal.rs
+++ b/src/tools/tidy/src/pal.rs
@@ -26,7 +26,6 @@
//! exceptions:
//!
//! - core may not have platform-specific code
-//! - libcompiler_builtins may have platform-specific code
//! - libpanic_abort may have platform-specific code
//! - libpanic_unwind may have platform-specific code
//! - libunwind may have platform-specific code
@@ -50,8 +49,6 @@
// Paths that may contain platform-specific code
const EXCEPTION_PATHS: &[&str] = &[
// std crates
- "src/libcompiler_builtins",
- "src/liblibc",
"src/libpanic_abort",
"src/libpanic_unwind",
"src/libunwind",