Skip to content

Commit 3560e3c

Browse files
committed
Auto merge of rust-lang#129210 - tgross35:rollup-571noi5, r=tgross35
Rollup of 6 pull requests Successful merges: - rust-lang#128771 (Stabilize `unsafe_attributes`) - rust-lang#128982 (Re-enable more debuginfo tests on Windows) - rust-lang#129115 (Re-enable `dump-ice-to-disk` for Windows) - rust-lang#129173 (Fix `is_val_statically_known` for floats) - rust-lang#129185 (Port `run-make/libtest-json/validate_json.py` to Rust) - rust-lang#129190 (Added f16 and f128 to tests/ui/consts/const-float-bits-conv.rs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents feeba19 + b657787 commit 3560e3c

Some content is hidden

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

55 files changed

+253
-171
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
887887

888888
impl<'a> Visitor<'a> for AstValidator<'a> {
889889
fn visit_attribute(&mut self, attr: &Attribute) {
890-
validate_attr::check_attr(&self.features, &self.session.psess, attr);
890+
validate_attr::check_attr(&self.session.psess, attr);
891891
}
892892

893893
fn visit_ty(&mut self, ty: &'a Ty) {

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
559559
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
560560
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
561561
gate_all!(global_registration, "global registration is experimental");
562-
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
563562
gate_all!(return_type_notation, "return type notation is experimental");
564563

565564
if !visitor.features.never_patterns {

compiler/rustc_builtin_macros/src/cfg_accessible.rs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ impl MultiItemModifier for Expander {
4747
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
4848
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
4949
validate_attr::check_builtin_meta_item(
50-
&ecx.ecfg.features,
5150
&ecx.sess.psess,
5251
meta_item,
5352
ast::AttrStyle::Outer,

compiler/rustc_builtin_macros/src/derive.rs

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl MultiItemModifier for Expander {
3838
let template =
3939
AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() };
4040
validate_attr::check_builtin_meta_item(
41-
features,
4241
&sess.psess,
4342
meta_item,
4443
ast::AttrStyle::Outer,

compiler/rustc_builtin_macros/src/util.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaI
1717
// All the built-in macro attributes are "words" at the moment.
1818
let template = AttributeTemplate { word: true, ..Default::default() };
1919
validate_attr::check_builtin_meta_item(
20-
&ecx.ecfg.features,
2120
&ecx.sess.psess,
2221
meta_item,
2322
AttrStyle::Outer,

compiler/rustc_codegen_llvm/src/context.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,10 @@ impl<'ll> CodegenCx<'ll, '_> {
10001000
ifn!("llvm.is.constant.i64", fn(t_i64) -> i1);
10011001
ifn!("llvm.is.constant.i128", fn(t_i128) -> i1);
10021002
ifn!("llvm.is.constant.isize", fn(t_isize) -> i1);
1003+
ifn!("llvm.is.constant.f16", fn(t_f16) -> i1);
10031004
ifn!("llvm.is.constant.f32", fn(t_f32) -> i1);
10041005
ifn!("llvm.is.constant.f64", fn(t_f64) -> i1);
1006+
ifn!("llvm.is.constant.f128", fn(t_f128) -> i1);
10051007
ifn!("llvm.is.constant.ptr", fn(ptr) -> i1);
10061008

10071009
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);

compiler/rustc_codegen_llvm/src/intrinsic.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,22 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
192192
}
193193
sym::is_val_statically_known => {
194194
let intrinsic_type = args[0].layout.immediate_llvm_type(self.cx);
195-
match self.type_kind(intrinsic_type) {
196-
TypeKind::Pointer | TypeKind::Integer | TypeKind::Float | TypeKind::Double => {
197-
self.call_intrinsic(
198-
&format!("llvm.is.constant.{:?}", intrinsic_type),
199-
&[args[0].immediate()],
200-
)
195+
let kind = self.type_kind(intrinsic_type);
196+
let intrinsic_name = match kind {
197+
TypeKind::Pointer | TypeKind::Integer => {
198+
Some(format!("llvm.is.constant.{intrinsic_type:?}"))
201199
}
202-
_ => self.const_bool(false),
200+
// LLVM float types' intrinsic names differ from their type names.
201+
TypeKind::Half => Some(format!("llvm.is.constant.f16")),
202+
TypeKind::Float => Some(format!("llvm.is.constant.f32")),
203+
TypeKind::Double => Some(format!("llvm.is.constant.f64")),
204+
TypeKind::FP128 => Some(format!("llvm.is.constant.f128")),
205+
_ => None,
206+
};
207+
if let Some(intrinsic_name) = intrinsic_name {
208+
self.call_intrinsic(&intrinsic_name, &[args[0].immediate()])
209+
} else {
210+
self.const_bool(false)
203211
}
204212
}
205213
sym::unlikely => self

compiler/rustc_expand/src/config.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,7 @@ impl<'a> StripUnconfigured<'a> {
265265
/// is in the original source file. Gives a compiler error if the syntax of
266266
/// the attribute is incorrect.
267267
pub(crate) fn expand_cfg_attr(&self, cfg_attr: &Attribute, recursive: bool) -> Vec<Attribute> {
268-
validate_attr::check_attribute_safety(
269-
self.features.unwrap_or(&Features::default()),
270-
&self.sess.psess,
271-
AttributeSafety::Normal,
272-
&cfg_attr,
273-
);
268+
validate_attr::check_attribute_safety(&self.sess.psess, AttributeSafety::Normal, &cfg_attr);
274269

275270
let Some((cfg_predicate, expanded_attrs)) =
276271
rustc_parse::parse_cfg_attr(cfg_attr, &self.sess.psess)
@@ -395,11 +390,7 @@ impl<'a> StripUnconfigured<'a> {
395390
}
396391
};
397392

398-
validate_attr::deny_builtin_meta_unsafety(
399-
self.features.unwrap_or(&Features::default()),
400-
&self.sess.psess,
401-
&meta_item,
402-
);
393+
validate_attr::deny_builtin_meta_unsafety(&self.sess.psess, &meta_item);
403394

404395
(
405396
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {

compiler/rustc_expand/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
18821882
let mut span: Option<Span> = None;
18831883
while let Some(attr) = attrs.next() {
18841884
rustc_ast_passes::feature_gate::check_attribute(attr, self.cx.sess, features);
1885-
validate_attr::check_attr(features, &self.cx.sess.psess, attr);
1885+
validate_attr::check_attr(&self.cx.sess.psess, attr);
18861886

18871887
let current_span = if let Some(sp) = span { sp.to(attr.span) } else { attr.span };
18881888
span = Some(current_span);

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ declare_features! (
392392
(accepted, universal_impl_trait, "1.26.0", Some(34511)),
393393
/// Allows arbitrary delimited token streams in non-macro attributes.
394394
(accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208)),
395+
/// Allows unsafe attributes.
396+
(accepted, unsafe_attributes, "CURRENT_RUSTC_VERSION", Some(123757)),
395397
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
396398
(accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668)),
397399
/// Allows unsafe on extern declarations and safety qualifiers over internal items.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,6 @@ declare_features! (
622622
(unstable, type_changing_struct_update, "1.58.0", Some(86555)),
623623
/// Allows unnamed fields of struct and union type
624624
(incomplete, unnamed_fields, "1.74.0", Some(49804)),
625-
/// Allows unsafe attributes.
626-
(unstable, unsafe_attributes, "1.80.0", Some(123757)),
627625
/// Allows const generic parameters to be defined with types that
628626
/// are not `Sized`, e.g. `fn foo<const N: [u8]>() {`.
629627
(incomplete, unsized_const_params, "CURRENT_RUSTC_VERSION", Some(95174)),

compiler/rustc_lint_defs/src/builtin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4971,7 +4971,6 @@ declare_lint! {
49714971
/// ### Example
49724972
///
49734973
/// ```rust
4974-
/// #![feature(unsafe_attributes)]
49754974
/// #![warn(unsafe_attr_outside_unsafe)]
49764975
///
49774976
/// #[no_mangle]

compiler/rustc_parse/src/parser/attr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::token::{self, Delimiter};
44
use rustc_errors::codes::*;
55
use rustc_errors::{Diag, PResult};
66
use rustc_span::symbol::kw;
7-
use rustc_span::{sym, BytePos, Span};
7+
use rustc_span::{BytePos, Span};
88
use thin_vec::ThinVec;
99
use tracing::debug;
1010

@@ -265,7 +265,6 @@ impl<'a> Parser<'a> {
265265
let is_unsafe = this.eat_keyword(kw::Unsafe);
266266
let unsafety = if is_unsafe {
267267
let unsafe_span = this.prev_token.span;
268-
this.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span);
269268
this.expect(&token::OpenDelim(Delimiter::Parenthesis))?;
270269
ast::Safety::Unsafe(unsafe_span)
271270
} else {
@@ -406,7 +405,6 @@ impl<'a> Parser<'a> {
406405
};
407406
let unsafety = if is_unsafe {
408407
let unsafe_span = self.prev_token.span;
409-
self.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span);
410408
self.expect(&token::OpenDelim(Delimiter::Parenthesis))?;
411409

412410
ast::Safety::Unsafe(unsafe_span)

compiler/rustc_parse/src/validate_attr.rs

+13-27
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use rustc_ast::{
77
NestedMetaItem, Safety,
88
};
99
use rustc_errors::{Applicability, FatalError, PResult};
10-
use rustc_feature::{
11-
AttributeSafety, AttributeTemplate, BuiltinAttribute, Features, BUILTIN_ATTRIBUTE_MAP,
12-
};
10+
use rustc_feature::{AttributeSafety, AttributeTemplate, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
1311
use rustc_session::errors::report_lit_error;
1412
use rustc_session::lint::builtin::{ILL_FORMED_ATTRIBUTE_INPUT, UNSAFE_ATTR_OUTSIDE_UNSAFE};
1513
use rustc_session::lint::BuiltinLintDiag;
@@ -18,7 +16,7 @@ use rustc_span::{sym, BytePos, Span, Symbol};
1816

1917
use crate::{errors, parse_in};
2018

21-
pub fn check_attr(features: &Features, psess: &ParseSess, attr: &Attribute) {
19+
pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
2220
if attr.is_doc_comment() {
2321
return;
2422
}
@@ -28,17 +26,17 @@ pub fn check_attr(features: &Features, psess: &ParseSess, attr: &Attribute) {
2826

2927
// All non-builtin attributes are considered safe
3028
let safety = attr_info.map(|x| x.safety).unwrap_or(AttributeSafety::Normal);
31-
check_attribute_safety(features, psess, safety, attr);
29+
check_attribute_safety(psess, safety, attr);
3230

3331
// Check input tokens for built-in and key-value attributes.
3432
match attr_info {
3533
// `rustc_dummy` doesn't have any restrictions specific to built-in attributes.
3634
Some(BuiltinAttribute { name, template, .. }) if *name != sym::rustc_dummy => {
3735
match parse_meta(psess, attr) {
3836
// Don't check safety again, we just did that
39-
Ok(meta) => check_builtin_meta_item(
40-
features, psess, &meta, attr.style, *name, *template, false,
41-
),
37+
Ok(meta) => {
38+
check_builtin_meta_item(psess, &meta, attr.style, *name, *template, false)
39+
}
4240
Err(err) => {
4341
err.emit();
4442
}
@@ -157,16 +155,7 @@ fn is_attr_template_compatible(template: &AttributeTemplate, meta: &ast::MetaIte
157155
}
158156
}
159157

160-
pub fn check_attribute_safety(
161-
features: &Features,
162-
psess: &ParseSess,
163-
safety: AttributeSafety,
164-
attr: &Attribute,
165-
) {
166-
if !features.unsafe_attributes {
167-
return;
168-
}
169-
158+
pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr: &Attribute) {
170159
let attr_item = attr.get_normal_item();
171160

172161
if safety == AttributeSafety::Unsafe {
@@ -215,21 +204,18 @@ pub fn check_attribute_safety(
215204

216205
// Called by `check_builtin_meta_item` and code that manually denies
217206
// `unsafe(...)` in `cfg`
218-
pub fn deny_builtin_meta_unsafety(features: &Features, psess: &ParseSess, meta: &MetaItem) {
207+
pub fn deny_builtin_meta_unsafety(psess: &ParseSess, meta: &MetaItem) {
219208
// This only supports denying unsafety right now - making builtin attributes
220209
// support unsafety will requite us to thread the actual `Attribute` through
221210
// for the nice diagnostics.
222-
if features.unsafe_attributes {
223-
if let Safety::Unsafe(unsafe_span) = meta.unsafety {
224-
psess
225-
.dcx()
226-
.emit_err(errors::InvalidAttrUnsafe { span: unsafe_span, name: meta.path.clone() });
227-
}
211+
if let Safety::Unsafe(unsafe_span) = meta.unsafety {
212+
psess
213+
.dcx()
214+
.emit_err(errors::InvalidAttrUnsafe { span: unsafe_span, name: meta.path.clone() });
228215
}
229216
}
230217

231218
pub fn check_builtin_meta_item(
232-
features: &Features,
233219
psess: &ParseSess,
234220
meta: &MetaItem,
235221
style: ast::AttrStyle,
@@ -246,7 +232,7 @@ pub fn check_builtin_meta_item(
246232
}
247233

248234
if deny_unsafety {
249-
deny_builtin_meta_unsafety(features, psess, meta);
235+
deny_builtin_meta_unsafety(psess, meta);
250236
}
251237
}
252238

src/tools/rustfmt/tests/target/unsafe_attributes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(unsafe_attributes)]
21
// https://github.com/rust-lang/rust/issues/123757
32
//
43
#![simple_ident]

tests/codegen/is_val_statically_known.rs

+79-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ compile-flags: --crate-type=lib -Zmerge-functions=disabled -O
22

33
#![feature(core_intrinsics)]
4+
#![feature(f16, f128)]
45

56
use std::intrinsics::is_val_statically_known;
67

@@ -49,7 +50,7 @@ pub fn _bool_false(b: bool) -> i32 {
4950

5051
#[inline]
5152
pub fn _iref(a: &u8) -> i32 {
52-
if unsafe { is_val_statically_known(a) } { 5 } else { 4 }
53+
if is_val_statically_known(a) { 5 } else { 4 }
5354
}
5455

5556
// CHECK-LABEL: @_iref_borrow(
@@ -68,7 +69,7 @@ pub fn _iref_arg(a: &u8) -> i32 {
6869

6970
#[inline]
7071
pub fn _slice_ref(a: &[u8]) -> i32 {
71-
if unsafe { is_val_statically_known(a) } { 7 } else { 6 }
72+
if is_val_statically_known(a) { 7 } else { 6 }
7273
}
7374

7475
// CHECK-LABEL: @_slice_ref_borrow(
@@ -84,3 +85,79 @@ pub fn _slice_ref_arg(a: &[u8]) -> i32 {
8485
// CHECK: ret i32 6
8586
_slice_ref(a)
8687
}
88+
89+
#[inline]
90+
pub fn _f16(a: f16) -> i32 {
91+
if is_val_statically_known(a) { 1 } else { 0 }
92+
}
93+
94+
// CHECK-LABEL: @_f16_true(
95+
#[no_mangle]
96+
pub fn _f16_true() -> i32 {
97+
// CHECK: ret i32 1
98+
_f16(1.0)
99+
}
100+
101+
// CHECK-LABEL: @_f16_false(
102+
#[no_mangle]
103+
pub fn _f16_false(a: f16) -> i32 {
104+
// CHECK: ret i32 0
105+
_f16(a)
106+
}
107+
108+
#[inline]
109+
pub fn _f32(a: f32) -> i32 {
110+
if is_val_statically_known(a) { 1 } else { 0 }
111+
}
112+
113+
// CHECK-LABEL: @_f32_true(
114+
#[no_mangle]
115+
pub fn _f32_true() -> i32 {
116+
// CHECK: ret i32 1
117+
_f32(1.0)
118+
}
119+
120+
// CHECK-LABEL: @_f32_false(
121+
#[no_mangle]
122+
pub fn _f32_false(a: f32) -> i32 {
123+
// CHECK: ret i32 0
124+
_f32(a)
125+
}
126+
127+
#[inline]
128+
pub fn _f64(a: f64) -> i32 {
129+
if is_val_statically_known(a) { 1 } else { 0 }
130+
}
131+
132+
// CHECK-LABEL: @_f64_true(
133+
#[no_mangle]
134+
pub fn _f64_true() -> i32 {
135+
// CHECK: ret i32 1
136+
_f64(1.0)
137+
}
138+
139+
// CHECK-LABEL: @_f64_false(
140+
#[no_mangle]
141+
pub fn _f64_false(a: f64) -> i32 {
142+
// CHECK: ret i32 0
143+
_f64(a)
144+
}
145+
146+
#[inline]
147+
pub fn _f128(a: f128) -> i32 {
148+
if is_val_statically_known(a) { 1 } else { 0 }
149+
}
150+
151+
// CHECK-LABEL: @_f128_true(
152+
#[no_mangle]
153+
pub fn _f128_true() -> i32 {
154+
// CHECK: ret i32 1
155+
_f128(1.0)
156+
}
157+
158+
// CHECK-LABEL: @_f128_false(
159+
#[no_mangle]
160+
pub fn _f128_false(a: f128) -> i32 {
161+
// CHECK: ret i32 0
162+
_f128(a)
163+
}

tests/debuginfo/drop-locations.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ ignore-windows
21
//@ ignore-android
32
//@ min-lldb-version: 310
43
//@ ignore-test: #128971

tests/debuginfo/embedded-visualizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ compile-flags:-g
22
//@ min-gdb-version: 8.1
33
//@ ignore-lldb
4-
//@ ignore-windows-gnu // emit_debug_gdb_scripts is disabled on Windows
4+
//@ ignore-windows-gnu: #128981
55

66
// === CDB TESTS ==================================================================================
77

tests/debuginfo/empty-string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ ignore-windows failing on win32 bot
1+
//@ ignore-windows-gnu: #128981
22
//@ ignore-android: FIXME(#10381)
33
//@ compile-flags:-g
44
//@ min-gdb-version: 8.1

0 commit comments

Comments
 (0)