Skip to content
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_lowering/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.arena.alloc(hir::LetStmt { hir_id, super_, ty, pat, init, els, span, source })
}

fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
fn lower_block_check_mode(&self, b: &BlockCheckMode) -> hir::BlockCheckMode {
match *b {
BlockCheckMode::Default => hir::BlockCheckMode::DefaultBlock,
BlockCheckMode::Unsafe(u) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
})
}

fn lower_delegation_generics(&mut self, span: Span) -> &'hir hir::Generics<'hir> {
fn lower_delegation_generics(&self, span: Span) -> &'hir hir::Generics<'hir> {
self.arena.alloc(hir::Generics {
params: &[],
predicates: &[],
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_delegation_sig(
&mut self,
&self,
sig_id: DefId,
decl: &'hir hir::FnDecl<'hir>,
span: Span,
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
})
}

pub(crate) fn lower_lit(&mut self, token_lit: &token::Lit, span: Span) -> hir::Lit {
pub(crate) fn lower_lit(&self, token_lit: &token::Lit, span: Span) -> hir::Lit {
let lit_kind = match LitKind::from_token_lit(*token_lit) {
Ok(lit_kind) => lit_kind,
Err(err) => {
Expand All @@ -435,19 +435,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
respan(self.lower_span(span), lit_kind)
}

fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
fn lower_unop(&self, u: UnOp) -> hir::UnOp {
match u {
UnOp::Deref => hir::UnOp::Deref,
UnOp::Not => hir::UnOp::Not,
UnOp::Neg => hir::UnOp::Neg,
}
}

fn lower_binop(&mut self, b: BinOp) -> BinOp {
fn lower_binop(&self, b: BinOp) -> BinOp {
Spanned { node: b.node, span: self.lower_span(b.span) }
}

fn lower_assign_op(&mut self, a: AssignOp) -> AssignOp {
fn lower_assign_op(&self, a: AssignOp) -> AssignOp {
Spanned { node: a.node, span: self.lower_span(a.span) }
}

Expand Down Expand Up @@ -681,7 +681,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::Arm { hir_id, pat, guard, body, span }
}

fn lower_capture_clause(&mut self, capture_clause: CaptureBy) -> CaptureBy {
fn lower_capture_clause(&self, capture_clause: CaptureBy) -> CaptureBy {
match capture_clause {
CaptureBy::Ref => CaptureBy::Ref,
CaptureBy::Use { use_kw } => CaptureBy::Use { use_kw: self.lower_span(use_kw) },
Expand Down Expand Up @@ -1103,7 +1103,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn closure_movability_for_fn(
&mut self,
&self,
decl: &FnDecl,
fn_decl_span: Span,
coroutine_kind: Option<hir::CoroutineKind>,
Expand Down Expand Up @@ -1133,7 +1133,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_closure_binder<'c>(
&mut self,
&self,
binder: &'c ClosureBinder,
) -> (hir::ClosureBinder, &'c [GenericParam]) {
let (binder, params) = match binder {
Expand Down Expand Up @@ -1283,7 +1283,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
/// if they are not tuple structs.
/// Type checking will take care of the full validation later.
fn extract_tuple_struct_path<'a>(
&mut self,
&self,
expr: &'a Expr,
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
if let ExprKind::Path(qself, path) = &expr.kind {
Expand All @@ -1305,7 +1305,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
/// if they are not unit structs.
/// Type checking will take care of the full validation later.
fn extract_unit_struct_path<'a>(
&mut self,
&self,
expr: &'a Expr,
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
if let ExprKind::Path(qself, path) = &expr.kind {
Expand Down Expand Up @@ -1589,7 +1589,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some(Label { ident: self.lower_ident(label.ident) })
}

fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
fn lower_loop_destination(&self, destination: Option<(NodeId, Label)>) -> hir::Destination {
let target_id = match destination {
Some((id, _)) => {
if let Some(loop_id) = self.resolver.get_label_res(id) {
Expand All @@ -1610,7 +1610,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::Destination { label, target_id }
}

fn lower_jump_destination(&mut self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
fn lower_jump_destination(&self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
if self.is_in_loop_condition && opt_label.is_none() {
hir::Destination {
label: None,
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.arena.alloc(item)
}

fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemId {
fn lower_foreign_item_ref(&self, i: &ForeignItem) -> hir::ForeignItemId {
hir::ForeignItemId { owner_id: self.owner_id(i.id) }
}

Expand Down Expand Up @@ -951,7 +951,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.arena.alloc(item)
}

fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemId {
fn lower_trait_item_ref(&self, i: &AssocItem) -> hir::TraitItemId {
hir::TraitItemId { owner_id: self.owner_id(i.id) }
}

Expand Down Expand Up @@ -1135,7 +1135,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.arena.alloc(item)
}

fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemId {
fn lower_impl_item_ref(&self, i: &AssocItem) -> hir::ImplItemId {
hir::ImplItemId { owner_id: self.owner_id(i.id) }
}

Expand Down Expand Up @@ -1582,7 +1582,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

pub(super) fn lower_fn_header(
&mut self,
&self,
h: FnHeader,
default_safety: hir::Safety,
attrs: &[hir::Attribute],
Expand Down Expand Up @@ -1613,7 +1613,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

pub(super) fn lower_abi(&mut self, abi_str: StrLit) -> ExternAbi {
pub(super) fn lower_abi(&self, abi_str: StrLit) -> ExternAbi {
let ast::StrLit { symbol_unescaped, span, .. } = abi_str;
let extern_abi = symbol_unescaped.as_str().parse().unwrap_or_else(|_| {
self.error_on_invalid_abi(abi_str);
Expand Down Expand Up @@ -1645,7 +1645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
extern_abi
}

pub(super) fn lower_extern(&mut self, ext: Extern) -> ExternAbi {
pub(super) fn lower_extern(&self, ext: Extern) -> ExternAbi {
match ext {
Extern::None => ExternAbi::Rust,
Extern::Implicit(_) => ExternAbi::FALLBACK,
Expand All @@ -1670,7 +1670,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
});
}

pub(super) fn lower_constness(&mut self, c: Const) -> hir::Constness {
pub(super) fn lower_constness(&self, c: Const) -> hir::Constness {
match c {
Const::Yes(_) => hir::Constness::Const,
Const::No => hir::Constness::NotConst,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

#[instrument(level = "trace", skip(self))]
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
fn lower_res(&self, res: Res<NodeId>) -> Res {
let res: Result<Res, ()> = res.apply_id(|id| {
let owner = self.current_hir_id_owner;
let local_id = self.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
Expand All @@ -748,11 +748,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
res.unwrap_or(Res::Err)
}

fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
fn expect_full_res(&self, id: NodeId) -> Res<NodeId> {
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
}

fn lower_import_res(&mut self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
fn lower_import_res(&self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
let per_ns = self.resolver.get_import_res(id);
let per_ns = per_ns.map(|res| res.map(|res| self.lower_res(res)));
if per_ns.is_empty() {
Expand Down Expand Up @@ -1595,7 +1595,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}))
}

fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
fn lower_fn_params_to_idents(&self, decl: &FnDecl) -> &'hir [Option<Ident>] {
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
PatKind::Missing => None,
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
Expand Down Expand Up @@ -2365,15 +2365,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}))
}

fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
fn lower_unsafe_source(&self, u: UnsafeSource) -> hir::UnsafeSource {
match u {
CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
UserProvided => hir::UnsafeSource::UserProvided,
}
}

fn lower_trait_bound_modifiers(
&mut self,
&self,
modifiers: TraitBoundModifiers,
) -> hir::TraitBoundModifiers {
let constness = match modifiers.constness {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

fn pat_wild_with_node_id_of(&mut self, p: &Pat, hir_id: hir::HirId) -> &'hir hir::Pat<'hir> {
fn pat_wild_with_node_id_of(&self, p: &Pat, hir_id: hir::HirId) -> &'hir hir::Pat<'hir> {
self.arena.alloc(self.pat_with_node_id_of(p, hir::PatKind::Wild, hir_id))
}

/// Construct a `Pat` with the `HirId` of `p.id` already lowered.
fn pat_with_node_id_of(
&mut self,
&self,
p: &Pat,
kind: hir::PatKind<'hir>,
hir_id: hir::HirId,
Expand All @@ -360,7 +360,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::PatKind::Wild
}

fn lower_range_end(&mut self, e: &RangeEnd, has_end: bool) -> hir::RangeEnd {
fn lower_range_end(&self, e: &RangeEnd, has_end: bool) -> hir::RangeEnd {
match *e {
RangeEnd::Excluded if has_end => hir::RangeEnd::Excluded,
// No end; so `X..` behaves like `RangeFrom`.
Expand Down
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 @@ -142,7 +142,7 @@ impl<'a> AstValidator<'a> {
}

fn check_type_alias_where_clause_location(
&mut self,
&self,
ty_alias: &TyAlias,
) -> Result<(), errors::WhereClauseBeforeTypeAlias> {
if ty_alias.ty.is_none() || !ty_alias.where_clauses.before.has_where_token {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn parse_cfg_entry<S: Stage>(
}

fn parse_cfg_entry_version<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
list: &MetaItemListParser<'_>,
meta_span: Span,
) -> Option<CfgEntry> {
Expand Down Expand Up @@ -119,7 +119,7 @@ fn parse_cfg_entry_version<S: Stage>(
}

fn parse_cfg_entry_target<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
list: &MetaItemListParser<'_>,
meta_span: Span,
) -> Option<CfgEntry> {
Expand Down Expand Up @@ -169,7 +169,7 @@ fn parse_name_value<S: Stage>(
name_span: Span,
value: Option<&NameValueParser>,
span: Span,
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
) -> Option<CfgEntry> {
try_gate_cfg(name, span, cx.sess(), cx.features_option());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcBuiltinMacroParser {
}

fn parse_derive_like<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
args: &ArgParser<'_>,
trait_name_mandatory: bool,
) -> Option<(Option<Symbol>, ThinVec<Symbol>)> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/prototype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<S: Stage> SingleAttributeParser<S> for CustomMirParser {
}

fn extract_value<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
key: Symbol,
arg: &ArgParser<'_>,
span: Span,
Expand Down Expand Up @@ -96,7 +96,7 @@ fn extract_value<S: Stage>(
}

fn parse_dialect<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
dialect: Option<(Symbol, Span)>,
failed: &mut bool,
) -> Option<(MirDialect, Span)> {
Expand All @@ -118,7 +118,7 @@ fn parse_dialect<S: Stage>(
}

fn parse_phase<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
phase: Option<(Symbol, Span)>,
failed: &mut bool,
) -> Option<(MirPhase, Span)> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ pub(crate) const ALL_TARGETS: &'static [MaybeWarn] = &[
/// `cx` is the context given to the attribute.
/// `args` is the parser for the attribute arguments.
pub(crate) fn parse_single_integer<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
cx: &AcceptContext<'_, '_, S>,
args: &ArgParser<'_>,
) -> Option<u128> {
let Some(list) = args.list() else {
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 @@ -3833,7 +3833,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.buffer_error(err);
}

fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diag<'_>) {
fn explain_deref_coercion(&self, loan: &BorrowData<'tcx>, err: &mut Diag<'_>) {
let tcx = self.infcx.tcx;
if let Some(Terminator { kind: TerminatorKind::Call { call_source, fn_span, .. }, .. }) =
&self.body[loan.reserve_location.block].terminator
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/find_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn find<'tcx>(
region_vid: RegionVid,
start_point: Location,
) -> Option<Cause> {
let mut uf = UseFinder { body, regioncx, tcx, region_vid, start_point };
let uf = UseFinder { body, regioncx, tcx, region_vid, start_point };

uf.find()
}
Expand All @@ -29,7 +29,7 @@ struct UseFinder<'a, 'tcx> {
}

impl<'a, 'tcx> UseFinder<'a, 'tcx> {
fn find(&mut self) -> Option<Cause> {
fn find(&self) -> Option<Cause> {
let mut queue = VecDeque::new();
let mut visited = FxIndexSet::default();

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.buffer_error(err);
}

fn has_ambiguous_copy(&mut self, ty: Ty<'tcx>) -> bool {
fn has_ambiguous_copy(&self, ty: Ty<'tcx>) -> bool {
let Some(copy_def_id) = self.infcx.tcx.lang_items().copy_trait() else { return false };

// Avoid bogus move errors because of an incoherent `Copy` impl.
self.infcx.type_implements_trait(copy_def_id, [ty], self.infcx.param_env).may_apply()
&& self.infcx.tcx.coherent_trait(copy_def_id).is_err()
}

fn report_cannot_move_from_static(&mut self, place: Place<'tcx>, span: Span) -> Diag<'infcx> {
fn report_cannot_move_from_static(&self, place: Place<'tcx>, span: Span) -> Diag<'infcx> {
let description = if place.projection.len() == 1 {
format!("static item {}", self.describe_any_place(place.as_ref()))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl OutlivesSuggestionBuilder {

/// Emit an intermediate note on the given `Diag` if the involved regions are suggestable.
pub(crate) fn intermediate_suggestion(
&mut self,
&self,
mbcx: &MirBorrowckCtxt<'_, '_, '_>,
errci: &ErrorConstraintInfo<'_>,
diag: &mut Diag<'_>,
Expand Down
Loading
Loading