Skip to content

Commit c8030ce

Browse files
committed
Auto merge of #149830 - Zalathar:rollup-gqpfqgv, r=Zalathar
Rollup of 12 pull requests Successful merges: - #147602 (Deduplicate higher-ranked lifetime capture errors in impl Trait) - #147725 (Remove -Zoom=panic) - #148294 (callconv: fix mips64 aggregate argument passing for C FFI) - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type) - #149417 (tidy: Detect outdated workspaces in workspace list) - #149458 (Run clippy on cg_gcc in CI) - #149679 (Restrict spe_acc to PowerPC SPE targets) - #149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro) - #149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std) - #149816 (Make typo in field and name suggestions verbose) - #149824 (Add a regression test for issue 145748) - #149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2e667b0 + 4490292 commit c8030ce

File tree

168 files changed

+3586
-1298
lines changed

Some content is hidden

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

168 files changed

+3586
-1298
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16701670
let output = match coro {
16711671
Some(coro) => {
16721672
let fn_def_id = self.local_def_id(fn_node_id);
1673-
self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind, fn_span)
1673+
self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind)
16741674
}
16751675
None => match &decl.output {
16761676
FnRetTy::Ty(ty) => {
@@ -1755,9 +1755,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17551755
fn_def_id: LocalDefId,
17561756
coro: CoroutineKind,
17571757
fn_kind: FnDeclKind,
1758-
fn_span: Span,
17591758
) -> hir::FnRetTy<'hir> {
1760-
let span = self.lower_span(fn_span);
1759+
let span = self.lower_span(output.span());
17611760

17621761
let (opaque_ty_node_id, allowed_features) = match coro {
17631762
CoroutineKind::Async { return_impl_trait_id, .. } => (return_impl_trait_id, None),

compiler/rustc_attr_parsing/src/safety.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,28 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
6262
Some(unsafe_since) => path_span.edition() >= unsafe_since,
6363
};
6464

65+
let mut not_from_proc_macro = true;
66+
if diag_span.from_expansion()
67+
&& let Ok(mut snippet) = self.sess.source_map().span_to_snippet(diag_span)
68+
{
69+
snippet.retain(|c| !c.is_whitespace());
70+
if snippet.contains("!(") || snippet.starts_with("#[") && snippet.ends_with("]")
71+
{
72+
not_from_proc_macro = false;
73+
}
74+
}
75+
6576
if emit_error {
6677
self.stage.emit_err(
6778
self.sess,
6879
crate::session_diagnostics::UnsafeAttrOutsideUnsafe {
6980
span: path_span,
70-
suggestion:
81+
suggestion: not_from_proc_macro.then(|| {
7182
crate::session_diagnostics::UnsafeAttrOutsideUnsafeSuggestion {
7283
left: diag_span.shrink_to_lo(),
7384
right: diag_span.shrink_to_hi(),
74-
},
85+
}
86+
}),
7587
},
7688
);
7789
} else {
@@ -81,7 +93,8 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
8193
span: path_span,
8294
kind: AttributeLintKind::UnsafeAttrOutsideUnsafe {
8395
attribute_name_span: path_span,
84-
sugg_spans: (diag_span.shrink_to_lo(), diag_span.shrink_to_hi()),
96+
sugg_spans: not_from_proc_macro
97+
.then(|| (diag_span.shrink_to_lo(), diag_span.shrink_to_hi())),
8598
},
8699
})
87100
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ pub(crate) struct UnsafeAttrOutsideUnsafe {
758758
#[label]
759759
pub span: Span,
760760
#[subdiagnostic]
761-
pub suggestion: UnsafeAttrOutsideUnsafeSuggestion,
761+
pub suggestion: Option<UnsafeAttrOutsideUnsafeSuggestion>,
762762
}
763763

764764
#[derive(Subdiagnostic)]

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_ast::expand::allocator::{
66
AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name,
77
};
88
use rustc_codegen_ssa::base::{allocator_kind_for_codegen, allocator_shim_contents};
9-
use rustc_session::config::OomStrategy;
109
use rustc_symbol_mangling::mangle_internal_symbol;
1110

1211
use crate::prelude::*;
@@ -15,16 +14,11 @@ use crate::prelude::*;
1514
pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module) -> bool {
1615
let Some(kind) = allocator_kind_for_codegen(tcx) else { return false };
1716
let methods = allocator_shim_contents(tcx, kind);
18-
codegen_inner(tcx, module, &methods, tcx.sess.opts.unstable_opts.oom);
17+
codegen_inner(tcx, module, &methods);
1918
true
2019
}
2120

22-
fn codegen_inner(
23-
tcx: TyCtxt<'_>,
24-
module: &mut dyn Module,
25-
methods: &[AllocatorMethod],
26-
oom_strategy: OomStrategy,
27-
) {
21+
fn codegen_inner(tcx: TyCtxt<'_>, module: &mut dyn Module, methods: &[AllocatorMethod]) {
2822
let usize_ty = module.target_config().pointer_type();
2923

3024
for method in methods {
@@ -65,35 +59,6 @@ fn codegen_inner(
6559
);
6660
}
6761

68-
{
69-
let sig = Signature {
70-
call_conv: module.target_config().default_call_conv,
71-
params: vec![],
72-
returns: vec![AbiParam::new(types::I8)],
73-
};
74-
let func_id = module
75-
.declare_function(
76-
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
77-
Linkage::Export,
78-
&sig,
79-
)
80-
.unwrap();
81-
let mut ctx = Context::new();
82-
ctx.func.signature = sig;
83-
{
84-
let mut func_ctx = FunctionBuilderContext::new();
85-
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
86-
87-
let block = bcx.create_block();
88-
bcx.switch_to_block(block);
89-
let value = bcx.ins().iconst(types::I8, oom_strategy.should_panic() as i64);
90-
bcx.ins().return_(&[value]);
91-
bcx.seal_all_blocks();
92-
bcx.finalize();
93-
}
94-
module.define_function(func_id, &mut ctx).unwrap();
95-
}
96-
9762
{
9863
let sig = Signature {
9964
call_conv: module.target_config().default_call_conv,

compiler/rustc_codegen_gcc/src/allocator.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#[cfg(feature = "master")]
22
use gccjit::FnAttribute;
3-
use gccjit::{Context, FunctionType, RValue, ToRValue, Type};
3+
use gccjit::{Context, FunctionType, ToRValue, Type};
44
use rustc_ast::expand::allocator::{
55
AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name,
66
};
77
use rustc_middle::bug;
88
use rustc_middle::ty::TyCtxt;
9-
use rustc_session::config::OomStrategy;
109
use rustc_symbol_mangling::mangle_internal_symbol;
1110

1211
use crate::GccContext;
@@ -59,14 +58,6 @@ pub(crate) unsafe fn codegen(
5958
create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output);
6059
}
6160

62-
create_const_value_function(
63-
tcx,
64-
context,
65-
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
66-
i8,
67-
context.new_rvalue_from_int(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as i32),
68-
);
69-
7061
create_wrapper_function(
7162
tcx,
7263
context,
@@ -77,34 +68,6 @@ pub(crate) unsafe fn codegen(
7768
);
7869
}
7970

80-
fn create_const_value_function(
81-
tcx: TyCtxt<'_>,
82-
context: &Context<'_>,
83-
name: &str,
84-
output: Type<'_>,
85-
value: RValue<'_>,
86-
) {
87-
let func = context.new_function(None, FunctionType::Exported, output, &[], name, false);
88-
89-
#[cfg(feature = "master")]
90-
{
91-
func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc(
92-
tcx.sess.default_visibility(),
93-
)));
94-
95-
// FIXME(antoyo): cg_llvm sets AlwaysInline, but AlwaysInline is different in GCC and using
96-
// it here will causes linking errors when using LTO.
97-
func.add_attribute(FnAttribute::Inline);
98-
}
99-
100-
if tcx.sess.must_emit_unwind_tables() {
101-
// TODO(antoyo): emit unwind tables.
102-
}
103-
104-
let block = func.new_block("entry");
105-
block.end_with_return(None, value);
106-
}
107-
10871
fn create_wrapper_function(
10972
tcx: TyCtxt<'_>,
11073
context: &Context<'_>,

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,11 @@ impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> {
500500
}
501501

502502
fn set_rvalue_location<'a, 'gcc, 'tcx>(
503-
bx: &mut Builder<'a, 'gcc, 'tcx>,
503+
_bx: &mut Builder<'a, 'gcc, 'tcx>,
504504
rvalue: RValue<'gcc>,
505505
) -> RValue<'gcc> {
506-
if let Some(location) = bx.location {
507-
#[cfg(feature = "master")]
506+
#[cfg(feature = "master")]
507+
if let Some(location) = _bx.location {
508508
rvalue.set_location(location);
509509
}
510510
rvalue

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _;
77
use rustc_middle::bug;
88
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
99
use rustc_middle::ty::TyCtxt;
10-
use rustc_session::config::{DebugInfo, OomStrategy};
10+
use rustc_session::config::DebugInfo;
1111
use rustc_symbol_mangling::mangle_internal_symbol;
1212

1313
use crate::attributes::llfn_attrs_from_instance;
1414
use crate::builder::SBuilder;
1515
use crate::declare::declare_simple_fn;
16-
use crate::llvm::{self, FALSE, FromGeneric, TRUE, Type, Value};
16+
use crate::llvm::{self, FromGeneric, TRUE, Type};
1717
use crate::{SimpleCx, attributes, debuginfo};
1818

1919
pub(crate) unsafe fn codegen(
@@ -28,7 +28,6 @@ pub(crate) unsafe fn codegen(
2828
64 => cx.type_i64(),
2929
tws => bug!("Unsupported target word size for int: {}", tws),
3030
};
31-
let i8 = cx.type_i8();
3231
let i8p = cx.type_ptr();
3332

3433
for method in methods {
@@ -87,17 +86,6 @@ pub(crate) unsafe fn codegen(
8786
);
8887
}
8988

90-
// __rust_alloc_error_handler_should_panic_v2
91-
create_const_value_function(
92-
tcx,
93-
&cx,
94-
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
95-
&i8,
96-
unsafe {
97-
llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, FALSE)
98-
},
99-
);
100-
10189
// __rust_no_alloc_shim_is_unstable_v2
10290
create_wrapper_function(
10391
tcx,
@@ -117,34 +105,6 @@ pub(crate) unsafe fn codegen(
117105
}
118106
}
119107

120-
fn create_const_value_function(
121-
tcx: TyCtxt<'_>,
122-
cx: &SimpleCx<'_>,
123-
name: &str,
124-
output: &Type,
125-
value: &Value,
126-
) {
127-
let ty = cx.type_func(&[], output);
128-
let llfn = declare_simple_fn(
129-
&cx,
130-
name,
131-
llvm::CallConv::CCallConv,
132-
llvm::UnnamedAddr::Global,
133-
llvm::Visibility::from_generic(tcx.sess.default_visibility()),
134-
ty,
135-
);
136-
137-
attributes::apply_to_llfn(
138-
llfn,
139-
llvm::AttributePlace::Function,
140-
&[llvm::AttributeKind::AlwaysInline.create_attr(cx.llcx)],
141-
);
142-
143-
let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) };
144-
let mut bx = SBuilder::build(&cx, llbb);
145-
bx.ret(value);
146-
}
147-
148108
fn create_wrapper_function(
149109
tcx: TyCtxt<'_>,
150110
cx: &SimpleCx<'_>,

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::middle::exported_symbols::{
1515
use rustc_middle::query::LocalCrate;
1616
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, Ty, TyCtxt};
1717
use rustc_middle::util::Providers;
18-
use rustc_session::config::{CrateType, OomStrategy};
18+
use rustc_session::config::CrateType;
1919
use rustc_symbol_mangling::mangle_internal_symbol;
2020
use rustc_target::spec::{Arch, Os, TlsModel};
2121
use tracing::debug;
@@ -493,7 +493,6 @@ pub(crate) fn allocator_shim_symbols(
493493
.map(move |method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
494494
.chain([
495495
mangle_internal_symbol(tcx, global_fn_name(ALLOC_ERROR_HANDLER).as_str()),
496-
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
497496
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
498497
])
499498
.map(move |symbol_name| {

0 commit comments

Comments
 (0)