Skip to content
Merged
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_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let predicates = match parent.kind {
hir::ExprKind::Call(callee, _) => {
let ty = typeck_result.node_type_opt(callee.hir_id)?;
let ty::FnDef(fn_def_id, args) = ty.kind() else { return None };
let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None };
tcx.predicates_of(fn_def_id).instantiate(tcx, args)
}
hir::ExprKind::MethodCall(..) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
_ => {
let local = &self.body.local_decls[local];
match local.local_info() {
match *local.local_info() {
LocalInfo::StaticRef { def_id, .. } => {
let span = self.infcx.tcx.def_span(def_id);
err.span_label(span, format!("this `static` cannot be {acted_on}"));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let tcx = self.infcx.tcx;

let ConstraintCategory::CallArgument(Some(func_ty)) = category else { return };
let ty::FnDef(fn_did, args) = func_ty.kind() else { return };
let ty::FnDef(fn_did, args) = *func_ty.kind() else { return };
debug!(?fn_did, ?args);

// Only suggest this on function calls, not closures
Expand All @@ -938,7 +938,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let Ok(Some(instance)) = ty::Instance::try_resolve(
tcx,
self.infcx.typing_env(self.infcx.param_env),
*fn_did,
fn_did,
self.infcx.resolve_vars_if_possible(args),
) else {
return;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let is_implicit_coercion = coercion_source == CoercionSource::Implicit;
let src_ty = op.ty(self.body, tcx);
let mut src_sig = src_ty.fn_sig(tcx);
if let ty::FnDef(def_id, _) = src_ty.kind()
if let ty::FnDef(def_id, _) = *src_ty.kind()
&& let ty::FnPtr(_, target_hdr) = *ty.kind()
&& tcx.codegen_fn_attrs(def_id).safe_target_features
&& target_hdr.safety.is_safe()
&& let Some(safe_sig) = tcx.adjust_target_feature_sig(
*def_id,
def_id,
src_sig,
self.body.source.def_id(),
)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {

Rvalue::Aggregate(kind, ..) => {
if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref()
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id)
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(*def_id)
{
self.check_op(ops::Coroutine(coroutine_kind));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ fn check_impl_items_against_trait<'tcx>(
match impl_trait_header.polarity {
ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
ty::ImplPolarity::Negative => {
if let [first_item_ref, ..] = impl_item_refs {
if let [first_item_ref, ..] = *impl_item_refs {
let first_item_span = tcx.def_span(first_item_ref);
struct_span_code_err!(
tcx.dcx(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ fn check_region_late_boundedness<'tcx>(
.iter()
.map(|param| {
let (LateEarlyMismatch::EarlyInImpl(impl_param_def_id, ..)
| LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = param;
| LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = *param;
tcx.def_span(impl_param_def_id)
})
.collect();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2445,12 +2445,12 @@ fn is_late_bound_map(
)) => {
// See comments on `ConstrainedCollectorPostHirTyLowering` for why this arm does not
// just consider args to be unconstrained.
let generics = self.tcx.generics_of(alias_def);
let generics = self.tcx.generics_of(*alias_def);
let mut walker = ConstrainedCollectorPostHirTyLowering {
arg_is_constrained: vec![false; generics.own_params.len()]
.into_boxed_slice(),
};
walker.visit_ty(self.tcx.type_of(alias_def).instantiate_identity());
walker.visit_ty(self.tcx.type_of(*alias_def).instantiate_identity());

match segments.last() {
Some(hir::PathSegment { args: Some(args), .. }) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if let [best_trait] = visible_traits
.iter()
.copied()
.filter(|trait_def_id| {
.filter(|&trait_def_id| {
tcx.associated_items(trait_def_id)
.filter_by_name_unhygienic(suggested_name)
.any(|item| item.tag() == assoc_tag)
Expand Down Expand Up @@ -1234,7 +1234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&& let name = Symbol::intern(&format!("{ident2}_{ident3}"))
&& let Some(item) = inherent_impls
.iter()
.flat_map(|inherent_impl| {
.flat_map(|&inherent_impl| {
tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name)
})
.next()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
let lifetimes_in_associated_types: FxHashSet<_> = tcx
.associated_item_def_ids(impl_def_id)
.iter()
.flat_map(|def_id| {
.flat_map(|&def_id| {
let item = tcx.associated_item(def_id);
match item.kind {
ty::AssocKind::Type { .. } => {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef);
}

match autoderef.final_ty().kind() {
match *autoderef.final_ty().kind() {
ty::FnDef(def_id, _) => {
let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi;
self.check_call_abi(abi, call_expr.span);
Expand Down Expand Up @@ -430,11 +430,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool {
if let ty::FnDef(def_id, _) = callee_ty.kind()
if let ty::FnDef(def_id, _) = *callee_ty.kind()
&& let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id)
{
self.tcx
.opt_parent(*def_id)
.opt_parent(def_id)
.and_then(|id| self.tcx.adt_def(id).repr().scalable)
.is_some()
} else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.tcx
.inherent_impls(def_id)
.into_iter()
.flat_map(|i| self.tcx.associated_items(i).in_definition_order())
.flat_map(|&i| self.tcx.associated_items(i).in_definition_order())
// Only assoc fn with no receivers.
.filter(|item| item.is_fn() && !item.is_method())
.filter_map(|item| {
Expand Down Expand Up @@ -3183,7 +3183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Check if there is an associated function with the same name.
if let Some(def_id) = base_ty.peel_refs().ty_adt_def().map(|d| d.did()) {
for impl_def_id in self.tcx.inherent_impls(def_id) {
for &impl_def_id in self.tcx.inherent_impls(def_id) {
for item in self.tcx.associated_items(impl_def_id).in_definition_order() {
if let ExprKind::Field(base_expr, _) = expr.kind
&& item.name() == field.name
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// error in `validate_res_from_ribs` -- it's just difficult to tell whether the
// self type has any generic types during rustc_resolve, which is what we use
// to determine if this is a hard error or warning.
if std::iter::successors(Some(self.body_id.to_def_id()), |def_id| {
if std::iter::successors(Some(self.body_id.to_def_id()), |&def_id| {
self.tcx.generics_of(def_id).parent
})
.all(|def_id| def_id != impl_def_id)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return false;
}
if self.may_coerce(Ty::new_box(self.tcx, found), expected) {
let suggest_boxing = match found.kind() {
let suggest_boxing = match *found.kind() {
ty::Tuple(tuple) if tuple.is_empty() => {
errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span }
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
.collect::<Vec<_>>();
if !inherent_impls_candidate.is_empty() {
inherent_impls_candidate.sort_by_key(|id| self.tcx.def_path_str(id));
inherent_impls_candidate.sort_by_key(|&id| self.tcx.def_path_str(id));
inherent_impls_candidate.dedup();

// number of types to show at most
Expand Down Expand Up @@ -2256,7 +2256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_args: Option<Vec<Ty<'tcx>>>,
) -> Option<Symbol> {
if let ty::Adt(adt, adt_args) = rcvr_ty.kind() {
for inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() {
for &inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() {
for inherent_method in
self.tcx.associated_items(inherent_impl_did).in_definition_order()
{
Expand Down Expand Up @@ -2315,7 +2315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sources: &mut Vec<CandidateSource>,
sugg_span: Option<Span>,
) {
sources.sort_by_key(|source| match source {
sources.sort_by_key(|source| match *source {
CandidateSource::Trait(id) => (0, self.tcx.def_path_str(id)),
CandidateSource::Impl(id) => (1, self.tcx.def_path_str(id)),
});
Expand Down Expand Up @@ -2468,7 +2468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.tcx
.inherent_impls(adt_def.did())
.iter()
.flat_map(|i| self.tcx.associated_items(i).in_definition_order())
.flat_map(|&i| self.tcx.associated_items(i).in_definition_order())
// Only assoc fn with no receivers and only if
// they are resolvable
.filter(|item| {
Expand Down Expand Up @@ -2521,7 +2521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
String::new()
};
match &items[..] {
match items[..] {
[] => {}
[(def_id, ret_ty)] => {
err.span_note(
Expand All @@ -2536,7 +2536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => {
let span: MultiSpan = items
.iter()
.map(|(def_id, _)| self.tcx.def_span(def_id))
.map(|&(def_id, _)| self.tcx.def_span(def_id))
.collect::<Vec<Span>>()
.into();
err.span_note(
Expand All @@ -2546,7 +2546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
following associated functions:\n{}{post}",
items
.iter()
.map(|(def_id, _ret_ty)| self.tcx.def_path_str(def_id))
.map(|&(def_id, _ret_ty)| self.tcx.def_path_str(def_id))
.collect::<Vec<String>>()
.join("\n")
),
Expand Down Expand Up @@ -3518,7 +3518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
traits.push(trait_pred.def_id());
}
}
traits.sort_by_key(|id| self.tcx.def_path_str(id));
traits.sort_by_key(|&id| self.tcx.def_path_str(id));
traits.dedup();

let len = traits.len();
Expand Down Expand Up @@ -3920,7 +3920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
valid_out_of_scope_traits.retain(|id| self.tcx.is_user_visible_dep(id.krate));
if !valid_out_of_scope_traits.is_empty() {
let mut candidates = valid_out_of_scope_traits;
candidates.sort_by_key(|id| self.tcx.def_path_str(id));
candidates.sort_by_key(|&id| self.tcx.def_path_str(id));
candidates.dedup();

// `TryFrom` and `FromIterator` have no methods
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx
.associated_item_def_ids(def_id)
.iter()
.find(|item_def_id| {
self.tcx.associated_item(*item_def_id).name() == sym::Output
.find(|&&item_def_id| {
self.tcx.associated_item(item_def_id).name() == sym::Output
})
.cloned()
});
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/impl_trait_overcaptures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where
return true;
};
// We only computed variance of lifetimes...
debug_assert_matches!(self.tcx.def_kind(def_id), DefKind::LifetimeParam);
debug_assert_matches!(self.tcx.def_kind(*def_id), DefKind::LifetimeParam);
let uncaptured = match *kind {
ParamKind::Early(name, index) => ty::Region::new_early_param(
self.tcx,
Expand Down Expand Up @@ -342,7 +342,7 @@ where

let uncaptured_spans: Vec<_> = uncaptured_args
.into_iter()
.map(|(def_id, _)| self.tcx.def_span(def_id))
.map(|(&def_id, _)| self.tcx.def_span(def_id))
.collect();

self.tcx.emit_node_span_lint(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ fn lint_ty_kind_usage(cx: &LateContext<'_>, res: &Res) -> bool {
}

fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &hir::Path<'_>) -> Option<String> {
match &path.res {
match path.res {
Res::Def(_, def_id) => {
if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(*def_id) {
if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(def_id) {
return Some(format!("{}{}", name, gen_args(path.segments.last().unwrap())));
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_middle/src/mir/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ where

let mirs = def_ids
.iter()
.filter(|def_id| !tcx.is_trivial_const(*def_id))
.flat_map(|def_id| {
if tcx.is_const_fn(*def_id) {
vec![tcx.optimized_mir(*def_id), tcx.mir_for_ctfe(*def_id)]
.filter(|&&def_id| !tcx.is_trivial_const(def_id))
.flat_map(|&def_id| {
if tcx.is_const_fn(def_id) {
vec![tcx.optimized_mir(def_id), tcx.mir_for_ctfe(def_id)]
} else {
vec![tcx.instance_mir(ty::InstanceKind::Item(*def_id))]
vec![tcx.instance_mir(ty::InstanceKind::Item(def_id))]
}
})
.collect::<Vec<_>>();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'tcx> GlobalAlloc<'tcx> {

pub fn mutability(&self, tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Mutability {
// Let's see what kind of memory we are.
match self {
match *self {
GlobalAlloc::Static(did) => {
let DefKind::Static { safety: _, mutability, nested } = tcx.def_kind(did) else {
bug!()
Expand Down Expand Up @@ -351,7 +351,7 @@ impl<'tcx> GlobalAlloc<'tcx> {
tcx: TyCtxt<'tcx>,
typing_env: ty::TypingEnv<'tcx>,
) -> (Size, Align) {
match self {
match *self {
GlobalAlloc::Static(def_id) => {
let DefKind::Static { nested, .. } = tcx.def_kind(def_id) else {
bug!("GlobalAlloc::Static is not a static")
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,6 @@ mod sealed {
}
}

impl<'a, P: Copy> IntoQueryParam<P> for &'a P {
#[inline(always)]
fn into_query_param(self) -> P {
*self
}
}

impl IntoQueryParam<LocalDefId> for OwnerId {
#[inline(always)]
fn into_query_param(self) -> LocalDefId {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ impl<'tcx> TyCtxt<'tcx> {

/// Given a `ty`, return whether it's an `impl Future<...>`.
pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool {
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *ty.kind() else { return false };
let future_trait = self.require_lang_item(LangItem::Future, DUMMY_SP);

self.explicit_item_self_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/significant_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn extract_component_with_significant_dtor<'tcx>(
/// when we are working with current local crate.
#[instrument(level = "trace", skip(tcx))]
pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> {
match ty.kind() {
match *ty.kind() {
ty::Bool
| ty::Char
| ty::Int(_)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl<'tcx> TyCtxt<'tcx> {
continue;
}

let Some(item_id) = self.associated_item_def_ids(impl_did).first() else {
let Some(&item_id) = self.associated_item_def_ids(impl_did).first() else {
self.dcx()
.span_delayed_bug(self.def_span(impl_did), "Drop impl without drop function");
continue;
Expand All @@ -435,7 +435,7 @@ impl<'tcx> TyCtxt<'tcx> {
.delay_as_bug();
}

dtor_candidate = Some(*item_id);
dtor_candidate = Some(item_id);
}

let did = dtor_candidate?;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Some intrinsics are handled here because they desperately want to avoid introducing
// unnecessary copies.
ExprKind::Call { ty, fun, ref args, .. }
if let ty::FnDef(def_id, generic_args) = ty.kind()
if let ty::FnDef(def_id, generic_args) = *ty.kind()
&& let Some(intrinsic) = this.tcx.intrinsic(def_id)
&& matches!(intrinsic.name, sym::write_via_move | sym::write_box_via_move) =>
{
Expand Down
Loading
Loading