about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2024-06-18 05:04:11 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2024-06-18 05:04:11 +0000
commitca06b3b4f23b774a5b7aadecd1a8de7cd0a2e574 (patch)
tree4673baef0e276a4f05ccc935f60f8d3436ec77ff /src
parent028f437abffc4943d085bd2b7be5e7a4ea73aac8 (diff)
parentc2932aaf9d20acbc9259c762f1a06f8767c6f13f (diff)
downloadrust-ca06b3b4f23b774a5b7aadecd1a8de7cd0a2e574.tar.gz
rust-ca06b3b4f23b774a5b7aadecd1a8de7cd0a2e574.zip
Merge from rustc
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/lib.rs37
-rw-r--r--src/bootstrap/src/utils/helpers.rs10
m---------src/doc/book0
m---------src/doc/edition-guide0
m---------src/doc/reference0
m---------src/doc/rust-by-example0
m---------src/doc/rustc-dev-guide0
-rw-r--r--src/tools/miri/src/intrinsics/mod.rs2
-rw-r--r--src/tools/run-make-support/src/command.rs44
-rw-r--r--src/tools/run-make-support/src/lib.rs53
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt6
11 files changed, 110 insertions, 42 deletions
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index abf407ea91e..449d8c128ec 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -520,10 +520,12 @@ impl Build {
             return;
         }
 
-        // check_submodule
-        let checked_out_hash =
-            output(helpers::git(Some(&absolute_path)).args(["rev-parse", "HEAD"]));
-        // update_submodules
+        let submodule_git = || helpers::git(Some(&absolute_path));
+
+        // Determine commit checked out in submodule.
+        let checked_out_hash = output(submodule_git().args(["rev-parse", "HEAD"]));
+        let checked_out_hash = checked_out_hash.trim_end();
+        // Determine commit that the submodule *should* have.
         let recorded =
             output(helpers::git(Some(&self.src)).args(["ls-tree", "HEAD"]).arg(relative_path));
         let actual_hash = recorded
@@ -531,8 +533,7 @@ impl Build {
             .nth(2)
             .unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
 
-        // update_submodule
-        if actual_hash == checked_out_hash.trim_end() {
+        if actual_hash == checked_out_hash {
             // already checked out
             return;
         }
@@ -581,26 +582,22 @@ impl Build {
         // Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
         // diff-index reports the modifications through the exit status
         let has_local_modifications = !self.run_cmd(
-            BootstrapCommand::from(helpers::git(Some(&absolute_path)).args([
-                "diff-index",
-                "--quiet",
-                "HEAD",
-            ]))
-            .allow_failure()
-            .output_mode(match self.is_verbose() {
-                true => OutputMode::PrintAll,
-                false => OutputMode::PrintOutput,
-            }),
+            BootstrapCommand::from(submodule_git().args(["diff-index", "--quiet", "HEAD"]))
+                .allow_failure()
+                .output_mode(match self.is_verbose() {
+                    true => OutputMode::PrintAll,
+                    false => OutputMode::PrintOutput,
+                }),
         );
         if has_local_modifications {
-            self.run(helpers::git(Some(&absolute_path)).args(["stash", "push"]));
+            self.run(submodule_git().args(["stash", "push"]));
         }
 
-        self.run(helpers::git(Some(&absolute_path)).args(["reset", "-q", "--hard"]));
-        self.run(helpers::git(Some(&absolute_path)).args(["clean", "-qdfx"]));
+        self.run(submodule_git().args(["reset", "-q", "--hard"]));
+        self.run(submodule_git().args(["clean", "-qdfx"]));
 
         if has_local_modifications {
-            self.run(helpers::git(Some(&absolute_path)).args(["stash", "pop"]));
+            self.run(submodule_git().args(["stash", "pop"]));
         }
     }
 
diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs
index 13d1346b3d9..4b6dc45b436 100644
--- a/src/bootstrap/src/utils/helpers.rs
+++ b/src/bootstrap/src/utils/helpers.rs
@@ -501,6 +501,16 @@ pub fn git(source_dir: Option<&Path>) -> Command {
 
     if let Some(source_dir) = source_dir {
         git.current_dir(source_dir);
+        // If we are running inside git (e.g. via a hook), `GIT_DIR` is set and takes precedence
+        // over the current dir. Un-set it to make the current dir matter.
+        git.env_remove("GIT_DIR");
+        // Also un-set some other variables, to be on the safe side (based on cargo's
+        // `fetch_with_cli`). In particular un-setting `GIT_INDEX_FILE` is required to fix some odd
+        // misbehavior.
+        git.env_remove("GIT_WORK_TREE")
+            .env_remove("GIT_INDEX_FILE")
+            .env_remove("GIT_OBJECT_DIRECTORY")
+            .env_remove("GIT_ALTERNATE_OBJECT_DIRECTORIES");
     }
 
     git
diff --git a/src/doc/book b/src/doc/book
-Subproject 5228bfac8267ad24659a81b92ec5417976b5edb
+Subproject 45c1a6d69edfd1fc91fb7504cb73958dbd09441
diff --git a/src/doc/edition-guide b/src/doc/edition-guide
-Subproject bbaabbe088e21a81a0d9ae6757705020d5d7b41
+Subproject cb58c430b4e8054c2cb81d2d4434092c482a93d
diff --git a/src/doc/reference b/src/doc/reference
-Subproject 6019b76f5b28938565b251bbba0bf5cc5c43d86
+Subproject 0b805c65804019b0ac8f2fe3117afad82a6069b
diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example
-Subproject 4840dca06cadf48b305d3ce0aeafde7f80933f8
+Subproject b1d97bd6113aba732b2091ce093c76f2d05bb8a
diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide
-Subproject 6a7374bd87cbac0f8be4fd4877d8186d9c31398
+Subproject aec82168dd3121289a194b381f56076fc789a4d
diff --git a/src/tools/miri/src/intrinsics/mod.rs b/src/tools/miri/src/intrinsics/mod.rs
index 74e39ffd933..313eac36337 100644
--- a/src/tools/miri/src/intrinsics/mod.rs
+++ b/src/tools/miri/src/intrinsics/mod.rs
@@ -57,7 +57,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
                     );
                 }
                 Ok(Some(ty::Instance {
-                    def: ty::InstanceDef::Item(instance.def_id()),
+                    def: ty::InstanceKind::Item(instance.def_id()),
                     args: instance.args,
                 }))
             }
diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs
index dab18dca2ff..f39bcfd60df 100644
--- a/src/tools/run-make-support/src/command.rs
+++ b/src/tools/run-make-support/src/command.rs
@@ -6,7 +6,7 @@ use std::path::Path;
 use std::process::{Command as StdCommand, ExitStatus, Output, Stdio};
 
 use crate::drop_bomb::DropBomb;
-use crate::{assert_contains, assert_not_contains, handle_failed_output};
+use crate::{assert_contains, assert_equals, assert_not_contains, handle_failed_output};
 
 /// This is a custom command wrapper that simplifies working with commands and makes it easier to
 /// ensure that we check the exit status of executed processes.
@@ -21,6 +21,7 @@ use crate::{assert_contains, assert_not_contains, handle_failed_output};
 ///
 /// [`run`]: Self::run
 /// [`run_fail`]: Self::run_fail
+/// [`run_unchecked`]: Self::run_unchecked
 #[derive(Debug)]
 pub struct Command {
     cmd: StdCommand,
@@ -116,6 +117,15 @@ impl Command {
         output
     }
 
+    /// Run the command but do not check its exit status.
+    /// Only use if you explicitly don't care about the exit status.
+    /// Prefer to use [`Self::run`] and [`Self::run_fail`]
+    /// whenever possible.
+    #[track_caller]
+    pub fn run_unchecked(&mut self) -> CompletedProcess {
+        self.command_output()
+    }
+
     #[track_caller]
     fn command_output(&mut self) -> CompletedProcess {
         self.drop_bomb.defuse();
@@ -163,41 +173,45 @@ impl CompletedProcess {
         self.output.status
     }
 
-    /// Checks that trimmed `stdout` matches trimmed `content`.
+    /// Checks that trimmed `stdout` matches trimmed `expected`.
     #[track_caller]
-    pub fn assert_stdout_equals<S: AsRef<str>>(&self, content: S) -> &Self {
-        assert_eq!(self.stdout_utf8().trim(), content.as_ref().trim());
+    pub fn assert_stdout_equals<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_equals(self.stdout_utf8().trim(), expected.as_ref().trim());
         self
     }
 
+    /// Checks that `stdout` does not contain `unexpected`.
     #[track_caller]
-    pub fn assert_stdout_contains<S: AsRef<str>>(self, needle: S) -> Self {
-        assert_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
+        assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
         self
     }
 
+    /// Checks that `stdout` contains `expected`.
     #[track_caller]
-    pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_not_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_contains(&self.stdout_utf8(), expected.as_ref());
         self
     }
 
-    /// Checks that trimmed `stderr` matches trimmed `content`.
+    /// Checks that trimmed `stderr` matches trimmed `expected`.
     #[track_caller]
-    pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {
-        assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
+    pub fn assert_stderr_equals<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_equals(self.stderr_utf8().trim(), expected.as_ref().trim());
         self
     }
 
+    /// Checks that `stderr` contains `expected`.
     #[track_caller]
-    pub fn assert_stderr_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_contains(&self.stderr_utf8(), needle.as_ref());
+    pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_contains(&self.stderr_utf8(), expected.as_ref());
         self
     }
 
+    /// Checks that `stderr` does not contain `unexpected`.
     #[track_caller]
-    pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_not_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
+        assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
         self
     }
 
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index ba4524c150c..a358ae83de1 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -214,6 +214,38 @@ pub fn cwd() -> PathBuf {
     env::current_dir().unwrap()
 }
 
+// FIXME(Oneirical): This will no longer be required after compiletest receives the ability
+// to manipulate read-only files. See https://github.com/rust-lang/rust/issues/126334
+/// Ensure that the path P is read-only while the test runs, and restore original permissions
+/// at the end so compiletest can clean up.
+/// This will panic on Windows if the path is a directory (as it would otherwise do nothing)
+#[track_caller]
+pub fn test_while_readonly<P: AsRef<Path>, F: FnOnce() + std::panic::UnwindSafe>(
+    path: P,
+    closure: F,
+) {
+    let path = path.as_ref();
+    if is_windows() && path.is_dir() {
+        eprintln!("This helper function cannot be used on Windows to make directories readonly.");
+        eprintln!(
+            "See the official documentation:
+            https://doc.rust-lang.org/std/fs/struct.Permissions.html#method.set_readonly"
+        );
+        panic!("`test_while_readonly` on directory detected while on Windows.");
+    }
+    let metadata = fs_wrapper::metadata(&path);
+    let original_perms = metadata.permissions();
+
+    let mut new_perms = original_perms.clone();
+    new_perms.set_readonly(true);
+    fs_wrapper::set_permissions(&path, new_perms);
+
+    let success = std::panic::catch_unwind(closure);
+
+    fs_wrapper::set_permissions(&path, original_perms);
+    success.unwrap();
+}
+
 /// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
 /// available on the platform!
 #[track_caller]
@@ -332,6 +364,18 @@ pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) {
     }
 }
 
+/// Check that `actual` is equal to `expected`. Panic otherwise.
+#[track_caller]
+pub fn assert_equals(actual: &str, expected: &str) {
+    if actual != expected {
+        eprintln!("=== ACTUAL TEXT ===");
+        eprintln!("{}", actual);
+        eprintln!("=== EXPECTED ===");
+        eprintln!("{}", expected);
+        panic!("expected text was not found in actual text");
+    }
+}
+
 /// Check that `haystack` contains `needle`. Panic otherwise.
 #[track_caller]
 pub fn assert_contains(haystack: &str, needle: &str) {
@@ -468,6 +512,15 @@ macro_rules! impl_common_helpers {
                 self.cmd.run_fail()
             }
 
+            /// Run the command but do not check its exit status.
+            /// Only use if you explicitly don't care about the exit status.
+            /// Prefer to use [`Self::run`] and [`Self::run_fail`]
+            /// whenever possible.
+            #[track_caller]
+            pub fn run_unchecked(&mut self) -> crate::command::CompletedProcess {
+                self.cmd.run_unchecked()
+            }
+
             /// Set the path where the command will be run.
             pub fn current_dir<P: AsRef<::std::path::Path>>(&mut self, path: P) -> &mut Self {
                 self.cmd.current_dir(path);
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index fdd0be79a4d..895798d7c1f 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -61,7 +61,6 @@ run-make/foreign-double-unwind/Makefile
 run-make/foreign-exceptions/Makefile
 run-make/foreign-rust-exceptions/Makefile
 run-make/glibc-staticlib-args/Makefile
-run-make/inaccessible-temp-dir/Makefile
 run-make/include_bytes_deps/Makefile
 run-make/incr-add-rust-src-component/Makefile
 run-make/incr-foreign-head-span/Makefile
@@ -74,7 +73,6 @@ run-make/invalid-library/Makefile
 run-make/invalid-so/Makefile
 run-make/invalid-staticlib/Makefile
 run-make/issue-107094/Makefile
-run-make/issue-10971-temps-dir/Makefile
 run-make/issue-109934-lto-debuginfo/Makefile
 run-make/issue-14698/Makefile
 run-make/issue-15460/Makefile
@@ -83,7 +81,6 @@ run-make/issue-20626/Makefile
 run-make/issue-22131/Makefile
 run-make/issue-25581/Makefile
 run-make/issue-26006/Makefile
-run-make/issue-26092/Makefile
 run-make/issue-28595/Makefile
 run-make/issue-33329/Makefile
 run-make/issue-35164/Makefile
@@ -109,10 +106,8 @@ run-make/libtest-json/Makefile
 run-make/libtest-junit/Makefile
 run-make/libtest-padding/Makefile
 run-make/libtest-thread-limit/Makefile
-run-make/link-arg/Makefile
 run-make/link-args-order/Makefile
 run-make/link-cfg/Makefile
-run-make/link-dedup/Makefile
 run-make/link-framework/Makefile
 run-make/link-path-order/Makefile
 run-make/linkage-attr-on-static/Makefile
@@ -153,7 +148,6 @@ run-make/optimization-remarks-dir/Makefile
 run-make/output-filename-conflicts-with-directory/Makefile
 run-make/output-filename-overwrites-input/Makefile
 run-make/output-type-permutations/Makefile
-run-make/output-with-hyphens/Makefile
 run-make/override-aliased-flags/Makefile
 run-make/overwrite-input/Makefile
 run-make/panic-abort-eh_frame/Makefile