Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 492c619

Browse files
committed
Auto merge of rust-lang#140027 - jhpratt:rollup-33i0na2, r=jhpratt
Rollup of 9 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139535 (Implement `Default` for raw pointers) - rust-lang#139753 (Make `#[naked]` an unsafe attribute) - rust-lang#139922 (fix incorrect type in cstr `to_string_lossy()` docs) - rust-lang#139978 (Add citool command for generating a test dashboard) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) - rust-lang#140016 (std: Use fstatat() on illumos) - rust-lang#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

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 2 additions & 2 deletions
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]`

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 2 additions & 4 deletions
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)]

compiler/rustc_error_codes/src/error_codes/E0736.md

Lines changed: 1 addition & 1 deletion
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

compiler/rustc_error_codes/src/error_codes/E0787.md

Lines changed: 1 addition & 1 deletion
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
}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
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

compiler/rustc_middle/src/ty/adt.rs

Lines changed: 0 additions & 2 deletions
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 }

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 6 additions & 2 deletions
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.

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 8 additions & 6 deletions
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,

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 0 additions & 6 deletions
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(),

compiler/rustc_passes/messages.ftl

Lines changed: 4 additions & 4 deletions
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

0 commit comments

Comments
 (0)