Skip to content

Commit 492c619

Browse files
committed
Auto merge of #140027 - jhpratt:rollup-33i0na2, r=jhpratt
Rollup of 9 pull requests Successful merges: - #137454 (not lint break with label and unsafe block) - #139297 (Deduplicate & clean up Nix shell) - #139535 (Implement `Default` for raw pointers) - #139753 (Make `#[naked]` an unsafe attribute) - #139922 (fix incorrect type in cstr `to_string_lossy()` docs) - #139978 (Add citool command for generating a test dashboard) - #140007 (Disable has_thread_local on i686-win7-windows-msvc) - #140016 (std: Use fstatat() on illumos) - #140025 (Re-remove `AdtFlags::IS_ANONYMOUS`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2ef7858 + c8de1ca commit 492c619

File tree

68 files changed

+1062
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1062
-486
lines changed

Diff for: compiler/rustc_builtin_macros/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ builtin_macros_multiple_defaults = multiple declared defaults
247247
.suggestion = make `{$ident}` default
248248
249249
builtin_macros_naked_functions_testing_attribute =
250-
cannot use `#[naked]` with testing attributes
250+
cannot use `#[unsafe(naked)]` with testing attributes
251251
.label = function marked with testing attribute here
252-
.naked_attribute = `#[naked]` is incompatible with testing attributes
252+
.naked_attribute = `#[unsafe(naked)]` is incompatible with testing attributes
253253
254254
builtin_macros_no_default_variant = `#[derive(Default)]` on enum with no `#[default]`
255255
.label = this enum needs a unit variant marked with `#[default]`

Diff for: compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,9 @@ global_asm! {
387387
}
388388

389389
#[cfg(all(not(jit), target_arch = "x86_64"))]
390-
#[naked]
390+
#[unsafe(naked)]
391391
extern "C" fn naked_test() {
392-
unsafe {
393-
naked_asm!("ret");
394-
}
392+
naked_asm!("ret")
395393
}
396394

397395
#[repr(C)]

Diff for: compiler/rustc_error_codes/src/error_codes/E0736.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Erroneous code example:
1111

1212
```compile_fail,E0736
1313
#[inline]
14-
#[naked]
14+
#[unsafe(naked)]
1515
fn foo() {}
1616
```
1717

Diff for: compiler/rustc_error_codes/src/error_codes/E0787.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Erroneous code example:
55
```compile_fail,E0787
66
#![feature(naked_functions)]
77
8-
#[naked]
8+
#[unsafe(naked)]
99
pub extern "C" fn f() -> u32 {
1010
42
1111
}

Diff for: compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
517517

518518
// Linking:
519519
gated!(
520-
naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
520+
unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
521521
naked_functions, experimental!(naked)
522522
),
523523

Diff for: compiler/rustc_middle/src/ty/adt.rs

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ bitflags::bitflags! {
5555
const IS_UNSAFE_CELL = 1 << 9;
5656
/// Indicates whether the type is `UnsafePinned`.
5757
const IS_UNSAFE_PINNED = 1 << 10;
58-
/// Indicates whether the type is anonymous.
59-
const IS_ANONYMOUS = 1 << 11;
6058
}
6159
}
6260
rustc_data_structures::external_bitflags_debug! { AdtFlags }

Diff for: compiler/rustc_mir_build/src/check_unsafety.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -564,13 +564,17 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
564564
}
565565
}
566566
ExprKind::InlineAsm(box InlineAsmExpr {
567-
asm_macro: AsmMacro::Asm | AsmMacro::NakedAsm,
567+
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
568568
ref operands,
569569
template: _,
570570
options: _,
571571
line_spans: _,
572572
}) => {
573-
self.requires_unsafe(expr.span, UseOfInlineAssembly);
573+
// The `naked` attribute and the `naked_asm!` block form one atomic unit of
574+
// unsafety, and `naked_asm!` does not itself need to be wrapped in an unsafe block.
575+
if let AsmMacro::Asm = asm_macro {
576+
self.requires_unsafe(expr.span, UseOfInlineAssembly);
577+
}
574578

575579
// For inline asm, do not use `walk_expr`, since we want to handle the label block
576580
// specially.

Diff for: compiler/rustc_parse/src/parser/expr.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1884,13 +1884,15 @@ impl<'a> Parser<'a> {
18841884
let mut expr = self.parse_expr_opt()?;
18851885
if let Some(expr) = &mut expr {
18861886
if label.is_some()
1887-
&& matches!(
1888-
expr.kind,
1887+
&& match &expr.kind {
18891888
ExprKind::While(_, _, None)
1890-
| ExprKind::ForLoop { label: None, .. }
1891-
| ExprKind::Loop(_, None, _)
1892-
| ExprKind::Block(_, None)
1893-
)
1889+
| ExprKind::ForLoop { label: None, .. }
1890+
| ExprKind::Loop(_, None, _) => true,
1891+
ExprKind::Block(block, None) => {
1892+
matches!(block.rules, BlockCheckMode::Default)
1893+
}
1894+
_ => false,
1895+
}
18941896
{
18951897
self.psess.buffer_lint(
18961898
BREAK_WITH_LABEL_AND_LOOP,

Diff for: compiler/rustc_parse/src/validate_attr.rs

-6
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
194194
}
195195
}
196196
} else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
197-
// Allow (but don't require) `#[unsafe(naked)]` so that compiler-builtins can upgrade to it.
198-
// FIXME(#139797): remove this special case when compiler-builtins has upgraded.
199-
if attr.has_name(sym::naked) {
200-
return;
201-
}
202-
203197
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
204198
span: unsafe_span,
205199
name: attr_item.path.clone(),

Diff for: compiler/rustc_passes/messages.ftl

+4-4
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,17 @@ passes_must_use_no_effect =
508508
`#[must_use]` has no effect when applied to {$article} {$target}
509509
510510
passes_naked_asm_outside_naked_fn =
511-
the `naked_asm!` macro can only be used in functions marked with `#[naked]`
511+
the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
512512
513513
passes_naked_functions_asm_block =
514514
naked functions must contain a single `naked_asm!` invocation
515515
.label_multiple_asm = multiple `naked_asm!` invocations are not allowed in naked functions
516516
.label_non_asm = not allowed in naked functions
517517
518518
passes_naked_functions_incompatible_attribute =
519-
attribute incompatible with `#[naked]`
520-
.label = the `{$attr}` attribute is incompatible with `#[naked]`
521-
.naked_attribute = function marked with `#[naked]` here
519+
attribute incompatible with `#[unsafe(naked)]`
520+
.label = the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`
521+
.naked_attribute = function marked with `#[unsafe(naked)]` here
522522
523523
passes_naked_functions_must_naked_asm =
524524
the `asm!` macro is not allowed in naked functions

Diff for: compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ pub(crate) fn target() -> Target {
77
base.cpu = "pentium4".into();
88
base.max_atomic_width = Some(64);
99
base.supported_sanitizers = SanitizerSet::ADDRESS;
10+
// On Windows 7 32-bit, the alignment characteristic of the TLS Directory
11+
// don't appear to be respected by the PE Loader, leading to crashes. As
12+
// a result, let's disable has_thread_local to make sure TLS goes through
13+
// the emulation layer.
14+
// See https://github.com/rust-lang/rust/issues/138903
15+
base.has_thread_local = false;
1016

1117
base.add_pre_link_args(
1218
LinkerFlavor::Msvc(Lld::No),

Diff for: library/alloc/src/ffi/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ impl CStr {
11161116
/// with the corresponding <code>&[str]</code> slice. Otherwise, it will
11171117
/// replace any invalid UTF-8 sequences with
11181118
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a
1119-
/// <code>[Cow]::[Owned]\(&[str])</code> with the result.
1119+
/// <code>[Cow]::[Owned]\([String])</code> with the result.
11201120
///
11211121
/// [str]: prim@str "str"
11221122
/// [Borrowed]: Cow::Borrowed

Diff for: library/core/src/ptr/const_ptr.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1739,3 +1739,11 @@ impl<T: ?Sized> PartialOrd for *const T {
17391739
*self >= *other
17401740
}
17411741
}
1742+
1743+
#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
1744+
impl<T: ?Sized + Thin> Default for *const T {
1745+
/// Returns the default value of [`null()`][crate::ptr::null].
1746+
fn default() -> Self {
1747+
crate::ptr::null()
1748+
}
1749+
}

Diff for: library/core/src/ptr/mut_ptr.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2156,3 +2156,11 @@ impl<T: ?Sized> PartialOrd for *mut T {
21562156
*self >= *other
21572157
}
21582158
}
2159+
2160+
#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
2161+
impl<T: ?Sized + Thin> Default for *mut T {
2162+
/// Returns the default value of [`null_mut()`][crate::ptr::null_mut].
2163+
fn default() -> Self {
2164+
crate::ptr::null_mut()
2165+
}
2166+
}

Diff for: library/coretests/tests/ptr.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1020,3 +1020,20 @@ fn test_ptr_swap_nonoverlapping_is_untyped() {
10201020
ptr_swap_nonoverlapping_is_untyped_inner();
10211021
const { ptr_swap_nonoverlapping_is_untyped_inner() };
10221022
}
1023+
1024+
#[test]
1025+
fn test_ptr_default() {
1026+
#[derive(Default)]
1027+
struct PtrDefaultTest {
1028+
ptr: *const u64,
1029+
}
1030+
let default = PtrDefaultTest::default();
1031+
assert!(default.ptr.is_null());
1032+
1033+
#[derive(Default)]
1034+
struct PtrMutDefaultTest {
1035+
ptr: *mut u64,
1036+
}
1037+
let default = PtrMutDefaultTest::default();
1038+
assert!(default.ptr.is_null());
1039+
}

Diff for: library/std/src/sys/fs/unix.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ use libc::c_char;
1212
all(target_os = "linux", not(target_env = "musl")),
1313
target_os = "android",
1414
target_os = "fuchsia",
15-
target_os = "hurd"
15+
target_os = "hurd",
16+
target_os = "illumos",
1617
))]
1718
use libc::dirfd;
18-
#[cfg(target_os = "fuchsia")]
19+
#[cfg(any(target_os = "fuchsia", target_os = "illumos"))]
1920
use libc::fstatat as fstatat64;
2021
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
2122
use libc::fstatat64;
@@ -892,7 +893,8 @@ impl DirEntry {
892893
all(target_os = "linux", not(target_env = "musl")),
893894
target_os = "android",
894895
target_os = "fuchsia",
895-
target_os = "hurd"
896+
target_os = "hurd",
897+
target_os = "illumos",
896898
),
897899
not(miri) // no dirfd on Miri
898900
))]
@@ -922,6 +924,7 @@ impl DirEntry {
922924
target_os = "android",
923925
target_os = "fuchsia",
924926
target_os = "hurd",
927+
target_os = "illumos",
925928
)),
926929
miri
927930
))]

Diff for: src/ci/citool/Cargo.lock

+67
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,63 @@ version = "1.0.95"
6464
source = "registry+https://github.com/rust-lang/crates.io-index"
6565
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
6666

67+
[[package]]
68+
name = "askama"
69+
version = "0.13.1"
70+
source = "registry+https://github.com/rust-lang/crates.io-index"
71+
checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7"
72+
dependencies = [
73+
"askama_derive",
74+
"itoa",
75+
"percent-encoding",
76+
"serde",
77+
"serde_json",
78+
]
79+
80+
[[package]]
81+
name = "askama_derive"
82+
version = "0.13.1"
83+
source = "registry+https://github.com/rust-lang/crates.io-index"
84+
checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac"
85+
dependencies = [
86+
"askama_parser",
87+
"basic-toml",
88+
"memchr",
89+
"proc-macro2",
90+
"quote",
91+
"rustc-hash",
92+
"serde",
93+
"serde_derive",
94+
"syn",
95+
]
96+
97+
[[package]]
98+
name = "askama_parser"
99+
version = "0.13.0"
100+
source = "registry+https://github.com/rust-lang/crates.io-index"
101+
checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
102+
dependencies = [
103+
"memchr",
104+
"serde",
105+
"serde_derive",
106+
"winnow",
107+
]
108+
67109
[[package]]
68110
name = "base64"
69111
version = "0.22.1"
70112
source = "registry+https://github.com/rust-lang/crates.io-index"
71113
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
72114

115+
[[package]]
116+
name = "basic-toml"
117+
version = "0.1.10"
118+
source = "registry+https://github.com/rust-lang/crates.io-index"
119+
checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
120+
dependencies = [
121+
"serde",
122+
]
123+
73124
[[package]]
74125
name = "build_helper"
75126
version = "0.1.0"
@@ -104,6 +155,7 @@ name = "citool"
104155
version = "0.1.0"
105156
dependencies = [
106157
"anyhow",
158+
"askama",
107159
"build_helper",
108160
"clap",
109161
"csv",
@@ -646,6 +698,12 @@ dependencies = [
646698
"windows-sys 0.52.0",
647699
]
648700

701+
[[package]]
702+
name = "rustc-hash"
703+
version = "2.1.1"
704+
source = "registry+https://github.com/rust-lang/crates.io-index"
705+
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
706+
649707
[[package]]
650708
name = "rustls"
651709
version = "0.23.23"
@@ -1026,6 +1084,15 @@ version = "0.52.6"
10261084
source = "registry+https://github.com/rust-lang/crates.io-index"
10271085
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
10281086

1087+
[[package]]
1088+
name = "winnow"
1089+
version = "0.7.6"
1090+
source = "registry+https://github.com/rust-lang/crates.io-index"
1091+
checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
1092+
dependencies = [
1093+
"memchr",
1094+
]
1095+
10291096
[[package]]
10301097
name = "write16"
10311098
version = "1.0.0"

Diff for: src/ci/citool/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
anyhow = "1"
8+
askama = "0.13"
89
clap = { version = "4.5", features = ["derive"] }
910
csv = "1"
1011
diff = "0.1"

Diff for: src/ci/citool/src/analysis.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use build_helper::metrics::{
88
};
99

1010
use crate::github::JobInfoResolver;
11-
use crate::metrics;
1211
use crate::metrics::{JobMetrics, JobName, get_test_suites};
1312
use crate::utils::{output_details, pluralize};
13+
use crate::{metrics, utils};
1414

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

404-
/// Normalizes Windows-style path delimiters to Unix-style paths.
405-
fn generate_test_name(name: &str) -> String {
406-
name.replace('\\', "/")
407-
}
408-
409408
/// Prints test changes in Markdown format to stdout.
410409
fn report_test_diffs(
411410
diff: AggregatedTestDiffs,

0 commit comments

Comments
 (0)