Skip to content

Commit 1bac9b2

Browse files
authored
Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmease
Avoid taking reference of &TyKind It's already a ref anyways. Just a tiny cleanup here.
2 parents b8e8a10 + 48f43fa commit 1bac9b2

File tree

14 files changed

+18
-18
lines changed

14 files changed

+18
-18
lines changed

compiler/rustc_borrowck/src/borrowck_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
290290
ty: Ty<'_>,
291291
is_index: Option<bool>,
292292
) -> Diag<'infcx> {
293-
let type_name = match (&ty.kind(), is_index) {
293+
let type_name = match (ty.kind(), is_index) {
294294
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
295295
(&ty::Slice(_), _) => "slice",
296296
_ => span_bug!(move_from_span, "this path should not cause illegal move"),

compiler/rustc_borrowck/src/places_conflict.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn place_components_conflict<'tcx>(
201201

202202
let base_ty = base.ty(body, tcx).ty;
203203

204-
match (elem, &base_ty.kind(), access) {
204+
match (elem, base_ty.kind(), access) {
205205
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
206206
| (_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
207207
// The array length is like additional fields on the

compiler/rustc_const_eval/src/interpret/cast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
388388
let (src_pointee_ty, dest_pointee_ty) =
389389
self.tcx.struct_lockstep_tails_for_codegen(source_ty, cast_ty, self.param_env);
390390

391-
match (&src_pointee_ty.kind(), &dest_pointee_ty.kind()) {
391+
match (src_pointee_ty.kind(), dest_pointee_ty.kind()) {
392392
(&ty::Array(_, length), &ty::Slice(_)) => {
393393
let ptr = self.read_pointer(src)?;
394394
let val = Immediate::new_slice(
@@ -478,9 +478,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
478478
dest: &PlaceTy<'tcx, M::Provenance>,
479479
) -> InterpResult<'tcx> {
480480
trace!("Unsizing {:?} of type {} into {}", *src, src.layout.ty, cast_ty.ty);
481-
match (&src.layout.ty.kind(), &cast_ty.ty.kind()) {
481+
match (src.layout.ty.kind(), cast_ty.ty.kind()) {
482482
(&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(c, _))
483-
| (&ty::RawPtr(s, _), &ty::RawPtr(c, _)) => self.unsize_into_ptr(src, dest, *s, *c),
483+
| (&ty::RawPtr(s, _), &ty::RawPtr(c, _)) => self.unsize_into_ptr(src, dest, s, c),
484484
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
485485
assert_eq!(def_a, def_b); // implies same number of fields
486486

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
608608

609609
let mut bound_span_label = |self_ty: Ty<'_>, obligation: &str, quiet: &str| {
610610
let msg = format!("`{}`", if obligation.len() > 50 { quiet } else { obligation });
611-
match &self_ty.kind() {
611+
match self_ty.kind() {
612612
// Point at the type that couldn't satisfy the bound.
613613
ty::Adt(def, _) => {
614614
bound_spans.get_mut_or_insert_default(tcx.def_span(def.did())).push(msg)

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
10561056

10571057
// Find the type of the associated item, and the trait where the associated
10581058
// item is declared.
1059-
let bound = match (&qself_ty.kind(), qself_res) {
1059+
let bound = match (qself_ty.kind(), qself_res) {
10601060
(_, Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true, .. }) => {
10611061
// `Self` in an impl of a trait -- we have a concrete self type and a
10621062
// trait reference.

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29752975
let mut suffix_suggestion = sugg.clone();
29762976
suffix_suggestion.push((
29772977
if matches!(
2978-
(&expected_ty.kind(), &checked_ty.kind()),
2978+
(expected_ty.kind(), checked_ty.kind()),
29792979
(ty::Int(_) | ty::Uint(_), ty::Float(_))
29802980
) {
29812981
// Remove fractional part from literal, for example `42.0f32` into `42`
@@ -3077,7 +3077,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30773077
err.multipart_suggestion_verbose(msg, suggestion, Applicability::MachineApplicable);
30783078
};
30793079

3080-
match (&expected_ty.kind(), &checked_ty.kind()) {
3080+
match (expected_ty.kind(), checked_ty.kind()) {
30813081
(ty::Int(exp), ty::Int(found)) => {
30823082
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
30833083
{

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10121012
};
10131013
let mut bound_span_label = |self_ty: Ty<'_>, obligation: &str, quiet: &str| {
10141014
let msg = format!("`{}`", if obligation.len() > 50 { quiet } else { obligation });
1015-
match &self_ty.kind() {
1015+
match self_ty.kind() {
10161016
// Point at the type that couldn't satisfy the bound.
10171017
ty::Adt(def, _) => {
10181018
bound_spans.get_mut_or_insert_default(tcx.def_span(def.did())).push(msg)

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13361336
// More generally, the expected type wants a tuple variant with one field of an
13371337
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
13381338
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
1339-
let missing_parentheses = match (&expected.kind(), fields, had_err) {
1339+
let missing_parentheses = match (expected.kind(), fields, had_err) {
13401340
// #67037: only do this if we could successfully type-check the expected type against
13411341
// the tuple struct pattern. Otherwise the args could get out of range on e.g.,
13421342
// `let P() = U;` where `P != U` with `struct P<T>(T);`.

compiler/rustc_middle/src/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ where
11041104
}
11051105

11061106
fn is_never(this: TyAndLayout<'tcx>) -> bool {
1107-
this.ty.kind() == &ty::Never
1107+
matches!(this.ty.kind(), ty::Never)
11081108
}
11091109

11101110
fn is_tuple(this: TyAndLayout<'tcx>) -> bool {

compiler/rustc_middle/src/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<'tcx> TyCtxt<'tcx> {
296296
) -> (Ty<'tcx>, Ty<'tcx>) {
297297
let (mut a, mut b) = (source, target);
298298
loop {
299-
match (&a.kind(), &b.kind()) {
299+
match (a.kind(), b.kind()) {
300300
(&ty::Adt(a_def, a_args), &ty::Adt(b_def, b_args))
301301
if a_def == b_def && a_def.is_struct() =>
302302
{

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn lit_to_mir_constant<'tcx>(
127127
Ok(ConstValue::Scalar(Scalar::from_uint(result, width)))
128128
};
129129

130-
let value = match (lit, &ty.kind()) {
130+
let value = match (lit, ty.kind()) {
131131
(ast::LitKind::Str(s, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_str() => {
132132
let s = s.as_str();
133133
let allocation = Allocation::from_bytes_byte_aligned_immutable(s.as_bytes());

compiler/rustc_mir_build/src/thir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) fn lit_to_const<'tcx>(
2929
.unwrap_or_else(|| bug!("expected to create ScalarInt from uint {:?}", result)))
3030
};
3131

32-
let valtree = match (lit, &ty.kind()) {
32+
let valtree = match (lit, ty.kind()) {
3333
(ast::LitKind::Str(s, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_str() => {
3434
let str_bytes = s.as_str().as_bytes();
3535
ty::ValTree::from_raw_bytes(tcx, str_bytes)

compiler/rustc_monomorphize/src/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,9 @@ fn find_vtable_types_for_unsizing<'tcx>(
10351035
}
10361036
};
10371037

1038-
match (&source_ty.kind(), &target_ty.kind()) {
1038+
match (source_ty.kind(), target_ty.kind()) {
10391039
(&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(b, _))
1040-
| (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => ptr_vtable(*a, *b),
1040+
| (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => ptr_vtable(a, b),
10411041
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
10421042
ptr_vtable(source_ty.boxed_ty(), target_ty.boxed_ty())
10431043
}

compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
382382
if !expected_inner.is_fn() || !found_inner.is_fn() {
383383
return;
384384
}
385-
match (&expected_inner.kind(), &found_inner.kind()) {
385+
match (expected_inner.kind(), found_inner.kind()) {
386386
(ty::FnPtr(sig_tys, hdr), ty::FnDef(did, args)) => {
387387
let sig = sig_tys.with(*hdr);
388388
let expected_sig = &(self.normalize_fn_sig)(sig);

0 commit comments

Comments
 (0)