Skip to content

Commit 9fa580b

Browse files
committed
Auto merge of rust-lang#82577 - Dylan-DPC:rollup-c3si8ju, r=Dylan-DPC
Rollup of 14 pull requests Successful merges: - rust-lang#81794 (update tracking issue for `relaxed_struct_unsize`) - rust-lang#82057 (Replace const_cstr with cstr crate) - rust-lang#82370 (Improve anonymous lifetime note to indicate the target span) - rust-lang#82394 (:arrow_up: rust-analyzer) - rust-lang#82396 (Add Future trait for doc_spotlight feature doc) - rust-lang#82404 (Test hexagon-enum only when llvm target is present) - rust-lang#82419 (expand: Preserve order of inert attributes during expansion) - rust-lang#82420 (Enable API documentation for `std::os::wasi`.) - rust-lang#82421 (Add a `size()` function to WASI's `MetadataExt`.) - rust-lang#82442 (Skip emitting closure diagnostic when closure_kind_origins has no entry) - rust-lang#82473 (Use libc::accept4 on Android instead of raw syscall.) - rust-lang#82482 (Use small hash set in `mir_inliner_callees`) - rust-lang#82490 (Update cargo) - rust-lang#82494 (Substitute erased lifetimes on bad placeholder type) Failed merges: - rust-lang#82448 (Combine HasAttrs and HasTokens into AstLike) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3da2dd3 + 95b31cf commit 9fa580b

File tree

61 files changed

+549
-355
lines changed

Some content is hidden

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

61 files changed

+549
-355
lines changed

Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,16 @@ dependencies = [
904904
"winapi 0.3.9",
905905
]
906906

907+
[[package]]
908+
name = "cstr"
909+
version = "0.2.8"
910+
source = "registry+https://github.com/rust-lang/crates.io-index"
911+
checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b"
912+
dependencies = [
913+
"proc-macro2",
914+
"quote",
915+
]
916+
907917
[[package]]
908918
name = "ctor"
909919
version = "0.1.15"
@@ -3698,6 +3708,7 @@ name = "rustc_codegen_llvm"
36983708
version = "0.0.0"
36993709
dependencies = [
37003710
"bitflags",
3711+
"cstr",
37013712
"libc",
37023713
"measureme",
37033714
"rustc-demangle",

compiler/rustc_codegen_llvm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ doctest = false
1010

1111
[dependencies]
1212
bitflags = "1.0"
13+
cstr = "0.2"
1314
libc = "0.2"
1415
measureme = "9.0.0"
1516
snap = "1"

compiler/rustc_codegen_llvm/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
554554
llvm::AddCallSiteAttrString(
555555
callsite,
556556
llvm::AttributePlace::Function,
557-
rustc_data_structures::const_cstr!("cmse_nonsecure_call"),
557+
cstr::cstr!("cmse_nonsecure_call"),
558558
);
559559
}
560560
}

compiler/rustc_codegen_llvm/src/attributes.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use std::ffi::CString;
44

5+
use cstr::cstr;
56
use rustc_codegen_ssa::traits::*;
6-
use rustc_data_structures::const_cstr;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_data_structures::small_c_str::SmallCStr;
99
use rustc_hir::def_id::DefId;
@@ -75,8 +75,8 @@ pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value)
7575
llvm::AddFunctionAttrStringValue(
7676
llfn,
7777
llvm::AttributePlace::Function,
78-
const_cstr!("frame-pointer"),
79-
const_cstr!("all"),
78+
cstr!("frame-pointer"),
79+
cstr!("all"),
8080
);
8181
}
8282
}
@@ -95,7 +95,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
9595
llvm::AddFunctionAttrStringValue(
9696
llfn,
9797
llvm::AttributePlace::Function,
98-
const_cstr!("instrument-function-entry-inlined"),
98+
cstr!("instrument-function-entry-inlined"),
9999
&mcount_name,
100100
);
101101
}
@@ -129,24 +129,24 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
129129
StackProbeType::None => None,
130130
// Request LLVM to generate the probes inline. If the given LLVM version does not support
131131
// this, no probe is generated at all (even if the attribute is specified).
132-
StackProbeType::Inline => Some(const_cstr!("inline-asm")),
132+
StackProbeType::Inline => Some(cstr!("inline-asm")),
133133
// Flag our internal `__rust_probestack` function as the stack probe symbol.
134134
// This is defined in the `compiler-builtins` crate for each architecture.
135-
StackProbeType::Call => Some(const_cstr!("__rust_probestack")),
135+
StackProbeType::Call => Some(cstr!("__rust_probestack")),
136136
// Pick from the two above based on the LLVM version.
137137
StackProbeType::InlineOrCall { min_llvm_version_for_inline } => {
138138
if llvm_util::get_version() < min_llvm_version_for_inline {
139-
Some(const_cstr!("__rust_probestack"))
139+
Some(cstr!("__rust_probestack"))
140140
} else {
141-
Some(const_cstr!("inline-asm"))
141+
Some(cstr!("inline-asm"))
142142
}
143143
}
144144
};
145145
if let Some(attr_value) = attr_value {
146146
llvm::AddFunctionAttrStringValue(
147147
llfn,
148148
llvm::AttributePlace::Function,
149-
const_cstr!("probe-stack"),
149+
cstr!("probe-stack"),
150150
attr_value,
151151
);
152152
}
@@ -169,7 +169,7 @@ pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
169169
llvm::AddFunctionAttrStringValue(
170170
llfn,
171171
llvm::AttributePlace::Function,
172-
const_cstr!("target-cpu"),
172+
cstr!("target-cpu"),
173173
target_cpu.as_c_str(),
174174
);
175175
}
@@ -180,7 +180,7 @@ pub fn apply_tune_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
180180
llvm::AddFunctionAttrStringValue(
181181
llfn,
182182
llvm::AttributePlace::Function,
183-
const_cstr!("tune-cpu"),
183+
cstr!("tune-cpu"),
184184
tune_cpu.as_c_str(),
185185
);
186186
}
@@ -289,7 +289,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
289289
Attribute::NoAlias.apply_llfn(llvm::AttributePlace::ReturnValue, llfn);
290290
}
291291
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
292-
llvm::AddFunctionAttrString(llfn, Function, const_cstr!("cmse_nonsecure_entry"));
292+
llvm::AddFunctionAttrString(llfn, Function, cstr!("cmse_nonsecure_entry"));
293293
}
294294
sanitize(cx, codegen_fn_attrs.no_sanitize, llfn);
295295

@@ -319,7 +319,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
319319
llvm::AddFunctionAttrStringValue(
320320
llfn,
321321
llvm::AttributePlace::Function,
322-
const_cstr!("target-features"),
322+
cstr!("target-features"),
323323
&val,
324324
);
325325
}
@@ -332,7 +332,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
332332
llvm::AddFunctionAttrStringValue(
333333
llfn,
334334
llvm::AttributePlace::Function,
335-
const_cstr!("wasm-import-module"),
335+
cstr!("wasm-import-module"),
336336
&module,
337337
);
338338

@@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
342342
llvm::AddFunctionAttrStringValue(
343343
llfn,
344344
llvm::AttributePlace::Function,
345-
const_cstr!("wasm-import-name"),
345+
cstr!("wasm-import-name"),
346346
&name,
347347
);
348348
}

compiler/rustc_codegen_llvm/src/builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use crate::llvm::{AtomicOrdering, AtomicRmwBinOp, SynchronizationScope};
55
use crate::type_::Type;
66
use crate::type_of::LayoutLlvmExt;
77
use crate::value::Value;
8+
use cstr::cstr;
89
use libc::{c_char, c_uint};
910
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, TypeKind};
1011
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
1112
use rustc_codegen_ssa::mir::place::PlaceRef;
1213
use rustc_codegen_ssa::traits::*;
1314
use rustc_codegen_ssa::MemFlags;
14-
use rustc_data_structures::const_cstr;
1515
use rustc_data_structures::small_c_str::SmallCStr;
1616
use rustc_hir::def_id::DefId;
1717
use rustc_middle::ty::layout::TyAndLayout;
@@ -979,7 +979,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
979979
}
980980

981981
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
982-
let name = const_cstr!("cleanuppad");
982+
let name = cstr!("cleanuppad");
983983
let ret = unsafe {
984984
llvm::LLVMRustBuildCleanupPad(
985985
self.llbuilder,
@@ -1003,7 +1003,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10031003
}
10041004

10051005
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
1006-
let name = const_cstr!("catchpad");
1006+
let name = cstr!("catchpad");
10071007
let ret = unsafe {
10081008
llvm::LLVMRustBuildCatchPad(
10091009
self.llbuilder,
@@ -1022,7 +1022,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10221022
unwind: Option<&'ll BasicBlock>,
10231023
num_handlers: usize,
10241024
) -> &'ll Value {
1025-
let name = const_cstr!("catchswitch");
1025+
let name = cstr!("catchswitch");
10261026
let ret = unsafe {
10271027
llvm::LLVMRustBuildCatchSwitch(
10281028
self.llbuilder,

compiler/rustc_codegen_llvm/src/consts.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use crate::llvm::{self, True};
55
use crate::type_::Type;
66
use crate::type_of::LayoutLlvmExt;
77
use crate::value::Value;
8+
use cstr::cstr;
89
use libc::c_uint;
910
use rustc_codegen_ssa::traits::*;
10-
use rustc_data_structures::const_cstr;
1111
use rustc_hir::def_id::DefId;
1212
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1313
use rustc_middle::mir::interpret::{
@@ -419,9 +419,9 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
419419
.all(|&byte| byte == 0);
420420

421421
let sect_name = if all_bytes_are_zero {
422-
const_cstr!("__DATA,__thread_bss")
422+
cstr!("__DATA,__thread_bss")
423423
} else {
424-
const_cstr!("__DATA,__thread_data")
424+
cstr!("__DATA,__thread_data")
425425
};
426426
llvm::LLVMSetSection(g, sect_name.as_ptr());
427427
}

compiler/rustc_codegen_llvm/src/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use crate::llvm_util;
77
use crate::type_::Type;
88
use crate::value::Value;
99

10+
use cstr::cstr;
1011
use rustc_codegen_ssa::base::wants_msvc_seh;
1112
use rustc_codegen_ssa::traits::*;
1213
use rustc_data_structures::base_n;
13-
use rustc_data_structures::const_cstr;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_data_structures::small_c_str::SmallCStr;
1616
use rustc_middle::bug;
@@ -414,8 +414,8 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
414414
}
415415

416416
fn create_used_variable(&self) {
417-
let name = const_cstr!("llvm.used");
418-
let section = const_cstr!("llvm.metadata");
417+
let name = cstr!("llvm.used");
418+
let section = cstr!("llvm.metadata");
419419
let array =
420420
self.const_array(&self.type_ptr_to(self.type_i8()), &*self.used_statics.borrow());
421421

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::llvm::debuginfo::{
1818
};
1919
use crate::value::Value;
2020

21+
use cstr::cstr;
2122
use rustc_codegen_ssa::traits::*;
22-
use rustc_data_structures::const_cstr;
2323
use rustc_data_structures::fingerprint::Fingerprint;
2424
use rustc_data_structures::fx::FxHashMap;
2525
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -1075,7 +1075,7 @@ pub fn compile_unit_metadata(
10751075
gcov_cu_info.len() as c_uint,
10761076
);
10771077

1078-
let llvm_gcov_ident = const_cstr!("llvm.gcov");
1078+
let llvm_gcov_ident = cstr!("llvm.gcov");
10791079
llvm::LLVMAddNamedMetadataOperand(
10801080
debug_context.llmod,
10811081
llvm_gcov_ident.as_ptr(),
@@ -1093,7 +1093,7 @@ pub fn compile_unit_metadata(
10931093
);
10941094
llvm::LLVMAddNamedMetadataOperand(
10951095
debug_context.llmod,
1096-
const_cstr!("llvm.ident").as_ptr(),
1096+
cstr!("llvm.ident").as_ptr(),
10971097
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
10981098
);
10991099
}

compiler/rustc_data_structures/src/const_cstr.rs

-30
This file was deleted.

compiler/rustc_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub mod base_n;
6969
pub mod binary_search_util;
7070
pub mod box_region;
7171
pub mod captures;
72-
pub mod const_cstr;
7372
pub mod flock;
7473
pub mod functor;
7574
pub mod fx;

compiler/rustc_expand/src/expand.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ pub enum InvocationKind {
301301
},
302302
Attr {
303303
attr: ast::Attribute,
304+
// Re-insertion position for inert attributes.
305+
pos: usize,
304306
item: Annotatable,
305307
// Required for resolving derive helper attributes.
306308
derives: Vec<Path>,
@@ -690,7 +692,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
690692
}
691693
_ => unreachable!(),
692694
},
693-
InvocationKind::Attr { attr, mut item, derives } => match ext {
695+
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
694696
SyntaxExtensionKind::Attr(expander) => {
695697
self.gate_proc_macro_input(&item);
696698
self.gate_proc_macro_attr_item(span, &item);
@@ -721,7 +723,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
721723
ExpandResult::Retry(item) => {
722724
// Reassemble the original invocation for retrying.
723725
return ExpandResult::Retry(Invocation {
724-
kind: InvocationKind::Attr { attr, item, derives },
726+
kind: InvocationKind::Attr { attr, pos, item, derives },
725727
..invoc
726728
});
727729
}
@@ -739,7 +741,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
739741
if *mark_used {
740742
self.cx.sess.mark_attr_used(&attr);
741743
}
742-
item.visit_attrs(|attrs| attrs.push(attr));
744+
item.visit_attrs(|attrs| attrs.insert(pos, attr));
743745
fragment_kind.expect_from_annotatables(iter::once(item))
744746
}
745747
_ => unreachable!(),
@@ -1000,17 +1002,20 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10001002

10011003
fn collect_attr(
10021004
&mut self,
1003-
(attr, derives): (ast::Attribute, Vec<Path>),
1005+
(attr, pos, derives): (ast::Attribute, usize, Vec<Path>),
10041006
item: Annotatable,
10051007
kind: AstFragmentKind,
10061008
) -> AstFragment {
1007-
self.collect(kind, InvocationKind::Attr { attr, item, derives })
1009+
self.collect(kind, InvocationKind::Attr { attr, pos, item, derives })
10081010
}
10091011

10101012
/// If `item` is an attribute invocation, remove the attribute and return it together with
1011-
/// derives following it. We have to collect the derives in order to resolve legacy derive
1012-
/// helpers (helpers written before derives that introduce them).
1013-
fn take_first_attr(&mut self, item: &mut impl HasAttrs) -> Option<(ast::Attribute, Vec<Path>)> {
1013+
/// its position and derives following it. We have to collect the derives in order to resolve
1014+
/// legacy derive helpers (helpers written before derives that introduce them).
1015+
fn take_first_attr(
1016+
&mut self,
1017+
item: &mut impl HasAttrs,
1018+
) -> Option<(ast::Attribute, usize, Vec<Path>)> {
10141019
let mut attr = None;
10151020

10161021
item.visit_attrs(|attrs| {
@@ -1033,7 +1038,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10331038
})
10341039
.collect();
10351040

1036-
(attr, following_derives)
1041+
(attr, attr_pos, following_derives)
10371042
})
10381043
});
10391044

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ declare_features! (
633633
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
634634

635635
/// Lessens the requirements for structs to implement `Unsize`.
636-
(active, relaxed_struct_unsize, "1.51.0", Some(1), None),
636+
(active, relaxed_struct_unsize, "1.51.0", Some(81793), None),
637637

638638
/// Allows macro attributes to observe output of `#[derive]`.
639639
(active, macro_attributes_in_derive_output, "1.51.0", Some(81119), None),

0 commit comments

Comments
 (0)