From adbd7bee01aaf94bd70636103a39b546a1a1cdf5 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 28 Sep 2024 02:38:13 -0400 Subject: [PATCH] Change a few `&Option` into `Option<&T>` --- compiler/rustc_ast_lowering/src/asm.rs | 2 +- compiler/rustc_ast_lowering/src/delegation.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 10 ++--- compiler/rustc_ast_lowering/src/format.rs | 6 +-- compiler/rustc_ast_lowering/src/lib.rs | 10 ++--- compiler/rustc_ast_lowering/src/pat.rs | 6 +-- compiler/rustc_ast_lowering/src/path.rs | 2 +- compiler/rustc_ast_pretty/src/pprust/state.rs | 12 +++--- .../rustc_ast_pretty/src/pprust/state/expr.rs | 4 +- .../rustc_ast_pretty/src/pprust/state/item.rs | 20 ++++----- .../src/diagnostics/conflict_errors.rs | 14 ++++-- compiler/rustc_borrowck/src/lib.rs | 11 ++++- compiler/rustc_borrowck/src/nll.rs | 6 +-- compiler/rustc_borrowck/src/polonius/dump.rs | 2 +- .../build_system/src/utils.rs | 10 ++--- compiler/rustc_codegen_gcc/src/builder.rs | 2 +- compiler/rustc_codegen_gcc/src/debuginfo.rs | 14 ++++-- .../rustc_codegen_gcc/src/intrinsic/llvm.rs | 4 +- compiler/rustc_codegen_llvm/src/attributes.rs | 4 +- .../src/debuginfo/create_scope_map.rs | 4 +- .../src/annotate_snippet_emitter_writer.rs | 4 +- compiler/rustc_errors/src/diagnostic.rs | 8 ++-- compiler/rustc_errors/src/emitter.rs | 10 ++--- .../rustc_hir_analysis/src/check/wfcheck.rs | 4 +- .../rustc_incremental/src/assert_dep_graph.rs | 6 +-- .../rustc_monomorphize/src/partitioning.rs | 6 +-- compiler/rustc_parse/src/parser/expr.rs | 6 +-- .../src/dep_graph/serialized.rs | 10 ++--- compiler/rustc_query_system/src/query/job.rs | 4 +- .../rustc_query_system/src/query/plumbing.rs | 7 ++- compiler/rustc_resolve/src/late.rs | 43 +++++++++++-------- compiler/rustc_session/src/config.rs | 9 ++-- 32 files changed, 146 insertions(+), 116 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index 2f1f1269ece57..c24513843cc78 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -206,7 +206,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { if let Some(def_id) = static_def_id { let path = self.lower_qpath( sym.id, - &sym.qself, + sym.qself.as_ref(), &sym.path, ParamMode::Optional, AllowReturnTypeNotation::No, diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 758f1dc1c3558..39c37aad3c49e 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -337,7 +337,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } else { let path = self.lower_qpath( delegation.id, - &delegation.qself, + delegation.qself.as_ref(), &delegation.path, ParamMode::Optional, AllowReturnTypeNotation::No, diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index d16a3ce390dbe..9d742af2e65ac 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -318,7 +318,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Path(qself, path) => { let qpath = self.lower_qpath( e.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -363,7 +363,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ExprKind::Struct( self.arena.alloc(self.lower_qpath( e.id, - &se.qself, + se.qself.as_ref(), &se.path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -1357,7 +1357,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ); let qpath = self.lower_qpath( callee.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -1378,7 +1378,7 @@ impl<'hir> LoweringContext<'_, 'hir> { if let Some((qself, path)) = self.extract_unit_struct_path(lhs) { let qpath = self.lower_qpath( lhs.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -1404,7 +1404,7 @@ impl<'hir> LoweringContext<'_, 'hir> { })); let qpath = self.lower_qpath( lhs.id, - &se.qself, + se.qself.as_ref(), &se.path, ParamMode::Optional, AllowReturnTypeNotation::No, diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 22aa1e6fc201a..3fcb825dd531a 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -282,7 +282,7 @@ fn make_argument<'hir>( fn make_count<'hir>( ctx: &mut LoweringContext<'_, 'hir>, sp: Span, - count: &Option, + count: Option<&FormatCount>, argmap: &mut FxIndexMap<(usize, ArgumentType), Option>, ) -> hir::Expr<'hir> { match count { @@ -377,8 +377,8 @@ fn make_format_spec<'hir>( | ((debug_hex == Some(FormatDebugHex::Lower)) as u32) << 4 | ((debug_hex == Some(FormatDebugHex::Upper)) as u32) << 5; let flags = ctx.expr_u32(sp, flags); - let precision = make_count(ctx, sp, precision, argmap); - let width = make_count(ctx, sp, width, argmap); + let precision = make_count(ctx, sp, precision.as_ref(), argmap); + let width = make_count(ctx, sp, width.as_ref(), argmap); let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative( sp, hir::LangItem::FormatPlaceholder, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8438a42122688..240a8bd205ad6 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1129,7 +1129,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_path_ty( &mut self, t: &Ty, - qself: &Option>, + qself: Option<&ptr::P>, path: &Path, param_mode: ParamMode, itctx: ImplTraitContext, @@ -1255,7 +1255,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { return self.lower_ty_direct(ty, itctx); } TyKind::Path(qself, path) => { - return self.lower_path_ty(t, qself, path, ParamMode::Explicit, itctx); + return self.lower_path_ty(t, qself.as_ref(), path, ParamMode::Explicit, itctx); } TyKind::ImplicitSelf => { let hir_id = self.next_id(); @@ -1919,7 +1919,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ) -> hir::TraitRef<'hir> { let path = match self.lower_qpath( p.ref_id, - &None, + None, &p.path, ParamMode::Explicit, AllowReturnTypeNotation::No, @@ -2070,7 +2070,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { { let qpath = self.lower_qpath( ty_id, - &None, + None, path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -2146,7 +2146,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { { let qpath = self.lower_qpath( expr.id, - &None, + None, path, ParamMode::Optional, AllowReturnTypeNotation::No, diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index a4ab2561b721b..dbbc7e48ec478 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -41,7 +41,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { PatKind::TupleStruct(qself, path, pats) => { let qpath = self.lower_qpath( pattern.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -59,7 +59,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { PatKind::Path(qself, path) => { let qpath = self.lower_qpath( pattern.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, @@ -71,7 +71,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { PatKind::Struct(qself, path, fields, etc) => { let qpath = self.lower_qpath( pattern.id, - qself, + qself.as_ref(), path, ParamMode::Optional, AllowReturnTypeNotation::No, diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 043144a54649b..420c1bc37f7a9 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -24,7 +24,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pub(crate) fn lower_qpath( &mut self, id: NodeId, - qself: &Option>, + qself: Option<&ptr::P>, p: &Path, param_mode: ParamMode, allow_return_type_notation: AllowReturnTypeNotation, diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 172df10292920..02c774e89d735 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1110,9 +1110,9 @@ impl<'a> State<'a> { self.commasep_cmnt(b, exprs, |s, e| s.print_expr(e, FixupContext::default()), |e| e.span) } - pub fn print_opt_lifetime(&mut self, lifetime: &Option) { - if let Some(lt) = *lifetime { - self.print_lifetime(lt); + pub fn print_opt_lifetime(&mut self, lifetime: Option<&ast::Lifetime>) { + if let Some(lt) = lifetime { + self.print_lifetime(*lt); self.nbsp(); } } @@ -1163,12 +1163,12 @@ impl<'a> State<'a> { } ast::TyKind::Ref(lifetime, mt) => { self.word("&"); - self.print_opt_lifetime(lifetime); + self.print_opt_lifetime(lifetime.as_ref()); self.print_mt(mt, false); } ast::TyKind::PinnedRef(lifetime, mt) => { self.word("&"); - self.print_opt_lifetime(lifetime); + self.print_opt_lifetime(lifetime.as_ref()); self.word("pin "); self.print_mt(mt, true); } @@ -1752,7 +1752,7 @@ impl<'a> State<'a> { } SelfKind::Region(lt, m) => { self.word("&"); - self.print_opt_lifetime(lt); + self.print_opt_lifetime(lt.as_ref()); self.print_mutability(*m, false); self.word("self") } diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index dce76fb1e7707..65654cde35c4a 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -147,7 +147,7 @@ impl<'a> State<'a> { fn print_expr_struct( &mut self, - qself: &Option>, + qself: Option<&P>, path: &ast::Path, fields: &[ast::ExprField], rest: &ast::StructRest, @@ -395,7 +395,7 @@ impl<'a> State<'a> { self.print_expr_repeat(element, count); } ast::ExprKind::Struct(se) => { - self.print_expr_struct(&se.qself, &se.path, &se.fields, &se.rest); + self.print_expr_struct(se.qself.as_ref(), &se.path, &se.fields, &se.rest); } ast::ExprKind::Tup(exprs) => { self.print_expr_tup(exprs); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 897c275d850c2..aa770eee3a3f8 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -390,18 +390,18 @@ impl<'a> State<'a> { ast::ItemKind::Delegation(deleg) => self.print_delegation( &item.attrs, &item.vis, - &deleg.qself, + deleg.qself.as_ref(), &deleg.path, DelegationKind::Single, - &deleg.body, + deleg.body.as_ref(), ), ast::ItemKind::DelegationMac(deleg) => self.print_delegation( &item.attrs, &item.vis, - &deleg.qself, + deleg.qself.as_ref(), &deleg.prefix, deleg.suffixes.as_ref().map_or(DelegationKind::Glob, |s| DelegationKind::List(s)), - &deleg.body, + deleg.body.as_ref(), ), } self.ann.post(self, AnnNode::Item(item)) @@ -583,18 +583,18 @@ impl<'a> State<'a> { ast::AssocItemKind::Delegation(deleg) => self.print_delegation( &item.attrs, vis, - &deleg.qself, + deleg.qself.as_ref(), &deleg.path, DelegationKind::Single, - &deleg.body, + deleg.body.as_ref(), ), ast::AssocItemKind::DelegationMac(deleg) => self.print_delegation( &item.attrs, vis, - &deleg.qself, + deleg.qself.as_ref(), &deleg.prefix, deleg.suffixes.as_ref().map_or(DelegationKind::Glob, |s| DelegationKind::List(s)), - &deleg.body, + deleg.body.as_ref(), ), } self.ann.post(self, AnnNode::SubItem(id)) @@ -604,10 +604,10 @@ impl<'a> State<'a> { &mut self, attrs: &[ast::Attribute], vis: &ast::Visibility, - qself: &Option>, + qself: Option<&P>, path: &ast::Path, kind: DelegationKind<'_>, - body: &Option>, + body: Option<&P>, ) { if body.is_some() { self.head(""); diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 8e5944d6cf45e..041a1500687bd 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2939,7 +2939,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { span, .. }, - ) => self.report_escaping_data(borrow_span, &name, upvar_span, upvar_name, span), + ) => self.report_escaping_data( + borrow_span, + name.as_deref(), + upvar_span, + upvar_name, + span, + ), (Some(name), explanation) => self.report_local_value_does_not_live_long_enough( location, &name, @@ -2992,7 +2998,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { borrow_span, span, category, - opt_place_desc.as_ref(), + opt_place_desc.as_deref(), ) { return diag; } @@ -3335,7 +3341,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { borrow_span: Span, return_span: Span, category: ConstraintCategory<'tcx>, - opt_place_desc: Option<&String>, + opt_place_desc: Option<&str>, ) -> Result<(), Diag<'infcx>> { let return_kind = match category { ConstraintCategory::Return(_) => "return", @@ -3538,7 +3544,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { fn report_escaping_data( &self, borrow_span: Span, - name: &Option, + name: Option<&str>, upvar_span: Span, upvar_name: Symbol, escape_span: Span, diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 8b968177c3c09..2ede570596db9 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -217,12 +217,19 @@ fn do_mir_borrowck<'tcx>( // Dump MIR results into a file, if that is enabled. This let us // write unit-tests, as well as helping with debugging. - nll::dump_nll_mir(&infcx, body, ®ioncx, &opt_closure_req, &borrow_set); + nll::dump_nll_mir(&infcx, body, ®ioncx, opt_closure_req.as_ref(), &borrow_set); // We also have a `#[rustc_regions]` annotation that causes us to dump // information. let diags = &mut diags::BorrowckDiags::new(); - nll::dump_annotation(&infcx, body, ®ioncx, &opt_closure_req, &opaque_type_values, diags); + nll::dump_annotation( + &infcx, + body, + ®ioncx, + opt_closure_req.as_ref(), + &opaque_type_values, + diags, + ); let movable_coroutine = // The first argument is the coroutine type passed by value diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index abe27555b1864..9e0f2db5bf569 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -205,7 +205,7 @@ pub(super) fn dump_nll_mir<'tcx>( infcx: &BorrowckInferCtxt<'tcx>, body: &Body<'tcx>, regioncx: &RegionInferenceContext<'tcx>, - closure_region_requirements: &Option>, + closure_region_requirements: Option<&ClosureRegionRequirements<'tcx>>, borrow_set: &BorrowSet<'tcx>, ) { let tcx = infcx.tcx; @@ -251,7 +251,7 @@ pub(super) fn dump_nll_mir<'tcx>( pub(crate) fn emit_nll_mir<'tcx>( tcx: TyCtxt<'tcx>, regioncx: &RegionInferenceContext<'tcx>, - closure_region_requirements: &Option>, + closure_region_requirements: Option<&ClosureRegionRequirements<'tcx>>, borrow_set: &BorrowSet<'tcx>, pass_where: PassWhere, out: &mut dyn io::Write, @@ -298,7 +298,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>( infcx: &'infcx BorrowckInferCtxt<'tcx>, body: &Body<'tcx>, regioncx: &RegionInferenceContext<'tcx>, - closure_region_requirements: &Option>, + closure_region_requirements: Option<&ClosureRegionRequirements<'tcx>>, opaque_type_values: &FxIndexMap>, diags: &mut crate::diags::BorrowckDiags<'infcx, 'tcx>, ) { diff --git a/compiler/rustc_borrowck/src/polonius/dump.rs b/compiler/rustc_borrowck/src/polonius/dump.rs index a6d8014903440..48219c2d44fc9 100644 --- a/compiler/rustc_borrowck/src/polonius/dump.rs +++ b/compiler/rustc_borrowck/src/polonius/dump.rs @@ -74,7 +74,7 @@ fn emit_polonius_mir<'tcx>( crate::nll::emit_nll_mir( tcx, regioncx, - closure_region_requirements, + closure_region_requirements.as_ref(), borrow_set, pass_where.clone(), out, diff --git a/compiler/rustc_codegen_gcc/build_system/src/utils.rs b/compiler/rustc_codegen_gcc/build_system/src/utils.rs index 401c23948e5d3..9721c5fe879ba 100644 --- a/compiler/rustc_codegen_gcc/build_system/src/utils.rs +++ b/compiler/rustc_codegen_gcc/build_system/src/utils.rs @@ -21,9 +21,9 @@ fn exec_command( ) -> Result { let status = get_command_inner(input, cwd, env) .spawn() - .map_err(|e| command_error(input, &cwd, e))? + .map_err(|e| command_error(input, cwd, e))? .wait() - .map_err(|e| command_error(input, &cwd, e))?; + .map_err(|e| command_error(input, cwd, e))?; #[cfg(unix)] { if let Some(signal) = status.signal() { @@ -31,7 +31,7 @@ fn exec_command( raise(signal as _); } // In case the signal didn't kill the current process. - return Err(command_error(input, &cwd, format!("Process received signal {}", signal))); + return Err(command_error(input, cwd, format!("Process received signal {}", signal))); } } Ok(status) @@ -92,7 +92,7 @@ fn check_exit_status( Err(error) } -fn command_error(input: &[&dyn AsRef], cwd: &Option<&Path>, error: D) -> String { +fn command_error(input: &[&dyn AsRef], cwd: Option<&Path>, error: D) -> String { format!( "Command `{}`{} failed to run: {error:?}", input.iter().map(|s| s.as_ref().to_str().unwrap()).collect::>().join(" "), @@ -112,7 +112,7 @@ pub fn run_command_with_env( env: Option<&HashMap>, ) -> Result { let output = - get_command_inner(input, cwd, env).output().map_err(|e| command_error(input, &cwd, e))?; + get_command_inner(input, cwd, env).output().map_err(|e| command_error(input, cwd, e))?; check_exit_status(input, cwd, output.status, Some(&output), true)?; Ok(output) } diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index 9a142326ad196..9446e5b1604a2 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -379,7 +379,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { gcc_func, args.into(), &func_name, - original_function_name, + original_function_name.map(String::as_str), ) }; let args_adjusted = args.len() != previous_arg_count; diff --git a/compiler/rustc_codegen_gcc/src/debuginfo.rs b/compiler/rustc_codegen_gcc/src/debuginfo.rs index 6aeb656c1ab40..18d939afac71b 100644 --- a/compiler/rustc_codegen_gcc/src/debuginfo.rs +++ b/compiler/rustc_codegen_gcc/src/debuginfo.rs @@ -86,7 +86,15 @@ fn compute_mir_scopes<'gcc, 'tcx>( // Instantiate all scopes. for idx in 0..mir.source_scopes.len() { let scope = SourceScope::new(idx); - make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); + make_mir_scope( + cx, + instance, + mir, + variables.as_ref(), + debug_context, + &mut instantiated, + scope, + ); } assert!(instantiated.count() == mir.source_scopes.len()); } @@ -101,7 +109,7 @@ fn make_mir_scope<'gcc, 'tcx>( cx: &CodegenCx<'gcc, 'tcx>, _instance: Instance<'tcx>, mir: &Body<'tcx>, - variables: &Option>, + variables: Option<&BitSet>, debug_context: &mut FunctionDebugContext<'tcx, (), Location<'gcc>>, instantiated: &mut BitSet, scope: SourceScope, @@ -126,7 +134,7 @@ fn make_mir_scope<'gcc, 'tcx>( return; }; - if let Some(ref vars) = *variables { + if let Some(vars) = variables { if !vars.contains(scope) && scope_data.inlined.is_none() { // Do not create a DIScope if there are no variables defined in this // MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat. diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs b/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs index 0a448ded6b1ae..e6319e98e909f 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs @@ -43,7 +43,7 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>( gcc_func: FunctionPtrType<'gcc>, mut args: Cow<'b, [RValue<'gcc>]>, func_name: &str, - original_function_name: Option<&String>, + original_function_name: Option<&str>, ) -> Cow<'b, [RValue<'gcc>]> { // TODO: this might not be a good way to workaround the missing tile builtins. if func_name == "__builtin_trap" { @@ -546,7 +546,7 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>( | "__builtin_ia32_vfmaddsubps256" | "__builtin_ia32_vfmaddsubpd" => { if let Some(original_function_name) = original_function_name { - match &**original_function_name { + match original_function_name { "llvm.x86.fma.vfmsubadd.pd.256" | "llvm.x86.fma.vfmsubadd.ps" | "llvm.x86.fma.vfmsubadd.ps.256" diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index f8454fd9960b6..6ec94cee28935 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -533,6 +533,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( attributes::apply_to_llfn(llfn, Function, &to_add); } -fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option<&String> { - tcx.wasm_import_module_map(id.krate).get(&id) +fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option<&str> { + tcx.wasm_import_module_map(id.krate).get(&id).map(String::as_str) } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs index 07bd0f4d1c171..bf5fb3b58bad1 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs @@ -49,7 +49,7 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( cx, instance, mir, - &variables, + variables.as_ref(), debug_context, &mut instantiated, &mut discriminators, @@ -63,7 +63,7 @@ fn make_mir_scope<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>, mir: &Body<'tcx>, - variables: &Option>, + variables: Option<&BitSet>, debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, instantiated: &mut BitSet, discriminators: &mut FxHashMap, diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index b337e27940022..70955b8faea6b 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -63,7 +63,7 @@ impl Emitter for AnnotateSnippetEmitter { &diag.level, &diag.messages, &fluent_args, - &diag.code, + diag.code, &diag.span, &diag.children, &suggestions, @@ -131,7 +131,7 @@ impl AnnotateSnippetEmitter { level: &Level, messages: &[(DiagMessage, Style)], args: &FluentArgs<'_>, - code: &Option, + code: Option, msp: &MultiSpan, _children: &[Subdiag], _suggestions: &[CodeSuggestion], diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 05b9cbfbc0664..d8d7b7b310b41 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -401,23 +401,23 @@ impl DiagInner { ) -> ( &Level, &[(DiagMessage, Style)], - &Option, + Option, &MultiSpan, &[Subdiag], &Suggestions, Vec<(&DiagArgName, &DiagArgValue)>, - &Option, + Option<&IsLint>, ) { ( &self.level, &self.messages, - &self.code, + self.code, &self.span, &self.children, &self.suggestions, self.args.iter().collect(), // omit self.sort_span - &self.is_lint, + self.is_lint.as_ref(), // omit self.emitted_at ) } diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 977721a5b8a2d..309dc170910c4 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -519,7 +519,7 @@ impl Emitter for HumanEmitter { &diag.level, &diag.messages, &fluent_args, - &diag.code, + diag.code, &diag.span, &diag.children, &suggestions, @@ -1391,7 +1391,7 @@ impl HumanEmitter { msp: &MultiSpan, msgs: &[(DiagMessage, Style)], args: &FluentArgs<'_>, - code: &Option, + code: Option, level: &Level, max_line_num_len: usize, is_secondary: bool, @@ -2322,7 +2322,7 @@ impl HumanEmitter { level: &Level, messages: &[(DiagMessage, Style)], args: &FluentArgs<'_>, - code: &Option, + code: Option, span: &MultiSpan, children: &[Subdiag], suggestions: &[CodeSuggestion], @@ -2385,7 +2385,7 @@ impl HumanEmitter { span, &child.messages, args, - &None, + None, &child.level, max_line_num_len, true, @@ -2405,7 +2405,7 @@ impl HumanEmitter { &MultiSpan::new(), &[(sugg.msg.to_owned(), Style::HeaderMsg)], args, - &None, + None, &Level::Help, max_line_num_len, true, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 3cddc9642bae2..180a78592e3fe 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -268,7 +268,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<() match header.map(|h| h.polarity) { // `None` means this is an inherent impl Some(ty::ImplPolarity::Positive) | None => { - res = res.and(check_impl(tcx, item, impl_.self_ty, &impl_.of_trait)); + res = res.and(check_impl(tcx, item, impl_.self_ty, impl_.of_trait.as_ref())); } Some(ty::ImplPolarity::Negative) => { let ast::ImplPolarity::Negative(span) = impl_.polarity else { @@ -1341,7 +1341,7 @@ fn check_impl<'tcx>( tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>, hir_self_ty: &hir::Ty<'_>, - hir_trait_ref: &Option>, + hir_trait_ref: Option<&hir::TraitRef<'_>>, ) -> Result<(), ErrorGuaranteed> { enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| { match hir_trait_ref { diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index 569034954c3db..3c423e736164f 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -235,7 +235,7 @@ fn dump_graph(query: &DepGraphQuery) { EdgeFilter::new(&string).unwrap_or_else(|e| bug!("invalid filter: {}", e)); let sources = node_set(query, &edge_filter.source); let targets = node_set(query, &edge_filter.target); - filter_nodes(query, &sources, &targets) + filter_nodes(query, sources.as_ref(), targets.as_ref()) } Err(_) => query.nodes().into_iter().map(|n| n.kind).collect(), }; @@ -317,8 +317,8 @@ fn node_set<'q>( fn filter_nodes<'q>( query: &'q DepGraphQuery, - sources: &Option>, - targets: &Option>, + sources: Option<&FxIndexSet<&'q DepNode>>, + targets: Option<&FxIndexSet<&'q DepNode>>, ) -> FxIndexSet { if let Some(sources) = sources { if let Some(targets) = targets { diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 7b17966343084..0a8eb7217c18a 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -96,7 +96,7 @@ use std::cmp; use std::collections::hash_map::Entry; use std::fs::{self, File}; use std::io::Write; -use std::path::{Path, PathBuf}; +use std::path::Path; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::sync; @@ -1179,7 +1179,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co // Output monomorphization stats per def_id if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats { if let Err(err) = - dump_mono_items_stats(tcx, codegen_units, path, tcx.crate_name(LOCAL_CRATE)) + dump_mono_items_stats(tcx, codegen_units, path.as_deref(), tcx.crate_name(LOCAL_CRATE)) { tcx.dcx().emit_fatal(CouldntDumpMonoStats { error: err.to_string() }); } @@ -1244,7 +1244,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co fn dump_mono_items_stats<'tcx>( tcx: TyCtxt<'tcx>, codegen_units: &[CodegenUnit<'tcx>], - output_directory: &Option, + output_directory: Option<&Path>, crate_name: Symbol, ) -> Result<(), Box> { let output_directory = if let Some(ref directory) = output_directory { diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 7533e75ffe261..2c2e01cdb3db9 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1618,7 +1618,7 @@ impl<'a> Parser<'a> { let mac = P(MacCall { path, args: self.parse_delim_args()? }); (lo.to(self.prev_token.span), ExprKind::MacCall(mac)) } else if self.check(exp!(OpenBrace)) - && let Some(expr) = self.maybe_parse_struct_expr(&qself, &path) + && let Some(expr) = self.maybe_parse_struct_expr(qself.as_ref(), &path) { if qself.is_some() { self.psess.gated_spans.gate(sym::more_qualified_paths, path.span); @@ -3487,7 +3487,7 @@ impl<'a> Parser<'a> { fn maybe_parse_struct_expr( &mut self, - qself: &Option>, + qself: Option<&P>, path: &ast::Path, ) -> Option>> { let struct_allowed = !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL); @@ -3495,7 +3495,7 @@ impl<'a> Parser<'a> { if let Err(err) = self.expect(exp!(OpenBrace)) { return Some(Err(err)); } - let expr = self.parse_expr_struct(qself.clone(), path.clone(), true); + let expr = self.parse_expr_struct(qself.cloned(), path.clone(), true); if let (Ok(expr), false) = (&expr, struct_allowed) { // This is a struct literal, but we don't can't accept them here. self.dcx().emit_err(errors::StructLiteralNotAllowedHere { diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index a4fb0a5b07220..f0bae2ee75e40 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -498,7 +498,7 @@ impl EncoderState { node: DepNode, edge_count: usize, edges: impl FnOnce(&mut Self) -> Vec, - record_graph: &Option>, + record_graph: Option<&Lock>, ) -> DepNodeIndex { let index = DepNodeIndex::new(self.total_node_count); @@ -538,7 +538,7 @@ impl EncoderState { fn encode_node( &mut self, node: &NodeInfo, - record_graph: &Option>, + record_graph: Option<&Lock>, ) -> DepNodeIndex { node.encode::(&mut self.encoder); self.record(node.node, node.edges.len(), |_| node.edges[..].to_vec(), record_graph) @@ -554,7 +554,7 @@ impl EncoderState { fn encode_promoted_node( &mut self, prev_index: SerializedDepNodeIndex, - record_graph: &Option>, + record_graph: Option<&Lock>, prev_index_to_index: &IndexVec>, ) -> DepNodeIndex { let node = self.previous.index_to_node(prev_index); @@ -704,7 +704,7 @@ impl GraphEncoder { ) -> DepNodeIndex { let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph"); let node = NodeInfo { node, fingerprint, edges }; - self.status.lock().as_mut().unwrap().encode_node(&node, &self.record_graph) + self.status.lock().as_mut().unwrap().encode_node(&node, self.record_graph.as_ref()) } /// Encodes a node that was promoted from the previous graph. It reads the information directly from @@ -718,7 +718,7 @@ impl GraphEncoder { let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph"); self.status.lock().as_mut().unwrap().encode_promoted_node( prev_index, - &self.record_graph, + self.record_graph.as_ref(), prev_index_to_index, ) } diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 2a7d759ab3576..acd27563094e8 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -100,12 +100,12 @@ impl QueryJobId { pub(super) fn find_cycle_in_stack( &self, query_map: QueryMap, - current_job: &Option, + current_job: Option<&QueryJobId>, span: Span, ) -> CycleError { // Find the waitee amongst `current_job` parents let mut cycle = Vec::new(); - let mut current_job = Option::clone(current_job); + let mut current_job = current_job.cloned(); while let Some(job) = current_job { let info = query_map.get(&job).unwrap(); diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 6fb5e37d2d066..1f166a8ae2f3d 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -254,8 +254,11 @@ where Q: QueryConfig, Qcx: QueryContext, { - let error = - try_execute.find_cycle_in_stack(qcx.collect_active_jobs(), &qcx.current_query_job(), span); + let error = try_execute.find_cycle_in_stack( + qcx.collect_active_jobs(), + qcx.current_query_job().as_ref(), + span, + ); (mk_cycle(query, qcx, error), None) } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 7324d3fe7862d..8608261e7ca46 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -810,7 +810,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r PathSource::Type }; - self.smart_resolve_path(ty.id, qself, path, source); + self.smart_resolve_path(ty.id, qself.as_ref(), path, source); // Check whether we should interpret this as a bare trait object. if qself.is_none() @@ -941,7 +941,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r this.visit_generic_params(&tref.bound_generic_params, false); this.smart_resolve_path( tref.trait_ref.ref_id, - &None, + None, &tref.trait_ref.path, PathSource::Trait(AliasPossibility::Maybe), ); @@ -1135,14 +1135,14 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r if !check_ns(TypeNS) && check_ns(ValueNS) { self.smart_resolve_path( *id, - &None, + None, path, PathSource::PreciseCapturingArg(ValueNS), ); } else { self.smart_resolve_path( *id, - &None, + None, path, PathSource::PreciseCapturingArg(TypeNS), ); @@ -1197,7 +1197,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r |this| { this.smart_resolve_path( ty.id, - &None, + None, path, PathSource::Expr(None), ); @@ -1358,7 +1358,12 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r self.with_rib(ValueNS, RibKind::InlineAsmSym, |this| { this.with_rib(TypeNS, RibKind::InlineAsmSym, |this| { this.with_label_rib(RibKind::InlineAsmSym, |this| { - this.smart_resolve_path(sym.id, &sym.qself, &sym.path, PathSource::Expr(None)); + this.smart_resolve_path( + sym.id, + sym.qself.as_ref(), + &sym.path, + PathSource::Expr(None), + ); visit::walk_inline_asm_sym(this, sym); }); }) @@ -3120,7 +3125,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.diag_metadata.currently_processing_impl_trait = Some((trait_ref.clone(), self_type.clone())); let res = self.smart_resolve_path_fragment( - &None, + None, &path, PathSource::Trait(AliasPossibility::No), Finalize::new(trait_ref.ref_id, trait_ref.path.span), @@ -3497,7 +3502,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { fn resolve_delegation(&mut self, delegation: &'ast Delegation) { self.smart_resolve_path( delegation.id, - &delegation.qself, + delegation.qself.as_ref(), &delegation.path, PathSource::Delegation, ); @@ -3804,7 +3809,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { PatKind::TupleStruct(ref qself, ref path, ref sub_patterns) => { self.smart_resolve_path( pat.id, - qself, + qself.as_ref(), path, PathSource::TupleStruct( pat.span, @@ -3813,10 +3818,10 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { ); } PatKind::Path(ref qself, ref path) => { - self.smart_resolve_path(pat.id, qself, path, PathSource::Pat); + self.smart_resolve_path(pat.id, qself.as_ref(), path, PathSource::Pat); } PatKind::Struct(ref qself, ref path, ref _fields, ref rest) => { - self.smart_resolve_path(pat.id, qself, path, PathSource::Struct); + self.smart_resolve_path(pat.id, qself.as_ref(), path, PathSource::Struct); self.record_patterns_with_skipped_bindings(pat, rest); } PatKind::Or(ref ps) => { @@ -4034,7 +4039,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { fn smart_resolve_path( &mut self, id: NodeId, - qself: &Option>, + qself: Option<&P>, path: &Path, source: PathSource<'ast>, ) { @@ -4050,7 +4055,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { #[instrument(level = "debug", skip(self))] fn smart_resolve_path_fragment( &mut self, - qself: &Option>, + qself: Option<&P>, path: &[Segment], source: PathSource<'ast>, finalize: Finalize, @@ -4335,7 +4340,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Resolve in alternative namespaces if resolution in the primary namespace fails. fn resolve_qpath_anywhere( &mut self, - qself: &Option>, + qself: Option<&P>, path: &[Segment], primary_ns: Namespace, span: Span, @@ -4379,7 +4384,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { /// Handles paths that may refer to associated items. fn resolve_qpath( &mut self, - qself: &Option>, + qself: Option<&P>, path: &[Segment], ns: Namespace, finalize: Finalize, @@ -4403,7 +4408,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let num_privacy_errors = self.r.privacy_errors.len(); // Make sure that `A` in `::B::C` is a trait. let trait_res = self.smart_resolve_path_fragment( - &None, + None, &path[..qself.position], PathSource::Trait(AliasPossibility::No), Finalize::new(finalize.node_id, qself.path_span), @@ -4427,7 +4432,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // but with `qself` set to `None`. let ns = if qself.position + 1 == path.len() { ns } else { TypeNS }; let partial_res = self.smart_resolve_path_fragment( - &None, + None, &path[..=qself.position], PathSource::TraitItem(ns), Finalize::with_root_span(finalize.node_id, finalize.path_span, qself.path_span), @@ -4659,12 +4664,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Next, resolve the node. match expr.kind { ExprKind::Path(ref qself, ref path) => { - self.smart_resolve_path(expr.id, qself, path, PathSource::Expr(parent)); + self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent)); visit::walk_expr(self, expr); } ExprKind::Struct(ref se) => { - self.smart_resolve_path(expr.id, &se.qself, &se.path, PathSource::Struct); + self.smart_resolve_path(expr.id, se.qself.as_ref(), &se.path, PathSource::Struct); // This is the same as `visit::walk_expr(self, expr);`, but we want to pass the // parent in for accurate suggestions when encountering `Foo { bar }` that should // have been `Foo { bar: self.bar }`. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 5c36c98649020..8b916a8dc52d1 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2131,11 +2131,11 @@ fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInf fn parse_assert_incr_state( early_dcx: &EarlyDiagCtxt, - opt_assertion: &Option, + opt_assertion: Option<&str>, ) -> Option { match opt_assertion { - Some(s) if s.as_str() == "loaded" => Some(IncrementalStateAssertion::Loaded), - Some(s) if s.as_str() == "not-loaded" => Some(IncrementalStateAssertion::NotLoaded), + Some("loaded") => Some(IncrementalStateAssertion::Loaded), + Some("not-loaded") => Some(IncrementalStateAssertion::NotLoaded), Some(s) => { early_dcx.early_fatal(format!("unexpected incremental state assertion value: {s}")) } @@ -2366,7 +2366,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M let incremental = cg.incremental.as_ref().map(PathBuf::from); - let assert_incr_state = parse_assert_incr_state(early_dcx, &unstable_opts.assert_incr_state); + let assert_incr_state = + parse_assert_incr_state(early_dcx, unstable_opts.assert_incr_state.as_deref()); if cg.profile_generate.enabled() && cg.profile_use.is_some() { early_dcx.early_fatal("options `-C profile-generate` and `-C profile-use` are exclusive");