Skip to content

Commit 4b34c7b

Browse files
committed
Auto merge of #108116 - Dylan-DPC:rollup-h3n2vxl, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #106372 (Use id-based thread parking on SOLID) - #108050 (Fix index out of bounds ICE in `point_at_expr_source_of_inferred_type`) - #108084 (Constify `RangeBounds`, `RangeX::contains` and `RangeX::is_empty` (where applicable).) - #108101 (don't clone types that are copy) - #108102 (simplify some refs) - #108103 (be nice and don't slice) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 639377e + bb1e984 commit 4b34c7b

File tree

17 files changed

+174
-234
lines changed

17 files changed

+174
-234
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19701970
) = &qself.kind {
19711971
// If the path segment already has type params, we want to overwrite
19721972
// them.
1973-
match &path.segments[..] {
1973+
match &path.segments {
19741974
// `segment` is the previous to last element on the path,
19751975
// which would normally be the `enum` itself, while the last
19761976
// `_` `PathSegment` corresponds to the variant.
@@ -2670,7 +2670,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
26702670
// `Self` in trait or type alias.
26712671
assert_eq!(opt_self_ty, None);
26722672
self.prohibit_generics(path.segments.iter(), |err| {
2673-
if let [hir::PathSegment { args: Some(args), ident, .. }] = &path.segments[..] {
2673+
if let [hir::PathSegment { args: Some(args), ident, .. }] = &path.segments {
26742674
err.span_suggestion_verbose(
26752675
ident.span.shrink_to_hi().to(args.span_ext),
26762676
"the `Self` type doesn't accept type parameters",

compiler/rustc_hir_typeck/src/demand.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
298298
// call's arguments and we can provide a more explicit span.
299299
let sig = self.tcx.fn_sig(def_id).subst_identity();
300300
let def_self_ty = sig.input(0).skip_binder();
301+
let param_tys = sig.inputs().skip_binder().iter().skip(1);
302+
// If there's an arity mismatch, pointing out the call as the source of an inference
303+
// can be misleading, so we skip it.
304+
if param_tys.len() != args.len() {
305+
continue;
306+
}
301307
let rcvr_ty = self.node_ty(rcvr.hir_id);
302308
// Get the evaluated type *after* calling the method call, so that the influence
303309
// of the arguments can be reflected in the receiver type. The receiver
@@ -323,13 +329,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
323329
let mut param_found = FxHashMap::default();
324330
if self.can_eq(self.param_env, ty, found) {
325331
// We only point at the first place where the found type was inferred.
326-
for (i, param_ty) in sig.inputs().skip_binder().iter().skip(1).enumerate() {
332+
for (param_ty, arg) in param_tys.zip(args) {
327333
if def_self_ty.contains(*param_ty) && let ty::Param(_) = param_ty.kind() {
328334
// We found an argument that references a type parameter in `Self`,
329335
// so we assume that this is the argument that caused the found
330336
// type, which we know already because of `can_eq` above was first
331337
// inferred in this method call.
332-
let arg = &args[i];
333338
let arg_ty = self.node_ty(arg.hir_id);
334339
if !arg.span.overlaps(mismatch_span) {
335340
err.span_label(

compiler/rustc_hir_typeck/src/method/probe.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ fn method_autoderef_steps<'tcx>(
517517
.by_ref()
518518
.map(|(ty, d)| {
519519
let step = CandidateStep {
520-
self_ty: infcx
521-
.make_query_response_ignoring_pending_obligations(inference_vars.clone(), ty),
520+
self_ty: infcx.make_query_response_ignoring_pending_obligations(inference_vars, ty),
522521
autoderefs: d,
523522
from_unsafe_deref: reached_raw_pointer,
524523
unsize: false,

compiler/rustc_middle/src/ty/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl FlagComputation {
125125
self.bound_computation(ts, |flags, ts| flags.add_tys(ts));
126126
}
127127

128-
&ty::GeneratorWitnessMIR(_, ref substs) => {
128+
ty::GeneratorWitnessMIR(_, substs) => {
129129
let should_remove_further_specializable =
130130
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
131131
self.add_substs(substs);

compiler/rustc_query_system/src/query/caches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
let mut lock = self.cache.lock();
9393
// We may be overwriting another value. This is all right, since the dep-graph
9494
// will check that the fingerprint matches.
95-
lock.insert(key, (value.clone(), index));
95+
lock.insert(key, (value, index));
9696
value
9797
}
9898

@@ -153,7 +153,7 @@ where
153153

154154
#[inline]
155155
fn complete(&self, _key: (), value: V, index: DepNodeIndex) -> Self::Stored {
156-
*self.cache.lock() = Some((value.clone(), index));
156+
*self.cache.lock() = Some((value, index));
157157
value
158158
}
159159

@@ -283,7 +283,7 @@ where
283283
let mut lock = self.cache.get_shard_by_hash(key.index() as u64).lock();
284284
#[cfg(not(parallel_compiler))]
285285
let mut lock = self.cache.lock();
286-
lock.insert(key, (value.clone(), index));
286+
lock.insert(key, (value, index));
287287
value
288288
}
289289

compiler/rustc_trait_selection/src/solve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
547547
response.value.certainty == Certainty::Yes
548548
&& response.has_no_inference_or_external_constraints()
549549
}) {
550-
return Ok(response.clone());
550+
return Ok(*response);
551551
}
552552

553553
let certainty = candidates.iter().fold(Certainty::AMBIGUOUS, |certainty, response| {

compiler/rustc_trait_selection/src/traits/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ fn virtual_call_violation_for_method<'tcx>(
599599
return false;
600600
}
601601

602-
contains_illegal_self_type_reference(tcx, trait_def_id, pred.clone())
602+
contains_illegal_self_type_reference(tcx, trait_def_id, pred)
603603
}) {
604604
return Some(MethodViolationCode::WhereClauseReferencesSelf);
605605
}

compiler/rustc_type_ir/src/sty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<I: Interner> PartialEq for TyKind<I> {
336336
a_d == b_d && a_s == b_s && a_m == b_m
337337
}
338338
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g == b_g,
339-
(&GeneratorWitnessMIR(ref a_d, ref a_s), &GeneratorWitnessMIR(ref b_d, ref b_s)) => {
339+
(GeneratorWitnessMIR(a_d, a_s), GeneratorWitnessMIR(b_d, b_s)) => {
340340
a_d == b_d && a_s == b_s
341341
}
342342
(Tuple(a_t), Tuple(b_t)) => a_t == b_t,
@@ -397,8 +397,8 @@ impl<I: Interner> Ord for TyKind<I> {
397397
}
398398
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g.cmp(b_g),
399399
(
400-
&GeneratorWitnessMIR(ref a_d, ref a_s),
401-
&GeneratorWitnessMIR(ref b_d, ref b_s),
400+
GeneratorWitnessMIR(a_d, a_s),
401+
GeneratorWitnessMIR(b_d, b_s),
402402
) => match Ord::cmp(a_d, b_d) {
403403
Ordering::Equal => Ord::cmp(a_s, b_s),
404404
cmp => cmp,

library/core/src/cmp.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1491,9 +1491,10 @@ mod impls {
14911491
}
14921492
}
14931493
#[stable(feature = "rust1", since = "1.0.0")]
1494-
impl<A: ?Sized, B: ?Sized> PartialOrd<&B> for &A
1494+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1495+
impl<A: ?Sized, B: ?Sized> const PartialOrd<&B> for &A
14951496
where
1496-
A: PartialOrd<B>,
1497+
A: ~const PartialOrd<B>,
14971498
{
14981499
#[inline]
14991500
fn partial_cmp(&self, other: &&B) -> Option<Ordering> {

0 commit comments

Comments
 (0)