Skip to content

remove mutability of fn args that don't need it #114996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
/// When encountering an equality constraint in a `where` clause, emit an error. If the code seems
/// like it's setting an associated type, provide an appropriate suggestion.
fn deny_equality_constraints(
this: &mut AstValidator<'_>,
this: &AstValidator<'_>,
predicate: &WhereEqPredicate,
generics: &Generics,
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,7 @@ enum AnnotatedBorrowFnSignature<'tcx> {
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
/// Annotate the provided diagnostic with information about borrow from the fn signature that
/// helps explain.
pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diagnostic) -> String {
pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diagnostic) -> String {
match self {
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
diag.span_label(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(super) fn populate_access_facts<'a, 'tcx>(
body: &Body<'tcx>,
location_table: &LocationTable,
move_data: &MoveData<'tcx>,
dropped_at: &mut Vec<(Local, Location)>,
dropped_at: &Vec<(Local, Location)>,
) {
debug!("populate_access_facts()");

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
});
}

fn compute_drop_data(
typeck: &mut TypeChecker<'_, 'tcx>,
dropped_ty: Ty<'tcx>,
) -> DropData<'tcx> {
fn compute_drop_data(typeck: &TypeChecker<'_, 'tcx>, dropped_ty: Ty<'tcx>) -> DropData<'tcx> {
debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,);

match typeck
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct AsmArgs {
}

fn parse_args<'a>(
ecx: &mut ExtCtxt<'a>,
ecx: &ExtCtxt<'a>,
sp: Span,
tts: TokenStream,
is_global_asm: bool,
Expand Down Expand Up @@ -295,7 +295,7 @@ pub fn parse_asm_args<'a>(
///
/// This function must be called immediately after the option token is parsed.
/// Otherwise, the suggestion will be incorrect.
fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) {
fn err_duplicate_option(p: &Parser<'_>, symbol: Symbol, span: Span) {
// Tool-only output
let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span };
p.sess.span_diagnostic.emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span });
Expand All @@ -307,7 +307,7 @@ fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) {
/// This function must be called immediately after the option token is parsed.
/// Otherwise, the error will not point to the correct spot.
fn try_set_option<'a>(
p: &mut Parser<'a>,
p: &Parser<'a>,
args: &mut AsmArgs,
symbol: Symbol,
option: ast::InlineAsmOptions,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn expr_if_not(
cx.expr_if(span, cx.expr(span, ExprKind::Unary(UnOp::Not, cond)), then, els)
}

fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<'a, Assert> {
fn parse_assert<'a>(cx: &ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<'a, Assert> {
let mut parser = cx.new_parser_from_tts(stream);

if parser.token == token::Eof {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn expand_cfg(
}
}

fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
let mut p = cx.new_parser_from_tts(tts);

if p.token == token::Eof {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_accessible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_span::Span;

pub(crate) struct Expander;

fn validate_input<'a>(ecx: &mut ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {
fn validate_input<'a>(ecx: &ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {
use errors::CfgAccessibleInvalid::*;
match mi.meta_item_list() {
None => {}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::errors;

/// Emits errors for literal expressions that are invalid inside and outside of an array.
fn invalid_type_err(
cx: &mut base::ExtCtxt<'_>,
cx: &base::ExtCtxt<'_>,
token_lit: ast::token::Lit,
span: Span,
is_nested: bool,
Expand Down Expand Up @@ -67,7 +67,7 @@ fn invalid_type_err(
}

fn handle_array_element(
cx: &mut base::ExtCtxt<'_>,
cx: &base::ExtCtxt<'_>,
has_errors: &mut bool,
missing_literals: &mut Vec<rustc_span::Span>,
expr: &P<rustc_ast::Expr>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn expand_deriving_clone(

fn cs_clone_simple(
name: &str,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
is_union: bool,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn expand_deriving_eq(
}

fn cs_total_eq_assert(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
) -> BlockOrExpr {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn expand_deriving_debug(
trait_def.expand(cx, mitem, item, push)
}

fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
// We want to make sure we have the ctxt set so that we can use unstable methods
let span = cx.with_def_site_ctxt(span);

Expand Down Expand Up @@ -210,7 +210,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
/// }
/// ```
fn show_fieldless_enum(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
span: Span,
def: &EnumDef,
substr: &Substructure<'_>,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn expand_deriving_default(
}

fn default_struct_substructure(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
summary: &StaticFields,
Expand All @@ -79,7 +79,7 @@ fn default_struct_substructure(
}

fn default_enum_substructure(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_span: Span,
enum_def: &EnumDef,
) -> BlockOrExpr {
Expand All @@ -98,7 +98,7 @@ fn default_enum_substructure(
}

fn extract_default_variant<'a>(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
enum_def: &'a EnumDef,
trait_span: Span,
) -> Result<&'a rustc_ast::Variant, ()> {
Expand Down Expand Up @@ -169,7 +169,7 @@ fn extract_default_variant<'a>(
}

fn validate_default_attribute(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
default_variant: &rustc_ast::Variant,
) -> Result<(), ()> {
let attrs: SmallVec<[_; 1]> =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn expand_deriving_rustc_encodable(
}

fn encodable_substructure(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
krate: Symbol,
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl<'a> TraitDef<'a> {
/// therefore does not get bound by the derived trait.
fn create_derived_impl(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
type_ident: Ident,
generics: &Generics,
field_tys: Vec<P<ast::Ty>>,
Expand Down Expand Up @@ -910,7 +910,7 @@ impl<'a> MethodDef<'a> {

fn get_ret_ty(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
generics: &Generics,
type_ident: Ident,
Expand All @@ -931,7 +931,7 @@ impl<'a> MethodDef<'a> {
// `&self`.
fn extract_arg_details(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
type_ident: Ident,
generics: &Generics,
Expand Down Expand Up @@ -967,7 +967,7 @@ impl<'a> MethodDef<'a> {

fn create_method(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
type_ident: Ident,
generics: &Generics,
Expand Down Expand Up @@ -1406,7 +1406,7 @@ impl<'a> MethodDef<'a> {

// general helper methods.
impl<'a> TraitDef<'a> {
fn summarise_struct(&self, cx: &mut ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
fn summarise_struct(&self, cx: &ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
let mut named_idents = Vec::new();
let mut just_spans = Vec::new();
for field in struct_def.fields() {
Expand All @@ -1433,7 +1433,7 @@ impl<'a> TraitDef<'a> {

fn create_struct_patterns(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
struct_path: ast::Path,
struct_def: &'a VariantData,
prefixes: &[String],
Expand Down Expand Up @@ -1526,7 +1526,7 @@ impl<'a> TraitDef<'a> {

fn create_struct_pattern_fields(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
struct_def: &'a VariantData,
prefixes: &[String],
) -> Vec<FieldInfo> {
Expand All @@ -1543,7 +1543,7 @@ impl<'a> TraitDef<'a> {

fn create_struct_field_access_fields(
&self,
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
selflike_args: &[P<Expr>],
struct_def: &'a VariantData,
is_packed: bool,
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ pub fn expand_deriving_hash(
hash_trait_def.expand(cx, mitem, item, push);
}

fn hash_substructure(
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
) -> BlockOrExpr {
fn hash_substructure(cx: &ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let [state_expr] = substr.nonselflike_args else {
cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`");
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P<ast::Expr> {
// does *not* add `where T: Structural` for parameters `T` in `...`.
// (That's the main reason we cannot use TraitDef here.)
fn inject_impl_of_structural_trait(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
span: Span,
item: &Annotatable,
structural_path: generic::ty::Path,
Expand Down Expand Up @@ -211,7 +211,7 @@ fn inject_impl_of_structural_trait(
}

fn assert_ty_bounds(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
stmts: &mut ThinVec<ast::Stmt>,
ty: P<ast::Ty>,
span: Span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/edition_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn expand_unreachable<'cx>(

fn expand<'cx>(
mac: rustc_span::Symbol,
cx: &'cx mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
) -> Box<dyn MacResult + 'cx> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct MacroInput {
/// ```text
/// Ok((fmtstr, parsed arguments))
/// ```
fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
let mut args = FormatArguments::new();

let mut p = ecx.new_parser_from_tts(tts);
Expand Down Expand Up @@ -562,7 +562,7 @@ fn invalid_placeholder_type_error(
}

fn report_missing_placeholders(
ecx: &mut ExtCtxt<'_>,
ecx: &ExtCtxt<'_>,
unused: Vec<(Span, bool)>,
detect_foreign_fmt: bool,
str_style: Option<usize>,
Expand Down Expand Up @@ -674,7 +674,7 @@ fn report_missing_placeholders(
/// there are named arguments or numbered positional arguments in the
/// format string.
fn report_invalid_references(
ecx: &mut ExtCtxt<'_>,
ecx: &ExtCtxt<'_>,
invalid_refs: &[(usize, Option<Span>, PositionUsedAs, FormatArgPositionKind)],
template: &[FormatArgsPiece],
fmt_span: Span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn expand_bench(
}

pub fn expand_test_or_bench(
cx: &mut ExtCtxt<'_>,
cx: &ExtCtxt<'_>,
attr_sp: Span,
item: Annotatable,
is_bench: bool,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/type_ascribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn expand_type_ascribe(
return MacEager::expr(asc_expr);
}

fn parse_ascribe<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P<Expr>, P<Ty>)> {
fn parse_ascribe<'a>(cx: &ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P<Expr>, P<Ty>)> {
let mut parser = cx.new_parser_from_tts(stream);

let expr = parser.parse_expr()?;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::ModuleLlvm;

pub(crate) unsafe fn codegen(
tcx: TyCtxt<'_>,
module_llvm: &mut ModuleLlvm,
module_llvm: &ModuleLlvm,
module_name: &str,
kind: AllocatorKind,
alloc_error_handler_kind: AllocatorKind,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ fn thin_lto(
pub(crate) fn run_pass_manager(
cgcx: &CodegenContext<LlvmCodegenBackend>,
diag_handler: &Handler,
module: &mut ModuleCodegen<ModuleLlvm>,
module: &ModuleCodegen<ModuleLlvm>,
thin: bool,
) -> Result<(), FatalError> {
let _timer = cgcx.prof.verbose_generic_activity_with_arg("LLVM_lto_optimize", &*module.name);
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct RPathConfig<'a> {
pub linker_is_gnu: bool,
}

pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<OsString> {
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
// No rpath on windows
if !config.has_rpath {
return Vec::new();
Expand Down Expand Up @@ -53,7 +53,7 @@ fn rpaths_to_flags(rpaths: Vec<OsString>) -> Vec<OsString> {
ret
}

fn get_rpaths(config: &mut RPathConfig<'_>) -> Vec<OsString> {
fn get_rpaths(config: &RPathConfig<'_>) -> Vec<OsString> {
debug!("output: {:?}", config.out_filename.display());
debug!("libs:");
for libpath in config.libs {
Expand All @@ -74,11 +74,11 @@ fn get_rpaths(config: &mut RPathConfig<'_>) -> Vec<OsString> {
minimize_rpaths(&rpaths)
}

fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>) -> Vec<OsString> {
fn get_rpaths_relative_to_output(config: &RPathConfig<'_>) -> Vec<OsString> {
config.libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect()
}

fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> OsString {
fn get_rpath_relative_to_output(config: &RPathConfig<'_>, lib: &Path) -> OsString {
// Mac doesn't appear to support $ORIGIN
let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" };

Expand Down
Loading