Skip to content

Commit cb52859

Browse files
committed
Auto merge of #142283 - workingjubilee:rollup-uxb08ai, r=workingjubilee
Rollup of 12 pull requests Successful merges: - #134442 (Specify the behavior of `file!`) - #134841 (Look at proc-macro attributes when encountering unknown attribute) - #140372 (Exhaustively handle parsed attributes in CheckAttr) - #140766 (Stabilize keylocker) - #141061 (Change __rust_no_alloc_shim_is_unstable to be a function) - #142042 (Make E0621 missing lifetime suggestion verbose) - #142101 (core::ptr: deduplicate more method docs) - #142258 (platform-support.md: Mention specific Linux kernel version or later) - #142260 (Miri subtree update) - #142262 (Mark `core::slice::memchr` as `#[doc(hidden)]`) - #142272 (tests: Change ABIs in tests to more future-resilient ones) - #142275 (rustdoc: Refractor `clean_ty_generics`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 40daf23 + 118d05c commit cb52859

File tree

103 files changed

+1210
-707
lines changed

Some content is hidden

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

103 files changed

+1210
-707
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,6 @@ dependencies = [
23262326
"tempfile",
23272327
"tikv-jemalloc-sys",
23282328
"ui_test",
2329-
"windows-sys 0.59.0",
23302329
]
23312330

23322331
[[package]]

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'st
2222
}
2323
}
2424

25-
pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable";
25+
pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable_v2";
2626

2727
pub enum AllocatorTy {
2828
Layout,

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ impl OptimizeAttr {
5757
}
5858
}
5959

60-
#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic, PrintAttribute)]
61-
pub enum DiagnosticAttribute {
62-
// tidy-alphabetical-start
63-
DoNotRecommend,
64-
OnUnimplemented,
65-
// tidy-alphabetical-end
66-
}
67-
6860
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)]
6961
pub enum ReprAttr {
7062
ReprInt(IntType),
@@ -160,40 +152,52 @@ impl Deprecation {
160152
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
161153
pub enum AttributeKind {
162154
// tidy-alphabetical-start
155+
/// Represents `#[rustc_allow_const_fn_unstable]`.
163156
AllowConstFnUnstable(ThinVec<Symbol>),
157+
158+
/// Represents `#[allow_internal_unstable]`.
164159
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
160+
161+
/// Represents `#[rustc_default_body_unstable]`.
165162
BodyStability {
166163
stability: DefaultBodyStability,
167164
/// Span of the `#[rustc_default_body_unstable(...)]` attribute
168165
span: Span,
169166
},
167+
168+
/// Represents `#[rustc_confusables]`.
170169
Confusables {
171170
symbols: ThinVec<Symbol>,
172171
// FIXME(jdonszelmann): remove when target validation code is moved
173172
first_span: Span,
174173
},
174+
175+
/// Represents `#[rustc_const_stable]` and `#[rustc_const_unstable]`.
175176
ConstStability {
176177
stability: PartialConstStability,
177178
/// Span of the `#[rustc_const_stable(...)]` or `#[rustc_const_unstable(...)]` attribute
178179
span: Span,
179180
},
181+
182+
/// Represents `#[rustc_const_stable_indirect]`.
180183
ConstStabilityIndirect,
181-
Deprecation {
182-
deprecation: Deprecation,
183-
span: Span,
184-
},
185-
Diagnostic(DiagnosticAttribute),
186-
DocComment {
187-
style: AttrStyle,
188-
kind: CommentKind,
189-
span: Span,
190-
comment: Symbol,
191-
},
184+
185+
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
186+
Deprecation { deprecation: Deprecation, span: Span },
187+
188+
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
189+
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
190+
191+
/// Represents `#[rustc_macro_transparency]`.
192192
MacroTransparency(Transparency),
193+
194+
/// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
193195
Repr(ThinVec<(ReprAttr, Span)>),
196+
197+
/// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
194198
Stability {
195199
stability: Stability,
196-
/// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute
200+
/// Span of the attribute.
197201
span: Span,
198202
},
199203
// tidy-alphabetical-end

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Allocator shim
22
// Adapted from rustc
33

4+
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
45
use rustc_ast::expand::allocator::{
56
ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
67
alloc_error_handler_name, default_fn_name, global_fn_name,
@@ -97,16 +98,31 @@ fn codegen_inner(
9798
data.define(Box::new([val]));
9899
module.define_data(data_id, &data).unwrap();
99100

100-
let data_id = module
101-
.declare_data(
102-
&mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
103-
Linkage::Export,
104-
false,
105-
false,
106-
)
107-
.unwrap();
108-
let mut data = DataDescription::new();
109-
data.set_align(1);
110-
data.define(Box::new([0]));
111-
module.define_data(data_id, &data).unwrap();
101+
{
102+
let sig = Signature {
103+
call_conv: module.target_config().default_call_conv,
104+
params: vec![],
105+
returns: vec![],
106+
};
107+
let func_id = module
108+
.declare_function(
109+
&mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
110+
Linkage::Export,
111+
&sig,
112+
)
113+
.unwrap();
114+
115+
let mut ctx = Context::new();
116+
ctx.func.signature = sig;
117+
let mut func_ctx = FunctionBuilderContext::new();
118+
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
119+
120+
let block = bcx.create_block();
121+
bcx.switch_to_block(block);
122+
bcx.ins().return_(&[]);
123+
bcx.seal_all_blocks();
124+
bcx.finalize();
125+
126+
module.define_function(func_id, &mut ctx).unwrap();
127+
}
112128
}

compiler/rustc_codegen_gcc/src/allocator.rs

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen(
5757
let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name));
5858
let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name));
5959

60-
create_wrapper_function(tcx, context, &from_name, &to_name, &types, output);
60+
create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output);
6161
}
6262
}
6363

@@ -66,7 +66,7 @@ pub(crate) unsafe fn codegen(
6666
tcx,
6767
context,
6868
&mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
69-
&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)),
69+
Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))),
7070
&[usize, usize],
7171
None,
7272
);
@@ -81,21 +81,21 @@ pub(crate) unsafe fn codegen(
8181
let value = context.new_rvalue_from_int(i8, value as i32);
8282
global.global_set_initializer_rvalue(value);
8383

84-
let name = mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE);
85-
let global = context.new_global(None, GlobalKind::Exported, i8, name);
86-
#[cfg(feature = "master")]
87-
global.add_attribute(VarAttribute::Visibility(symbol_visibility_to_gcc(
88-
tcx.sess.default_visibility(),
89-
)));
90-
let value = context.new_rvalue_from_int(i8, 0);
91-
global.global_set_initializer_rvalue(value);
84+
create_wrapper_function(
85+
tcx,
86+
context,
87+
&mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
88+
None,
89+
&[],
90+
None,
91+
);
9292
}
9393

9494
fn create_wrapper_function(
9595
tcx: TyCtxt<'_>,
9696
context: &Context<'_>,
9797
from_name: &str,
98-
to_name: &str,
98+
to_name: Option<&str>,
9999
types: &[Type<'_>],
100100
output: Option<Type<'_>>,
101101
) {
@@ -124,34 +124,40 @@ fn create_wrapper_function(
124124
// TODO(antoyo): emit unwind tables.
125125
}
126126

127-
let args: Vec<_> = types
128-
.iter()
129-
.enumerate()
130-
.map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index)))
131-
.collect();
132-
let callee = context.new_function(
133-
None,
134-
FunctionType::Extern,
135-
output.unwrap_or(void),
136-
&args,
137-
to_name,
138-
false,
139-
);
140-
#[cfg(feature = "master")]
141-
callee.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
142-
143127
let block = func.new_block("entry");
144128

145-
let args = args
146-
.iter()
147-
.enumerate()
148-
.map(|(i, _)| func.get_param(i as i32).to_rvalue())
149-
.collect::<Vec<_>>();
150-
let ret = context.new_call(None, callee, &args);
151-
//llvm::LLVMSetTailCall(ret, True);
152-
if output.is_some() {
153-
block.end_with_return(None, ret);
129+
if let Some(to_name) = to_name {
130+
let args: Vec<_> = types
131+
.iter()
132+
.enumerate()
133+
.map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index)))
134+
.collect();
135+
let callee = context.new_function(
136+
None,
137+
FunctionType::Extern,
138+
output.unwrap_or(void),
139+
&args,
140+
to_name,
141+
false,
142+
);
143+
#[cfg(feature = "master")]
144+
callee.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
145+
146+
let args = args
147+
.iter()
148+
.enumerate()
149+
.map(|(i, _)| func.get_param(i as i32).to_rvalue())
150+
.collect::<Vec<_>>();
151+
let ret = context.new_call(None, callee, &args);
152+
//llvm::LLVMSetTailCall(ret, True);
153+
if output.is_some() {
154+
block.end_with_return(None, ret);
155+
} else {
156+
block.add_eval(None, ret);
157+
block.end_with_void_return(None);
158+
}
154159
} else {
160+
assert!(output.is_none());
155161
block.end_with_void_return(None);
156162
}
157163

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen(
5757
let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name));
5858
let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name));
5959

60-
create_wrapper_function(tcx, &cx, &from_name, &to_name, &args, output, false);
60+
create_wrapper_function(tcx, &cx, &from_name, Some(&to_name), &args, output, false);
6161
}
6262
}
6363

@@ -66,7 +66,7 @@ pub(crate) unsafe fn codegen(
6666
tcx,
6767
&cx,
6868
&mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
69-
&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)),
69+
Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))),
7070
&[usize, usize], // size, align
7171
None,
7272
true,
@@ -81,11 +81,16 @@ pub(crate) unsafe fn codegen(
8181
let llval = llvm::LLVMConstInt(i8, val as u64, False);
8282
llvm::set_initializer(ll_g, llval);
8383

84-
let name = mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE);
85-
let ll_g = cx.declare_global(&name, i8);
86-
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
87-
let llval = llvm::LLVMConstInt(i8, 0, False);
88-
llvm::set_initializer(ll_g, llval);
84+
// __rust_no_alloc_shim_is_unstable_v2
85+
create_wrapper_function(
86+
tcx,
87+
&cx,
88+
&mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
89+
None,
90+
&[],
91+
None,
92+
false,
93+
);
8994
}
9095

9196
if tcx.sess.opts.debuginfo != DebugInfo::None {
@@ -99,7 +104,7 @@ fn create_wrapper_function(
99104
tcx: TyCtxt<'_>,
100105
cx: &SimpleCx<'_>,
101106
from_name: &str,
102-
to_name: &str,
107+
to_name: Option<&str>,
103108
args: &[&Type],
104109
output: Option<&Type>,
105110
no_return: bool,
@@ -128,33 +133,38 @@ fn create_wrapper_function(
128133
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[uwtable]);
129134
}
130135

131-
let callee = declare_simple_fn(
132-
&cx,
133-
to_name,
134-
llvm::CallConv::CCallConv,
135-
llvm::UnnamedAddr::Global,
136-
llvm::Visibility::Hidden,
137-
ty,
138-
);
139-
if let Some(no_return) = no_return {
140-
// -> ! DIFlagNoReturn
141-
attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]);
142-
}
143-
llvm::set_visibility(callee, llvm::Visibility::Hidden);
144-
145136
let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) };
146-
147137
let mut bx = SBuilder::build(&cx, llbb);
148-
let args = args
149-
.iter()
150-
.enumerate()
151-
.map(|(i, _)| llvm::get_param(llfn, i as c_uint))
152-
.collect::<Vec<_>>();
153-
let ret = bx.call(ty, callee, &args, None);
154-
llvm::LLVMSetTailCall(ret, True);
155-
if output.is_some() {
156-
bx.ret(ret);
138+
139+
if let Some(to_name) = to_name {
140+
let callee = declare_simple_fn(
141+
&cx,
142+
to_name,
143+
llvm::CallConv::CCallConv,
144+
llvm::UnnamedAddr::Global,
145+
llvm::Visibility::Hidden,
146+
ty,
147+
);
148+
if let Some(no_return) = no_return {
149+
// -> ! DIFlagNoReturn
150+
attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]);
151+
}
152+
llvm::set_visibility(callee, llvm::Visibility::Hidden);
153+
154+
let args = args
155+
.iter()
156+
.enumerate()
157+
.map(|(i, _)| llvm::get_param(llfn, i as c_uint))
158+
.collect::<Vec<_>>();
159+
let ret = bx.call(ty, callee, &args, None);
160+
llvm::LLVMSetTailCall(ret, True);
161+
if output.is_some() {
162+
bx.ret(ret);
163+
} else {
164+
bx.ret_void()
165+
}
157166
} else {
167+
assert!(output.is_none());
158168
bx.ret_void()
159169
}
160170
}

0 commit comments

Comments
 (0)