about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-26 06:40:36 +0000
committerbors <bors@rust-lang.org>2024-07-26 06:40:36 +0000
commitf98fdfc8a449bf535602b971e8eb12fd282de305 (patch)
treef1616040f0575679c5a75a89c75ae074a1b3688f /src
parent35e70f3e7ec31d5c8bb07f80c62559425a81979c (diff)
parent4bd2757b4ccf6c4fed986bae9593782112aecd80 (diff)
downloadrust-f98fdfc8a449bf535602b971e8eb12fd282de305.tar.gz
rust-f98fdfc8a449bf535602b971e8eb12fd282de305.zip
Auto merge of #3765 - rust-lang:rustup-2024-07-26, r=RalfJung
Automatic Rustup
Diffstat (limited to 'src')
-rw-r--r--src/tools/clippy/clippy_lints/src/precedence.rs56
-rw-r--r--src/tools/clippy/tests/ui/precedence.fixed34
-rw-r--r--src/tools/clippy/tests/ui/precedence.rs34
-rw-r--r--src/tools/clippy/tests/ui/precedence.stderr32
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_cast.fixed2
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_cast.rs2
-rw-r--r--src/tools/miri/rust-version2
-rw-r--r--src/tools/miri/tests/pass/intrinsics/portable-simd.rs15
-rw-r--r--src/tools/run-make-support/src/external_deps/c_build.rs37
-rw-r--r--src/tools/run-make-support/src/fs.rs15
-rw-r--r--src/tools/run-make-support/src/lib.rs2
-rw-r--r--src/tools/rustfmt/tests/source/type.rs2
-rw-r--r--src/tools/rustfmt/tests/target/negative-bounds.rs6
-rw-r--r--src/tools/rustfmt/tests/target/type.rs2
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt6
-rw-r--r--src/tools/tidy/src/deps.rs2
-rw-r--r--src/tools/tidy/src/ui_tests.rs2
17 files changed, 71 insertions, 180 deletions
diff --git a/src/tools/clippy/clippy_lints/src/precedence.rs b/src/tools/clippy/clippy_lints/src/precedence.rs
index ff83725da69..37f5dd5583b 100644
--- a/src/tools/clippy/clippy_lints/src/precedence.rs
+++ b/src/tools/clippy/clippy_lints/src/precedence.rs
@@ -1,38 +1,17 @@
 use clippy_utils::diagnostics::span_lint_and_sugg;
 use clippy_utils::source::snippet_with_applicability;
-use rustc_ast::ast::{BinOpKind, Expr, ExprKind, MethodCall, UnOp};
-use rustc_ast::token;
+use rustc_ast::ast::{BinOpKind, Expr, ExprKind};
 use rustc_errors::Applicability;
 use rustc_lint::{EarlyContext, EarlyLintPass};
 use rustc_session::declare_lint_pass;
 use rustc_span::source_map::Spanned;
 
-const ALLOWED_ODD_FUNCTIONS: [&str; 14] = [
-    "asin",
-    "asinh",
-    "atan",
-    "atanh",
-    "cbrt",
-    "fract",
-    "round",
-    "signum",
-    "sin",
-    "sinh",
-    "tan",
-    "tanh",
-    "to_degrees",
-    "to_radians",
-];
-
 declare_clippy_lint! {
     /// ### What it does
     /// Checks for operations where precedence may be unclear
     /// and suggests to add parentheses. Currently it catches the following:
     /// * mixed usage of arithmetic and bit shifting/combining operators without
     /// parentheses
-    /// * a "negative" numeric literal (which is really a unary `-` followed by a
-    /// numeric literal)
-    ///   followed by a method call
     ///
     /// ### Why is this bad?
     /// Not everyone knows the precedence of those operators by
@@ -41,7 +20,6 @@ declare_clippy_lint! {
     ///
     /// ### Example
     /// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
-    /// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1
     #[clippy::version = "pre 1.29.0"]
     pub PRECEDENCE,
     complexity,
@@ -104,38 +82,6 @@ impl EarlyLintPass for Precedence {
                 (false, false) => (),
             }
         }
-
-        if let ExprKind::Unary(UnOp::Neg, operand) = &expr.kind {
-            let mut arg = operand;
-
-            let mut all_odd = true;
-            while let ExprKind::MethodCall(box MethodCall { seg, receiver, .. }) = &arg.kind {
-                let seg_str = seg.ident.name.as_str();
-                all_odd &= ALLOWED_ODD_FUNCTIONS
-                    .iter()
-                    .any(|odd_function| **odd_function == *seg_str);
-                arg = receiver;
-            }
-
-            if !all_odd
-                && let ExprKind::Lit(lit) = &arg.kind
-                && let token::LitKind::Integer | token::LitKind::Float = &lit.kind
-            {
-                let mut applicability = Applicability::MachineApplicable;
-                span_lint_and_sugg(
-                    cx,
-                    PRECEDENCE,
-                    expr.span,
-                    "unary minus has lower precedence than method call",
-                    "consider adding parentheses to clarify your intent",
-                    format!(
-                        "-({})",
-                        snippet_with_applicability(cx, operand.span, "..", &mut applicability)
-                    ),
-                    applicability,
-                );
-            }
-        }
     }
 }
 
diff --git a/src/tools/clippy/tests/ui/precedence.fixed b/src/tools/clippy/tests/ui/precedence.fixed
index cc87de0d90f..c25c2062ace 100644
--- a/src/tools/clippy/tests/ui/precedence.fixed
+++ b/src/tools/clippy/tests/ui/precedence.fixed
@@ -20,40 +20,6 @@ fn main() {
     1 ^ (1 - 1);
     3 | (2 - 1);
     3 & (5 - 2);
-    -(1i32.abs());
-    -(1f32.abs());
-
-    // These should not trigger an error
-    let _ = (-1i32).abs();
-    let _ = (-1f32).abs();
-    let _ = -(1i32).abs();
-    let _ = -(1f32).abs();
-    let _ = -(1i32.abs());
-    let _ = -(1f32.abs());
-
-    // Odd functions should not trigger an error
-    let _ = -1f64.asin();
-    let _ = -1f64.asinh();
-    let _ = -1f64.atan();
-    let _ = -1f64.atanh();
-    let _ = -1f64.cbrt();
-    let _ = -1f64.fract();
-    let _ = -1f64.round();
-    let _ = -1f64.signum();
-    let _ = -1f64.sin();
-    let _ = -1f64.sinh();
-    let _ = -1f64.tan();
-    let _ = -1f64.tanh();
-    let _ = -1f64.to_degrees();
-    let _ = -1f64.to_radians();
-
-    // Chains containing any non-odd function should trigger (issue #5924)
-    let _ = -(1.0_f64.cos().cos());
-    let _ = -(1.0_f64.cos().sin());
-    let _ = -(1.0_f64.sin().cos());
-
-    // Chains of odd functions shouldn't trigger
-    let _ = -1f64.sin().sin();
 
     let b = 3;
     trip!(b * 8);
diff --git a/src/tools/clippy/tests/ui/precedence.rs b/src/tools/clippy/tests/ui/precedence.rs
index 00c18d92b5f..dc242ecf4c7 100644
--- a/src/tools/clippy/tests/ui/precedence.rs
+++ b/src/tools/clippy/tests/ui/precedence.rs
@@ -20,40 +20,6 @@ fn main() {
     1 ^ 1 - 1;
     3 | 2 - 1;
     3 & 5 - 2;
-    -1i32.abs();
-    -1f32.abs();
-
-    // These should not trigger an error
-    let _ = (-1i32).abs();
-    let _ = (-1f32).abs();
-    let _ = -(1i32).abs();
-    let _ = -(1f32).abs();
-    let _ = -(1i32.abs());
-    let _ = -(1f32.abs());
-
-    // Odd functions should not trigger an error
-    let _ = -1f64.asin();
-    let _ = -1f64.asinh();
-    let _ = -1f64.atan();
-    let _ = -1f64.atanh();
-    let _ = -1f64.cbrt();
-    let _ = -1f64.fract();
-    let _ = -1f64.round();
-    let _ = -1f64.signum();
-    let _ = -1f64.sin();
-    let _ = -1f64.sinh();
-    let _ = -1f64.tan();
-    let _ = -1f64.tanh();
-    let _ = -1f64.to_degrees();
-    let _ = -1f64.to_radians();
-
-    // Chains containing any non-odd function should trigger (issue #5924)
-    let _ = -1.0_f64.cos().cos();
-    let _ = -1.0_f64.cos().sin();
-    let _ = -1.0_f64.sin().cos();
-
-    // Chains of odd functions shouldn't trigger
-    let _ = -1f64.sin().sin();
 
     let b = 3;
     trip!(b * 8);
diff --git a/src/tools/clippy/tests/ui/precedence.stderr b/src/tools/clippy/tests/ui/precedence.stderr
index 47e61326219..8057c25a5e4 100644
--- a/src/tools/clippy/tests/ui/precedence.stderr
+++ b/src/tools/clippy/tests/ui/precedence.stderr
@@ -43,35 +43,5 @@ error: operator precedence can trip the unwary
 LL |     3 & 5 - 2;
    |     ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)`
 
-error: unary minus has lower precedence than method call
-  --> tests/ui/precedence.rs:23:5
-   |
-LL |     -1i32.abs();
-   |     ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())`
-
-error: unary minus has lower precedence than method call
-  --> tests/ui/precedence.rs:24:5
-   |
-LL |     -1f32.abs();
-   |     ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())`
-
-error: unary minus has lower precedence than method call
-  --> tests/ui/precedence.rs:51:13
-   |
-LL |     let _ = -1.0_f64.cos().cos();
-   |             ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().cos())`
-
-error: unary minus has lower precedence than method call
-  --> tests/ui/precedence.rs:52:13
-   |
-LL |     let _ = -1.0_f64.cos().sin();
-   |             ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().sin())`
-
-error: unary minus has lower precedence than method call
-  --> tests/ui/precedence.rs:53:13
-   |
-LL |     let _ = -1.0_f64.sin().cos();
-   |             ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.sin().cos())`
-
-error: aborting due to 12 previous errors
+error: aborting due to 7 previous errors
 
diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.fixed b/src/tools/clippy/tests/ui/unnecessary_cast.fixed
index 288541362cd..c43e50761bd 100644
--- a/src/tools/clippy/tests/ui/unnecessary_cast.fixed
+++ b/src/tools/clippy/tests/ui/unnecessary_cast.fixed
@@ -206,7 +206,7 @@ mod fixable {
 
     fn issue_9563() {
         let _: f64 = (-8.0_f64).exp();
-        #[allow(clippy::precedence)]
+        #[allow(ambiguous_negative_literals)]
         let _: f64 = -8.0_f64.exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior
     }
 
diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.rs b/src/tools/clippy/tests/ui/unnecessary_cast.rs
index eef3a42e351..4a5ca231315 100644
--- a/src/tools/clippy/tests/ui/unnecessary_cast.rs
+++ b/src/tools/clippy/tests/ui/unnecessary_cast.rs
@@ -206,7 +206,7 @@ mod fixable {
 
     fn issue_9563() {
         let _: f64 = (-8.0 as f64).exp();
-        #[allow(clippy::precedence)]
+        #[allow(ambiguous_negative_literals)]
         let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior
     }
 
diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version
index 9868188eeee..e1a6084b22e 100644
--- a/src/tools/miri/rust-version
+++ b/src/tools/miri/rust-version
@@ -1 +1 @@
-e7d66eac5e8e8f60370c98d186aee9fa0ebd7845
+72d73cec61aa8f85901358cd5d386d5dd066fe52
diff --git a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs
index 03d9fc0a76f..c4ba11d0a43 100644
--- a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs
+++ b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs
@@ -1,10 +1,23 @@
 //@compile-flags: -Zmiri-strict-provenance
-#![feature(portable_simd, adt_const_params, core_intrinsics, repr_simd)]
+#![feature(
+    portable_simd,
+    unsized_const_params,
+    adt_const_params,
+    rustc_attrs,
+    intrinsics,
+    core_intrinsics,
+    repr_simd
+)]
 #![allow(incomplete_features, internal_features)]
 use std::intrinsics::simd as intrinsics;
 use std::ptr;
 use std::simd::{prelude::*, StdFloat};
 
+extern "rust-intrinsic" {
+    #[rustc_nounwind]
+    pub fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;
+}
+
 fn simd_ops_f32() {
     let a = f32x4::splat(10.0);
     let b = f32x4::from_array([1.0, 2.0, 3.0, -4.0]);
diff --git a/src/tools/run-make-support/src/external_deps/c_build.rs b/src/tools/run-make-support/src/external_deps/c_build.rs
index 35b2bf75c95..86c9c081831 100644
--- a/src/tools/run-make-support/src/external_deps/c_build.rs
+++ b/src/tools/run-make-support/src/external_deps/c_build.rs
@@ -1,10 +1,13 @@
 use std::path::PathBuf;
 
-use crate::artifact_names::static_lib_name;
+use super::cygpath::get_windows_path;
+use crate::artifact_names::{dynamic_lib_name, static_lib_name};
 use crate::external_deps::cc::cc;
 use crate::external_deps::llvm::llvm_ar;
 use crate::path_helpers::path;
-use crate::targets::is_msvc;
+use crate::targets::{is_darwin, is_msvc, is_windows};
+
+// FIXME(Oneirical): These native build functions should take a Path-based generic.
 
 /// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
 #[track_caller]
@@ -25,3 +28,33 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
     llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
     path(lib_path)
 }
+
+/// Builds a dynamic lib. The filename is computed in a target-dependent manner, relying on
+/// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`].
+#[track_caller]
+pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
+    let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
+    let src = format!("{lib_name}.c");
+    let lib_path = dynamic_lib_name(lib_name);
+    if is_msvc() {
+        cc().arg("-c").out_exe(&obj_file).input(src).run();
+    } else {
+        cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
+    };
+    let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
+    if is_msvc() {
+        let mut out_arg = "-out:".to_owned();
+        out_arg.push_str(&get_windows_path(&lib_path));
+        cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run();
+    } else if is_darwin() {
+        cc().out_exe(&lib_path).input(&obj_file).args(&["-dynamiclib", "-Wl,-dylib"]).run();
+    } else if is_windows() {
+        cc().out_exe(&lib_path)
+            .input(&obj_file)
+            .args(&["-shared", &format!("-Wl,--out-implib={lib_path}.a")])
+            .run();
+    } else {
+        cc().out_exe(&lib_path).input(&obj_file).arg("-shared").run();
+    }
+    path(lib_path)
+}
diff --git a/src/tools/run-make-support/src/fs.rs b/src/tools/run-make-support/src/fs.rs
index f346e983aea..0a796161633 100644
--- a/src/tools/run-make-support/src/fs.rs
+++ b/src/tools/run-make-support/src/fs.rs
@@ -1,5 +1,5 @@
 use std::io;
-use std::path::Path;
+use std::path::{Path, PathBuf};
 
 // FIXME(jieyouxu): modify create_symlink to panic on windows.
 
@@ -176,3 +176,16 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: std::fs::Permissions) {
         path.as_ref().display()
     ));
 }
+
+/// A function which prints all file names in the directory `dir` similarly to Unix's `ls`.
+/// Useful for debugging.
+/// Usage: `eprintln!("{:#?}", shallow_find_dir_entries(some_dir));`
+#[track_caller]
+pub fn shallow_find_dir_entries<P: AsRef<Path>>(dir: P) -> Vec<PathBuf> {
+    let paths = read_dir(dir);
+    let mut output = Vec::new();
+    for path in paths {
+        output.push(path.unwrap().path());
+    }
+    output
+}
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index b85191970de..a4bb9056346 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -43,7 +43,7 @@ pub use wasmparser;
 pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rustdoc};
 
 // These rely on external dependencies.
-pub use c_build::build_native_static_lib;
+pub use c_build::{build_native_dynamic_lib, build_native_static_lib};
 pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
 pub use clang::{clang, Clang};
 pub use htmldocck::htmldocck;
diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs
index 61ef73a3cab..7a232f85198 100644
--- a/src/tools/rustfmt/tests/source/type.rs
+++ b/src/tools/rustfmt/tests/source/type.rs
@@ -146,8 +146,6 @@ trait T: ~   const  Super {}
 
 const fn not_quite_const<S: ~  const    T>() -> i32 { <S as T>::CONST }
 
-struct S<T:~  const   ?  Sized>(std::marker::PhantomData<T>);
-
 impl ~    const T {}
 
 fn apit(_: impl ~   const T) {}
diff --git a/src/tools/rustfmt/tests/target/negative-bounds.rs b/src/tools/rustfmt/tests/target/negative-bounds.rs
index 4fb35cccf66..9fcb86ef4a4 100644
--- a/src/tools/rustfmt/tests/target/negative-bounds.rs
+++ b/src/tools/rustfmt/tests/target/negative-bounds.rs
@@ -3,9 +3,3 @@ where
     i32: !Copy,
 {
 }
-
-fn maybe_const_negative()
-where
-    i32: ~const !Copy,
-{
-}
diff --git a/src/tools/rustfmt/tests/target/type.rs b/src/tools/rustfmt/tests/target/type.rs
index c789ecb055a..325adb52f3f 100644
--- a/src/tools/rustfmt/tests/target/type.rs
+++ b/src/tools/rustfmt/tests/target/type.rs
@@ -153,8 +153,6 @@ const fn not_quite_const<S: ~const T>() -> i32 {
     <S as T>::CONST
 }
 
-struct S<T: ~const ?Sized>(std::marker::PhantomData<T>);
-
 impl ~const T {}
 
 fn apit(_: impl ~const T) {}
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 4042bac8dac..36f7f68ef7b 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -1,6 +1,4 @@
 run-make/branch-protection-check-IBT/Makefile
-run-make/c-dynamic-dylib/Makefile
-run-make/c-dynamic-rlib/Makefile
 run-make/c-unwind-abi-catch-lib-panic/Makefile
 run-make/cat-and-grep-sanity-check/Makefile
 run-make/cdylib-dylib-linkage/Makefile
@@ -15,11 +13,8 @@ run-make/dep-info/Makefile
 run-make/dump-ice-to-disk/Makefile
 run-make/emit-to-stdout/Makefile
 run-make/export-executable-symbols/Makefile
-run-make/extern-diff-internal-name/Makefile
 run-make/extern-flag-disambiguates/Makefile
 run-make/extern-fn-reachable/Makefile
-run-make/extern-multiple-copies/Makefile
-run-make/extern-multiple-copies2/Makefile
 run-make/fmt-write-bloat/Makefile
 run-make/foreign-double-unwind/Makefile
 run-make/foreign-exceptions/Makefile
@@ -51,7 +46,6 @@ run-make/panic-abort-eh_frame/Makefile
 run-make/pdb-buildinfo-cl-cmd/Makefile
 run-make/pgo-gen-lto/Makefile
 run-make/pgo-indirect-call-promotion/Makefile
-run-make/pointer-auth-link-with-c/Makefile
 run-make/print-calling-conventions/Makefile
 run-make/print-target-list/Makefile
 run-make/raw-dylib-alt-calling-convention/Makefile
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 6d61e0dd3ef..499e735b1df 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -269,7 +269,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
     "darling_macro",
     "datafrog",
     "deranged",
-    "derivative",
+    "derive-where",
     "derive_more",
     "derive_setters",
     "digest",
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 5e6992038e3..0ae0356b2c4 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -16,7 +16,7 @@ use std::path::{Path, PathBuf};
 const ENTRY_LIMIT: u32 = 901;
 // FIXME: The following limits should be reduced eventually.
 
-const ISSUES_ENTRY_LIMIT: u32 = 1672;
+const ISSUES_ENTRY_LIMIT: u32 = 1673;
 
 const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
     "rs",     // test source files