Skip to content

Commit 1ac1950

Browse files
committed
Auto merge of #141739 - GuillaumeGomez:rollup-ivboqwd, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #137574 (Make `std/src/num` mirror `core/src/num`) - #141384 (Enable review queue tracking) - #141448 (A variety of improvements to the codegen backends) - #141636 (avoid some usages of `&mut P<T>` in AST visitors) - #141676 (float: Disable `total_cmp` sNaN tests for `f16`) - #141705 (Add eslint as part of `tidy` run) - #141715 (Add `loongarch64` with `d` feature to `f32::midpoint` fast path) - #141723 (Provide secrets to try builds with new bors) - #141728 (Fix false documentation of FnCtxt::diverges) - #141729 (resolve target-libdir directly from rustc) - #141732 (creader: Remove extraenous String::clone) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1bbd62e + 18646a8 commit 1ac1950

File tree

54 files changed

+348
-275
lines changed

Some content is hidden

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

54 files changed

+348
-275
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ concurrency:
3434
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
3535
# We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which
3636
# are all triggered on the same branch, but which should be able to run concurrently.
37-
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}
37+
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try') && github.sha) || github.ref }}
3838
cancel-in-progress: true
3939
env:
4040
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
@@ -80,7 +80,7 @@ jobs:
8080
# access the environment.
8181
#
8282
# We only enable the environment for the rust-lang/rust repository, so that CI works on forks.
83-
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
83+
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
8484
env:
8585
CI_JOB_NAME: ${{ matrix.name }}
8686
CI_JOB_DOC_URL: ${{ matrix.doc_url }}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ pub trait MutVisitor: Sized {
7777
walk_use_tree(self, use_tree);
7878
}
7979

80-
fn visit_foreign_item(&mut self, ni: &mut P<ForeignItem>) {
80+
fn visit_foreign_item(&mut self, ni: &mut ForeignItem) {
8181
walk_item(self, ni);
8282
}
8383

8484
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
8585
walk_flat_map_foreign_item(self, ni)
8686
}
8787

88-
fn visit_item(&mut self, i: &mut P<Item>) {
88+
fn visit_item(&mut self, i: &mut Item) {
8989
walk_item(self, i);
9090
}
9191

@@ -105,7 +105,7 @@ pub trait MutVisitor: Sized {
105105
walk_flat_map_field_def(self, fd)
106106
}
107107

108-
fn visit_assoc_item(&mut self, i: &mut P<AssocItem>, ctxt: AssocCtxt) {
108+
fn visit_assoc_item(&mut self, i: &mut AssocItem, ctxt: AssocCtxt) {
109109
walk_assoc_item(self, i, ctxt)
110110
}
111111

@@ -117,11 +117,11 @@ pub trait MutVisitor: Sized {
117117
walk_flat_map_assoc_item(self, i, ctxt)
118118
}
119119

120-
fn visit_contract(&mut self, c: &mut P<FnContract>) {
120+
fn visit_contract(&mut self, c: &mut FnContract) {
121121
walk_contract(self, c);
122122
}
123123

124-
fn visit_fn_decl(&mut self, d: &mut P<FnDecl>) {
124+
fn visit_fn_decl(&mut self, d: &mut FnDecl) {
125125
walk_fn_decl(self, d);
126126
}
127127

@@ -138,7 +138,7 @@ pub trait MutVisitor: Sized {
138138
walk_closure_binder(self, b);
139139
}
140140

141-
fn visit_block(&mut self, b: &mut P<Block>) {
141+
fn visit_block(&mut self, b: &mut Block) {
142142
walk_block(self, b);
143143
}
144144

@@ -184,7 +184,7 @@ pub trait MutVisitor: Sized {
184184
walk_ty(self, t);
185185
}
186186

187-
fn visit_ty_pat(&mut self, t: &mut P<TyPat>) {
187+
fn visit_ty_pat(&mut self, t: &mut TyPat) {
188188
walk_ty_pat(self, t);
189189
}
190190

@@ -240,7 +240,7 @@ pub trait MutVisitor: Sized {
240240
walk_parenthesized_parameter_data(self, p);
241241
}
242242

243-
fn visit_local(&mut self, l: &mut P<Local>) {
243+
fn visit_local(&mut self, l: &mut Local) {
244244
walk_local(self, l);
245245
}
246246

@@ -507,8 +507,8 @@ fn walk_assoc_item_constraint<T: MutVisitor>(
507507
vis.visit_span(span);
508508
}
509509

510-
pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
511-
let Ty { id, kind, span, tokens: _ } = ty.deref_mut();
510+
pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut Ty) {
511+
let Ty { id, kind, span, tokens: _ } = ty;
512512
vis.visit_id(id);
513513
match kind {
514514
TyKind::Err(_guar) => {}
@@ -559,8 +559,8 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
559559
vis.visit_span(span);
560560
}
561561

562-
pub fn walk_ty_pat<T: MutVisitor>(vis: &mut T, ty: &mut P<TyPat>) {
563-
let TyPat { id, kind, span, tokens: _ } = ty.deref_mut();
562+
pub fn walk_ty_pat<T: MutVisitor>(vis: &mut T, ty: &mut TyPat) {
563+
let TyPat { id, kind, span, tokens: _ } = ty;
564564
vis.visit_id(id);
565565
match kind {
566566
TyPatKind::Range(start, end, _include_end) => {
@@ -651,8 +651,8 @@ fn walk_parenthesized_parameter_data<T: MutVisitor>(vis: &mut T, args: &mut Pare
651651
vis.visit_span(inputs_span);
652652
}
653653

654-
fn walk_local<T: MutVisitor>(vis: &mut T, local: &mut P<Local>) {
655-
let Local { id, super_, pat, ty, kind, span, colon_sp, attrs, tokens: _ } = local.deref_mut();
654+
fn walk_local<T: MutVisitor>(vis: &mut T, local: &mut Local) {
655+
let Local { id, super_, pat, ty, kind, span, colon_sp, attrs, tokens: _ } = local;
656656
visit_opt(super_, |sp| vis.visit_span(sp));
657657
vis.visit_id(id);
658658
visit_attrs(vis, attrs);
@@ -789,8 +789,8 @@ fn walk_fn<T: MutVisitor>(vis: &mut T, kind: FnKind<'_>) {
789789
}
790790
}
791791

792-
fn walk_contract<T: MutVisitor>(vis: &mut T, contract: &mut P<FnContract>) {
793-
let FnContract { requires, ensures } = contract.deref_mut();
792+
fn walk_contract<T: MutVisitor>(vis: &mut T, contract: &mut FnContract) {
793+
let FnContract { requires, ensures } = contract;
794794
if let Some(pred) = requires {
795795
vis.visit_expr(pred);
796796
}
@@ -799,8 +799,8 @@ fn walk_contract<T: MutVisitor>(vis: &mut T, contract: &mut P<FnContract>) {
799799
}
800800
}
801801

802-
fn walk_fn_decl<T: MutVisitor>(vis: &mut T, decl: &mut P<FnDecl>) {
803-
let FnDecl { inputs, output } = decl.deref_mut();
802+
fn walk_fn_decl<T: MutVisitor>(vis: &mut T, decl: &mut FnDecl) {
803+
let FnDecl { inputs, output } = decl;
804804
inputs.flat_map_in_place(|param| vis.flat_map_param(param));
805805
vis.visit_fn_ret_ty(output);
806806
}
@@ -999,8 +999,8 @@ pub fn walk_flat_map_expr_field<T: MutVisitor>(
999999
smallvec![f]
10001000
}
10011001

1002-
pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
1003-
let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut();
1002+
pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut Block) {
1003+
let Block { id, stmts, rules: _, span, tokens: _ } = block;
10041004
vis.visit_id(id);
10051005
stmts.flat_map_in_place(|stmt| vis.flat_map_stmt(stmt));
10061006
vis.visit_span(span);
@@ -1049,8 +1049,8 @@ pub fn walk_flat_map_assoc_item(
10491049
smallvec![item]
10501050
}
10511051

1052-
pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
1053-
let Pat { id, kind, span, tokens: _ } = pat.deref_mut();
1052+
pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut Pat) {
1053+
let Pat { id, kind, span, tokens: _ } = pat;
10541054
vis.visit_id(id);
10551055
match kind {
10561056
PatKind::Err(_guar) => {}

compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ macro_rules! common_visitor_and_walkers {
404404

405405
fn walk_item_ctxt<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind>(
406406
visitor: &mut V,
407-
item: &$($mut P<Item<K>>)? $($lt Item<K>)?,
407+
item: &$($mut)? $($lt)? Item<K>,
408408
ctxt: K::Ctxt,
409409
) $(-> <V as Visitor<$lt>>::Result)? {
410-
let Item { attrs, id, kind, vis, span, tokens: _ } = &$($mut *)? *item;
410+
let Item { attrs, id, kind, vis, span, tokens: _ } = item;
411411
try_visit!(visit_id(visitor, id));
412412
walk_list!(visitor, visit_attribute, attrs);
413413
try_visit!(visitor.visit_vis(vis));
@@ -417,14 +417,14 @@ macro_rules! common_visitor_and_walkers {
417417

418418
pub fn walk_item<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind<Ctxt = ()>>(
419419
visitor: &mut V,
420-
item: &$($mut P<Item<K>>)? $($lt Item<K>)?,
420+
item: &$($mut)? $($lt)? Item<K>,
421421
) $(-> <V as Visitor<$lt>>::Result)? {
422422
walk_item_ctxt(visitor, item, ())
423423
}
424424

425425
pub fn walk_assoc_item<$($lt,)? V: $Visitor$(<$lt>)?>(
426426
visitor: &mut V,
427-
item: &$($mut P<AssocItem>)? $($lt AssocItem)?,
427+
item: &$($mut)? $($lt)? AssocItem,
428428
ctxt: AssocCtxt,
429429
) $(-> <V as Visitor<$lt>>::Result)? {
430430
walk_item_ctxt(visitor, item, ctxt)

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
128128
c.items.push(mk_main(&mut self.cx));
129129
}
130130

131-
fn visit_item(&mut self, item: &mut P<ast::Item>) {
132-
let item = &mut **item;
133-
131+
fn visit_item(&mut self, item: &mut ast::Item) {
134132
if let Some(name) = get_test_name(&item) {
135133
debug!("this is a test item");
136134

@@ -193,7 +191,7 @@ struct EntryPointCleaner<'a> {
193191
}
194192

195193
impl<'a> MutVisitor for EntryPointCleaner<'a> {
196-
fn visit_item(&mut self, item: &mut P<ast::Item>) {
194+
fn visit_item(&mut self, item: &mut ast::Item) {
197195
self.depth += 1;
198196
ast::mut_visit::walk_item(self, item);
199197
self.depth -= 1;

compiler/rustc_codegen_gcc/src/abi.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_target::callconv::{Conv, RiscvInterruptKind};
1515

1616
use crate::builder::Builder;
1717
use crate::context::CodegenCx;
18-
use crate::intrinsic::ArgAbiExt;
1918
use crate::type_of::LayoutGccExt;
2019

2120
impl AbiBuilderMethods for Builder<'_, '_, '_> {
@@ -125,7 +124,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
125124
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
126125
PassMode::Cast { ref cast, .. } => cast.gcc_type(cx),
127126
PassMode::Indirect { .. } => {
128-
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
127+
argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx)));
129128
cx.type_void()
130129
}
131130
};
@@ -176,13 +175,13 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
176175
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: true } => {
177176
// This is a "byval" argument, so we don't apply the `restrict` attribute on it.
178177
on_stack_param_indices.insert(argument_tys.len());
179-
arg.memory_ty(cx)
178+
arg.layout.gcc_type(cx)
180179
}
181180
PassMode::Direct(attrs) => {
182181
apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len())
183182
}
184183
PassMode::Indirect { attrs, meta_attrs: None, on_stack: false } => {
185-
apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs, argument_tys.len())
184+
apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len())
186185
}
187186
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
188187
assert!(!on_stack);

compiler/rustc_codegen_gcc/src/base.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,22 @@ pub fn compile_codegen_unit(
219219

220220
let mono_items = cgu.items_in_deterministic_order(tcx);
221221
for &(mono_item, data) in &mono_items {
222-
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
222+
mono_item.predefine::<Builder<'_, '_, '_>>(
223+
&mut cx,
224+
cgu_name.as_str(),
225+
data.linkage,
226+
data.visibility,
227+
);
223228
}
224229

225230
// ... and now that we have everything pre-defined, fill out those definitions.
226231
for &(mono_item, item_data) in &mono_items {
227-
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, item_data);
232+
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, cgu_name.as_str(), item_data);
228233
}
229234

230235
// If this codegen unit contains the main function, also create the
231236
// wrapper here
232-
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx);
237+
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx, cx.codegen_unit);
233238

234239
// Finalize debuginfo
235240
if cx.sess().opts.debuginfo != DebugInfo::None {

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
6767
}
6868

6969
#[cfg_attr(not(feature = "master"), allow(unused_mut))]
70-
fn codegen_static(&self, def_id: DefId) {
70+
fn codegen_static(&mut self, def_id: DefId) {
7171
let attrs = self.tcx.codegen_fn_attrs(def_id);
7272

7373
let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else {
@@ -160,19 +160,14 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
160160
self.add_used_global(global.to_rvalue());
161161
}
162162
}
163+
}
163164

165+
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
164166
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*.
165-
fn add_used_global(&self, _global: RValue<'gcc>) {
167+
pub fn add_used_global(&mut self, _global: RValue<'gcc>) {
166168
// TODO(antoyo)
167169
}
168170

169-
fn add_compiler_used_global(&self, global: RValue<'gcc>) {
170-
// NOTE: seems like GCC does not make the distinction between compiler.used and used.
171-
self.add_used_global(global);
172-
}
173-
}
174-
175-
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
176171
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
177172
pub fn add_used_function(&self, function: Function<'gcc>) {
178173
#[cfg(feature = "master")]

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,6 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
470470
self.tcx.sess
471471
}
472472

473-
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
474-
self.codegen_unit
475-
}
476-
477473
fn set_frame_pointer_type(&self, _llfn: RValue<'gcc>) {
478474
// TODO(antoyo)
479475
}

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,9 @@ impl<'a, 'gcc, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
574574
) {
575575
arg_abi.store(self, val, dst)
576576
}
577-
578-
fn arg_memory_ty(&self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>) -> Type<'gcc> {
579-
arg_abi.memory_ty(self)
580-
}
581577
}
582578

583579
pub trait ArgAbiExt<'gcc, 'tcx> {
584-
fn memory_ty(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
585580
fn store(
586581
&self,
587582
bx: &mut Builder<'_, 'gcc, 'tcx>,
@@ -597,12 +592,6 @@ pub trait ArgAbiExt<'gcc, 'tcx> {
597592
}
598593

599594
impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
600-
/// Gets the LLVM type for a place of the original Rust type of
601-
/// this argument/return, i.e., the result of `type_of::type_of`.
602-
fn memory_ty(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
603-
self.layout.gcc_type(cx)
604-
}
605-
606595
/// Stores a direct/indirect value described by this ArgAbi into a
607596
/// place for the original Rust type of this argument/return.
608597
/// Can be used for both storing formal arguments into Rust variables

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl WriteBackendMethods for GccCodegenBackend {
391391
unimplemented!()
392392
}
393393

394-
unsafe fn optimize(
394+
fn optimize(
395395
_cgcx: &CodegenContext<Self>,
396396
_dcx: DiagCtxtHandle<'_>,
397397
module: &mut ModuleCodegen<Self::Module>,
@@ -409,14 +409,14 @@ impl WriteBackendMethods for GccCodegenBackend {
409409
Ok(())
410410
}
411411

412-
unsafe fn optimize_thin(
412+
fn optimize_thin(
413413
cgcx: &CodegenContext<Self>,
414414
thin: ThinModule<Self>,
415415
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
416416
back::lto::optimize_thin_module(thin, cgcx)
417417
}
418418

419-
unsafe fn codegen(
419+
fn codegen(
420420
cgcx: &CodegenContext<Self>,
421421
dcx: DiagCtxtHandle<'_>,
422422
module: ModuleCodegen<Self::Module>,

compiler/rustc_codegen_gcc/src/mono_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{attributes, base};
1616
impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
1717
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
1818
fn predefine_static(
19-
&self,
19+
&mut self,
2020
def_id: DefId,
2121
_linkage: Linkage,
2222
visibility: Visibility,
@@ -42,7 +42,7 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
4242

4343
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
4444
fn predefine_fn(
45-
&self,
45+
&mut self,
4646
instance: Instance<'tcx>,
4747
linkage: Linkage,
4848
visibility: Visibility,

0 commit comments

Comments
 (0)