Skip to content

Rollup of 9 pull requests #140027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3fe0b3d
not lint break with label and unsafe block
mu001999 Feb 23, 2025
830bd8b
Implement Default for raw pointers
ChrisDenton Apr 6, 2025
2f0ba67
fix incorrect type in cstr `to_string_lossy()` docs
jnqnfe Apr 16, 2025
5a38550
Deduplicate nix code
RossSmyth Apr 3, 2025
d14df26
Make `parent` in `download_auto_job_metrics` optional
Kobzol Apr 16, 2025
111c15c
Extract function for normalizing path delimiters to `utils`
Kobzol Apr 16, 2025
c8a882b
Add command to `citool` for generating a test dashboard
Kobzol Apr 17, 2025
a326afd
Add buttons for expanding and collapsing all test suites
Kobzol Apr 17, 2025
4b31033
Add a note about how to find tests that haven't been executed anywhere.
Kobzol Apr 17, 2025
1a6e0d5
Render test revisions separately
Kobzol Apr 17, 2025
d2c1763
Create a macro for rendering test results
Kobzol Apr 17, 2025
aa9cb70
Print number of root tests and subdirectories
Kobzol Apr 17, 2025
08cb187
Turn `test_dashboard` into a file
Kobzol Apr 17, 2025
cecf167
Add a note about the test dashboard to the post-merge report
Kobzol Apr 17, 2025
65ce38a
Add a note that explains the counts
Kobzol Apr 18, 2025
b18e373
Reduce duplicated test prefixes in nested subdirectories
Kobzol Apr 18, 2025
1b39302
Disable has_thread_local on i686-win7-windows-msvc
roblabla Apr 18, 2025
fb3cae0
std: Use fstatat() on illumos
pfmooney Apr 18, 2025
41ddf86
Make `#[naked]` an unsafe attribute
folkertdev Mar 29, 2025
d863f81
Re-remove `AdtFlags::IS_ANONYMOUS`
Sky9x Apr 19, 2025
9455414
Rollup merge of #137454 - mu001999-contrib:fix-137414, r=wesleywiser
jhpratt Apr 19, 2025
44ae11c
Rollup merge of #139297 - RossSmyth:NixClean, r=WaffleLapkin
jhpratt Apr 19, 2025
4dc4640
Rollup merge of #139535 - ChrisDenton:default-ptr, r=tgross35
jhpratt Apr 19, 2025
73de020
Rollup merge of #139753 - folkertdev:naked-function-unsafe-attribute,…
jhpratt Apr 19, 2025
8ae204a
Rollup merge of #139922 - jnqnfe:cstr_doc_fix, r=jhpratt
jhpratt Apr 19, 2025
fdcacb8
Rollup merge of #139978 - Kobzol:ci-test-summary, r=jieyouxu
jhpratt Apr 19, 2025
1aeb903
Rollup merge of #140007 - roblabla:fix-win7, r=ChrisDenton
jhpratt Apr 19, 2025
54f947c
Rollup merge of #140016 - pfmooney:illumos-fstatat, r=jhpratt
jhpratt Apr 19, 2025
c8de1ca
Rollup merge of #140025 - Sky9x:re-remove-adtflags-anon, r=compiler-e…
jhpratt Apr 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ builtin_macros_multiple_defaults = multiple declared defaults
.suggestion = make `{$ident}` default
builtin_macros_naked_functions_testing_attribute =
cannot use `#[naked]` with testing attributes
cannot use `#[unsafe(naked)]` with testing attributes
.label = function marked with testing attribute here
.naked_attribute = `#[naked]` is incompatible with testing attributes
.naked_attribute = `#[unsafe(naked)]` is incompatible with testing attributes
builtin_macros_no_default_variant = `#[derive(Default)]` on enum with no `#[default]`
.label = this enum needs a unit variant marked with `#[default]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,9 @@ global_asm! {
}

#[cfg(all(not(jit), target_arch = "x86_64"))]
#[naked]
#[unsafe(naked)]
extern "C" fn naked_test() {
unsafe {
naked_asm!("ret");
}
naked_asm!("ret")
}

#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0736.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Erroneous code example:

```compile_fail,E0736
#[inline]
#[naked]
#[unsafe(naked)]
fn foo() {}
```

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0787.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Erroneous code example:
```compile_fail,E0787
#![feature(naked_functions)]
#[naked]
#[unsafe(naked)]
pub extern "C" fn f() -> u32 {
42
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[

// Linking:
gated!(
naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
naked_functions, experimental!(naked)
),

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ bitflags::bitflags! {
const IS_UNSAFE_CELL = 1 << 9;
/// Indicates whether the type is `UnsafePinned`.
const IS_UNSAFE_PINNED = 1 << 10;
/// Indicates whether the type is anonymous.
const IS_ANONYMOUS = 1 << 11;
}
}
rustc_data_structures::external_bitflags_debug! { AdtFlags }
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,17 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
}
}
ExprKind::InlineAsm(box InlineAsmExpr {
asm_macro: AsmMacro::Asm | AsmMacro::NakedAsm,
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
ref operands,
template: _,
options: _,
line_spans: _,
}) => {
self.requires_unsafe(expr.span, UseOfInlineAssembly);
// The `naked` attribute and the `naked_asm!` block form one atomic unit of
// unsafety, and `naked_asm!` does not itself need to be wrapped in an unsafe block.
if let AsmMacro::Asm = asm_macro {
self.requires_unsafe(expr.span, UseOfInlineAssembly);
}

// For inline asm, do not use `walk_expr`, since we want to handle the label block
// specially.
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1884,13 +1884,15 @@ impl<'a> Parser<'a> {
let mut expr = self.parse_expr_opt()?;
if let Some(expr) = &mut expr {
if label.is_some()
&& matches!(
expr.kind,
&& match &expr.kind {
ExprKind::While(_, _, None)
| ExprKind::ForLoop { label: None, .. }
| ExprKind::Loop(_, None, _)
| ExprKind::Block(_, None)
)
| ExprKind::ForLoop { label: None, .. }
| ExprKind::Loop(_, None, _) => true,
ExprKind::Block(block, None) => {
matches!(block.rules, BlockCheckMode::Default)
}
_ => false,
}
{
self.psess.buffer_lint(
BREAK_WITH_LABEL_AND_LOOP,
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_parse/src/validate_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
}
}
} else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
// Allow (but don't require) `#[unsafe(naked)]` so that compiler-builtins can upgrade to it.
// FIXME(#139797): remove this special case when compiler-builtins has upgraded.
if attr.has_name(sym::naked) {
return;
}

psess.dcx().emit_err(errors::InvalidAttrUnsafe {
span: unsafe_span,
name: attr_item.path.clone(),
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,17 @@ passes_must_use_no_effect =
`#[must_use]` has no effect when applied to {$article} {$target}

passes_naked_asm_outside_naked_fn =
the `naked_asm!` macro can only be used in functions marked with `#[naked]`
the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`

passes_naked_functions_asm_block =
naked functions must contain a single `naked_asm!` invocation
.label_multiple_asm = multiple `naked_asm!` invocations are not allowed in naked functions
.label_non_asm = not allowed in naked functions

passes_naked_functions_incompatible_attribute =
attribute incompatible with `#[naked]`
.label = the `{$attr}` attribute is incompatible with `#[naked]`
.naked_attribute = function marked with `#[naked]` here
attribute incompatible with `#[unsafe(naked)]`
.label = the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`
.naked_attribute = function marked with `#[unsafe(naked)]` here

passes_naked_functions_must_naked_asm =
the `asm!` macro is not allowed in naked functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ pub(crate) fn target() -> Target {
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS;
// On Windows 7 32-bit, the alignment characteristic of the TLS Directory
// don't appear to be respected by the PE Loader, leading to crashes. As
// a result, let's disable has_thread_local to make sure TLS goes through
// the emulation layer.
// See https://github.com/rust-lang/rust/issues/138903
base.has_thread_local = false;

base.add_pre_link_args(
LinkerFlavor::Msvc(Lld::No),
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ impl CStr {
/// with the corresponding <code>&[str]</code> slice. Otherwise, it will
/// replace any invalid UTF-8 sequences with
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a
/// <code>[Cow]::[Owned]\(&[str])</code> with the result.
/// <code>[Cow]::[Owned]\([String])</code> with the result.
///
/// [str]: prim@str "str"
/// [Borrowed]: Cow::Borrowed
Expand Down
8 changes: 8 additions & 0 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,3 +1739,11 @@ impl<T: ?Sized> PartialOrd for *const T {
*self >= *other
}
}

#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
impl<T: ?Sized + Thin> Default for *const T {
/// Returns the default value of [`null()`][crate::ptr::null].
fn default() -> Self {
crate::ptr::null()
}
}
8 changes: 8 additions & 0 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2156,3 +2156,11 @@ impl<T: ?Sized> PartialOrd for *mut T {
*self >= *other
}
}

#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
impl<T: ?Sized + Thin> Default for *mut T {
/// Returns the default value of [`null_mut()`][crate::ptr::null_mut].
fn default() -> Self {
crate::ptr::null_mut()
}
}
17 changes: 17 additions & 0 deletions library/coretests/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,3 +1020,20 @@ fn test_ptr_swap_nonoverlapping_is_untyped() {
ptr_swap_nonoverlapping_is_untyped_inner();
const { ptr_swap_nonoverlapping_is_untyped_inner() };
}

#[test]
fn test_ptr_default() {
#[derive(Default)]
struct PtrDefaultTest {
ptr: *const u64,
}
let default = PtrDefaultTest::default();
assert!(default.ptr.is_null());

#[derive(Default)]
struct PtrMutDefaultTest {
ptr: *mut u64,
}
let default = PtrMutDefaultTest::default();
assert!(default.ptr.is_null());
}
9 changes: 6 additions & 3 deletions library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use libc::c_char;
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "fuchsia",
target_os = "hurd"
target_os = "hurd",
target_os = "illumos",
))]
use libc::dirfd;
#[cfg(target_os = "fuchsia")]
#[cfg(any(target_os = "fuchsia", target_os = "illumos"))]
use libc::fstatat as fstatat64;
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
use libc::fstatat64;
Expand Down Expand Up @@ -892,7 +893,8 @@ impl DirEntry {
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "fuchsia",
target_os = "hurd"
target_os = "hurd",
target_os = "illumos",
),
not(miri) // no dirfd on Miri
))]
Expand Down Expand Up @@ -922,6 +924,7 @@ impl DirEntry {
target_os = "android",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
)),
miri
))]
Expand Down
67 changes: 67 additions & 0 deletions src/ci/citool/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,63 @@ version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"

[[package]]
name = "askama"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7"
dependencies = [
"askama_derive",
"itoa",
"percent-encoding",
"serde",
"serde_json",
]

[[package]]
name = "askama_derive"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac"
dependencies = [
"askama_parser",
"basic-toml",
"memchr",
"proc-macro2",
"quote",
"rustc-hash",
"serde",
"serde_derive",
"syn",
]

[[package]]
name = "askama_parser"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
dependencies = [
"memchr",
"serde",
"serde_derive",
"winnow",
]

[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"

[[package]]
name = "basic-toml"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
dependencies = [
"serde",
]

[[package]]
name = "build_helper"
version = "0.1.0"
Expand Down Expand Up @@ -104,6 +155,7 @@ name = "citool"
version = "0.1.0"
dependencies = [
"anyhow",
"askama",
"build_helper",
"clap",
"csv",
Expand Down Expand Up @@ -646,6 +698,12 @@ dependencies = [
"windows-sys 0.52.0",
]

[[package]]
name = "rustc-hash"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"

[[package]]
name = "rustls"
version = "0.23.23"
Expand Down Expand Up @@ -1026,6 +1084,15 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

[[package]]
name = "winnow"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
dependencies = [
"memchr",
]

[[package]]
name = "write16"
version = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/ci/citool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
anyhow = "1"
askama = "0.13"
clap = { version = "4.5", features = ["derive"] }
csv = "1"
diff = "0.1"
Expand Down
13 changes: 6 additions & 7 deletions src/ci/citool/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use build_helper::metrics::{
};

use crate::github::JobInfoResolver;
use crate::metrics;
use crate::metrics::{JobMetrics, JobName, get_test_suites};
use crate::utils::{output_details, pluralize};
use crate::{metrics, utils};

/// Outputs durations of individual bootstrap steps from the gathered bootstrap invocations,
/// and also a table with summarized information about executed tests.
Expand Down Expand Up @@ -394,18 +394,17 @@ fn aggregate_tests(metrics: &JsonRoot) -> TestSuiteData {
// Poor man's detection of doctests based on the "(line XYZ)" suffix
let is_doctest = matches!(suite.metadata, TestSuiteMetadata::CargoPackage { .. })
&& test.name.contains("(line");
let test_entry = Test { name: generate_test_name(&test.name), stage, is_doctest };
let test_entry = Test {
name: utils::normalize_path_delimiters(&test.name).to_string(),
stage,
is_doctest,
};
tests.insert(test_entry, test.outcome.clone());
}
}
TestSuiteData { tests }
}

/// Normalizes Windows-style path delimiters to Unix-style paths.
fn generate_test_name(name: &str) -> String {
name.replace('\\', "/")
}

/// Prints test changes in Markdown format to stdout.
fn report_test_diffs(
diff: AggregatedTestDiffs,
Expand Down
Loading
Loading