Skip to content

Commit 797b5f0

Browse files
committed
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #105375 (Fix an outdated comment mentioning parameter that doesn't exist anymore) - #105955 (Remove wrapper functions for some unstable options) - #106137 (fix more clippy::style findings) - #106140 (Migrate links-color.goml to functions) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8dfb339 + a054e70 commit 797b5f0

File tree

24 files changed

+173
-211
lines changed

24 files changed

+173
-211
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
259259
body.as_deref(),
260260
);
261261

262-
let mut itctx = ImplTraitContext::Universal;
263-
let (generics, decl) = this.lower_generics(generics, id, &mut itctx, |this| {
262+
let itctx = ImplTraitContext::Universal;
263+
let (generics, decl) = this.lower_generics(generics, id, &itctx, |this| {
264264
let ret_id = asyncness.opt_return_id();
265265
this.lower_fn_decl(&decl, id, *fn_sig_span, FnDeclKind::Fn, ret_id)
266266
});
@@ -369,9 +369,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
369369
// method, it will not be considered an in-band
370370
// lifetime to be added, but rather a reference to a
371371
// parent lifetime.
372-
let mut itctx = ImplTraitContext::Universal;
372+
let itctx = ImplTraitContext::Universal;
373373
let (generics, (trait_ref, lowered_ty)) =
374-
self.lower_generics(ast_generics, id, &mut itctx, |this| {
374+
self.lower_generics(ast_generics, id, &itctx, |this| {
375375
let trait_ref = trait_ref.as_ref().map(|trait_ref| {
376376
this.lower_trait_ref(
377377
trait_ref,
@@ -590,9 +590,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
590590
kind: match &i.kind {
591591
ForeignItemKind::Fn(box Fn { sig, generics, .. }) => {
592592
let fdec = &sig.decl;
593-
let mut itctx = ImplTraitContext::Universal;
593+
let itctx = ImplTraitContext::Universal;
594594
let (generics, (fn_dec, fn_args)) =
595-
self.lower_generics(generics, i.id, &mut itctx, |this| {
595+
self.lower_generics(generics, i.id, &itctx, |this| {
596596
(
597597
// Disallow `impl Trait` in foreign items.
598598
this.lower_fn_decl(
@@ -1184,8 +1184,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
11841184
is_async: Option<(NodeId, Span)>,
11851185
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
11861186
let header = self.lower_fn_header(sig.header);
1187-
let mut itctx = ImplTraitContext::Universal;
1188-
let (generics, decl) = self.lower_generics(generics, id, &mut itctx, |this| {
1187+
let itctx = ImplTraitContext::Universal;
1188+
let (generics, decl) = self.lower_generics(generics, id, &itctx, |this| {
11891189
this.lower_fn_decl(&sig.decl, id, sig.span, kind, is_async)
11901190
});
11911191
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16561656
// Lowers a function declaration.
16571657
//
16581658
// `decl`: the unlowered (AST) function declaration.
1659-
// `fn_def_id`: if `Some`, impl Trait arguments are lowered into generic parameters on the
1660-
// given DefId, otherwise impl Trait is disallowed. Must be `Some` if
1661-
// `make_ret_async` is also `Some`.
1659+
// `fn_node_id`: `impl Trait` arguments are lowered into generic parameters on the given `NodeId`.
16621660
// `make_ret_async`: if `Some`, converts `-> T` into `-> impl Future<Output = T>` in the
16631661
// return type. This is used for `async fn` declarations. The `NodeId` is the ID of the
16641662
// return type `impl Trait` item, and the `Span` points to the `async` keyword.
@@ -1789,7 +1787,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17891787
// type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
17901788
//
17911789
// `output`: unlowered output type (`T` in `-> T`)
1792-
// `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition)
1790+
// `fn_node_id`: `NodeId` of the parent function (used to create child impl trait definition)
17931791
// `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
17941792
#[instrument(level = "debug", skip(self))]
17951793
fn lower_async_fn_ret_ty(
@@ -2031,15 +2029,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20312029
&mut self,
20322030
output: &FnRetTy,
20332031
span: Span,
2034-
mut nested_impl_trait_context: ImplTraitContext,
2032+
nested_impl_trait_context: ImplTraitContext,
20352033
) -> hir::GenericBound<'hir> {
20362034
// Compute the `T` in `Future<Output = T>` from the return type.
20372035
let output_ty = match output {
20382036
FnRetTy::Ty(ty) => {
20392037
// Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
20402038
// `impl Future` opaque type that `async fn` implicitly
20412039
// generates.
2042-
self.lower_ty(ty, &mut nested_impl_trait_context)
2040+
self.lower_ty(ty, &nested_impl_trait_context)
20432041
}
20442042
FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
20452043
};

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3737
qself,
3838
path,
3939
ParamMode::Optional,
40-
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
40+
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
4141
);
4242
let (pats, ddpos) = self.lower_pat_tuple(pats, "tuple struct");
4343
break hir::PatKind::TupleStruct(qpath, pats, ddpos);
@@ -53,7 +53,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
5353
qself,
5454
path,
5555
ParamMode::Optional,
56-
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
56+
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
5757
);
5858
break hir::PatKind::Path(qpath);
5959
}
@@ -63,7 +63,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6363
qself,
6464
path,
6565
ParamMode::Optional,
66-
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
66+
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
6767
);
6868

6969
let fs = self.arena.alloc_from_iter(fields.iter().map(|f| {

compiler/rustc_borrowck/src/type_check/input_output.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,30 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
3737
// those.
3838
//
3939
// e.g., `|x: FxHashMap<_, &'static u32>| ...`
40-
let user_provided_sig;
41-
if !self.tcx().is_closure(mir_def_id.to_def_id()) {
42-
user_provided_sig = None;
40+
let user_provided_sig = if !self.tcx().is_closure(mir_def_id.to_def_id()) {
41+
None
4342
} else {
4443
let typeck_results = self.tcx().typeck(mir_def_id);
45-
user_provided_sig =
46-
typeck_results.user_provided_sigs.get(&mir_def_id).map(|user_provided_poly_sig| {
47-
// Instantiate the canonicalized variables from
48-
// user-provided signature (e.g., the `_` in the code
49-
// above) with fresh variables.
50-
let poly_sig = self.instantiate_canonical_with_fresh_inference_vars(
51-
body.span,
52-
&user_provided_poly_sig,
53-
);
54-
55-
// Replace the bound items in the fn sig with fresh
56-
// variables, so that they represent the view from
57-
// "inside" the closure.
58-
self.infcx.replace_bound_vars_with_fresh_vars(
59-
body.span,
60-
LateBoundRegionConversionTime::FnCall,
61-
poly_sig,
62-
)
63-
});
64-
}
44+
45+
typeck_results.user_provided_sigs.get(&mir_def_id).map(|user_provided_poly_sig| {
46+
// Instantiate the canonicalized variables from
47+
// user-provided signature (e.g., the `_` in the code
48+
// above) with fresh variables.
49+
let poly_sig = self.instantiate_canonical_with_fresh_inference_vars(
50+
body.span,
51+
&user_provided_poly_sig,
52+
);
53+
54+
// Replace the bound items in the fn sig with fresh
55+
// variables, so that they represent the view from
56+
// "inside" the closure.
57+
self.infcx.replace_bound_vars_with_fresh_vars(
58+
body.span,
59+
LateBoundRegionConversionTime::FnCall,
60+
poly_sig,
61+
)
62+
})
63+
};
6564

6665
debug!(?normalized_input_tys, ?body.local_decls);
6766

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ pub fn uwtable_attr(llcx: &llvm::Context) -> &Attribute {
102102

103103
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
104104
let mut fp = cx.sess().target.frame_pointer;
105+
let opts = &cx.sess().opts;
105106
// "mcount" function relies on stack pointer.
106107
// See <https://sourceware.org/binutils/docs/gprof/Implementation.html>.
107-
if cx.sess().instrument_mcount() || matches!(cx.sess().opts.cg.force_frame_pointers, Some(true))
108-
{
108+
if opts.unstable_opts.instrument_mcount || matches!(opts.cg.force_frame_pointers, Some(true)) {
109109
fp = FramePointer::Always;
110110
}
111111
let attr_value = match fp {
@@ -119,7 +119,7 @@ pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attr
119119
/// Tell LLVM what instrument function to insert.
120120
#[inline]
121121
fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
122-
if cx.sess().instrument_mcount() {
122+
if cx.sess().opts.unstable_opts.instrument_mcount {
123123
// Similar to `clang -pg` behavior. Handled by the
124124
// `post-inline-ee-instrument` LLVM pass.
125125

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn target_machine_factory(
203203
sess.opts.unstable_opts.trap_unreachable.unwrap_or(sess.target.trap_unreachable);
204204
let emit_stack_size_section = sess.opts.unstable_opts.emit_stack_sizes;
205205

206-
let asm_comments = sess.asm_comments();
206+
let asm_comments = sess.opts.unstable_opts.asm_comments;
207207
let relax_elf_relocations =
208208
sess.opts.unstable_opts.relax_elf_relocations.unwrap_or(sess.target.relax_elf_relocations);
209209

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ unsafe fn configure_llvm(sess: &Session) {
8181
};
8282
// Set the llvm "program name" to make usage and invalid argument messages more clear.
8383
add("rustc -Cllvm-args=\"...\" with", true);
84-
if sess.time_llvm_passes() {
84+
if sess.opts.unstable_opts.time_llvm_passes {
8585
add("-time-passes", false);
8686
}
87-
if sess.print_llvm_passes() {
87+
if sess.opts.unstable_opts.print_llvm_passes {
8888
add("-debug-pass=Structure", false);
8989
}
9090
if sess.target.generate_arange_section

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
18991899

19001900
// FIXME: time_llvm_passes support - does this use a global context or
19011901
// something?
1902-
if sess.codegen_units() == 1 && sess.time_llvm_passes() {
1902+
if sess.codegen_units() == 1 && sess.opts.unstable_opts.time_llvm_passes {
19031903
self.backend.print_pass_timings()
19041904
}
19051905

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
681681
});
682682

683683
let mut total_codegen_time = Duration::new(0, 0);
684-
let start_rss = tcx.sess.time_passes().then(|| get_resident_set_size());
684+
let start_rss = tcx.sess.opts.unstable_opts.time_passes.then(|| get_resident_set_size());
685685

686686
// The non-parallel compiler can only translate codegen units to LLVM IR
687687
// on a single thread, leading to a staircase effect where the N LLVM
@@ -781,7 +781,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
781781

782782
// Since the main thread is sometimes blocked during codegen, we keep track
783783
// -Ztime-passes output manually.
784-
if tcx.sess.time_passes() {
784+
if tcx.sess.opts.unstable_opts.time_passes {
785785
let end_rss = get_resident_set_size();
786786

787787
print_time_passes_entry(

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ pub fn compute_debuginfo_vtable_name<'tcx>(
509509
visited.clear();
510510
push_generic_params_internal(tcx, trait_ref.substs, &mut vtable_name, &mut visited);
511511
} else {
512-
vtable_name.push_str("_");
512+
vtable_name.push('_');
513513
}
514514

515515
push_close_angle_bracket(cpp_like_debuginfo, &mut vtable_name);

0 commit comments

Comments
 (0)