Skip to content

Commit c5351ad

Browse files
committed
Auto merge of #105348 - JohnTitor:rollup-q9bichr, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #104967 (Fix UI issues with Rustdoc scrape-examples feature.) - #105207 (interpret: clobber return place when calling function) - #105246 (Fix --pass in compiletest) - #105256 (Add small comment explaining what `method-margins.goml` test is about) - #105289 (Fix dupe word typos) - #105309 (rustdoc: remove no-op mobile CSS `.sidebar { margin: 0; padding: 0 }`) - #105313 (Update books) - #105315 (Normalize inherent associated types after substitution) - #105324 (Point at GAT `where` clause when an obligation is unsatisfied) - #105338 (Tweak "the following other types implement trait") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ed61c13 + 1310d9b commit c5351ad

File tree

52 files changed

+285
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+285
-426
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
240240
let align = ImmTy::from_uint(target_align, args[1].layout).into();
241241
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?;
242242

243-
// We replace the entire entire function call with a "tail call".
243+
// We replace the entire function call with a "tail call".
244244
// Note that this happens before the frame of the original function
245245
// is pushed on the stack.
246246
self.eval_fn_call(

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
676676
return_to_block: StackPopCleanup,
677677
) -> InterpResult<'tcx> {
678678
trace!("body: {:#?}", body);
679+
// Clobber previous return place contents, nobody is supposed to be able to see them any more
680+
// This also checks dereferenceable, but not align. We rely on all constructed places being
681+
// sufficiently aligned (in particular we rely on `deref_operand` checking alignment).
682+
self.write_uninit(return_place)?;
679683
// first push a stack frame so we have access to the local substs
680684
let pre_frame = Frame {
681685
body,

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19301930
adt_substs,
19311931
);
19321932
let ty = tcx.bound_type_of(assoc_ty_did).subst(tcx, item_substs);
1933+
let ty = self.normalize_ty(span, ty);
19331934
return Ok((ty, DefKind::AssocTy, assoc_ty_did));
19341935
}
19351936
}

compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<V: Clone> Clone for StateData<V> {
406406
/// The dataflow state for an instance of [`ValueAnalysis`].
407407
///
408408
/// Every instance specifies a lattice that represents the possible values of a single tracked
409-
/// place. If we call this lattice `V` and set set of tracked places `P`, then a [`State`] is an
409+
/// place. If we call this lattice `V` and set of tracked places `P`, then a [`State`] is an
410410
/// element of `{unreachable} ∪ (P -> V)`. This again forms a lattice, where the bottom element is
411411
/// `unreachable` and the top element is the mapping `p ↦ ⊤`. Note that the mapping `p ↦ ⊥` is not
412412
/// the bottom element (because joining an unreachable and any other reachable state yields a

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
19271927
// We have a single lifetime => success.
19281928
elision_lifetime = Elision::Param(res)
19291929
} else {
1930-
// We have have multiple lifetimes => error.
1930+
// We have multiple lifetimes => error.
19311931
elision_lifetime = Elision::Err;
19321932
}
19331933
}

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
18101810
&self,
18111811
trait_pred: ty::PolyTraitPredicate<'tcx>,
18121812
) -> Vec<ImplCandidate<'tcx>> {
1813-
self.tcx
1813+
let mut candidates: Vec<_> = self
1814+
.tcx
18141815
.all_impls(trait_pred.def_id())
18151816
.filter_map(|def_id| {
18161817
if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative
@@ -1826,7 +1827,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
18261827
self.fuzzy_match_tys(trait_pred.skip_binder().self_ty(), imp.self_ty(), false)
18271828
.map(|similarity| ImplCandidate { trait_ref: imp, similarity })
18281829
})
1829-
.collect()
1830+
.collect();
1831+
if candidates.iter().any(|c| matches!(c.similarity, CandidateSimilarity::Exact { .. })) {
1832+
// If any of the candidates is a perfect match, we don't want to show all of them.
1833+
// This is particularly relevant for the case of numeric types (as they all have the
1834+
// same cathegory).
1835+
candidates.retain(|c| matches!(c.similarity, CandidateSimilarity::Exact { .. }));
1836+
}
1837+
candidates
18301838
}
18311839

18321840
fn report_similar_impl_candidates(

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,11 +2321,10 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
23212321
nested: &mut Vec<PredicateObligation<'tcx>>,
23222322
) {
23232323
let tcx = selcx.tcx();
2324-
for predicate in tcx
2324+
let own = tcx
23252325
.predicates_of(obligation.predicate.item_def_id)
2326-
.instantiate_own(tcx, obligation.predicate.substs)
2327-
.predicates
2328-
{
2326+
.instantiate_own(tcx, obligation.predicate.substs);
2327+
for (predicate, span) in std::iter::zip(own.predicates, own.spans) {
23292328
let normalized = normalize_with_depth_to(
23302329
selcx,
23312330
obligation.param_env,
@@ -2334,9 +2333,30 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
23342333
predicate,
23352334
nested,
23362335
);
2336+
2337+
let nested_cause = if matches!(
2338+
obligation.cause.code(),
2339+
super::CompareImplItemObligation { .. }
2340+
| super::CheckAssociatedTypeBounds { .. }
2341+
| super::AscribeUserTypeProvePredicate(..)
2342+
) {
2343+
obligation.cause.clone()
2344+
} else if span.is_dummy() {
2345+
ObligationCause::new(
2346+
obligation.cause.span,
2347+
obligation.cause.body_id,
2348+
super::ItemObligation(obligation.predicate.item_def_id),
2349+
)
2350+
} else {
2351+
ObligationCause::new(
2352+
obligation.cause.span,
2353+
obligation.cause.body_id,
2354+
super::BindingObligation(obligation.predicate.item_def_id, span),
2355+
)
2356+
};
23372357
nested.push(Obligation::with_depth(
23382358
tcx,
2339-
obligation.cause.clone(),
2359+
nested_cause,
23402360
obligation.recursion_depth + 1,
23412361
obligation.param_env,
23422362
normalized,

library/core/src/iter/sources/repeat_n.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::mem::ManuallyDrop;
2020
/// #![feature(iter_repeat_n)]
2121
/// use std::iter;
2222
///
23-
/// // four of the the number four:
23+
/// // four of the number four:
2424
/// let mut four_fours = iter::repeat_n(4, 4);
2525
///
2626
/// assert_eq!(Some(4), four_fours.next());

library/core/src/str/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
18941894
// Thus, derefencing both `px` and `py` in the loop below is safe.
18951895
//
18961896
// Moreover, we set `pxend` and `pyend` to be 4 bytes before the actual
1897-
// end of of `px` and `py`. Thus, the final dereference outside of the
1897+
// end of `px` and `py`. Thus, the final dereference outside of the
18981898
// loop is guaranteed to be valid. (The final comparison will overlap with
18991899
// the last comparison done in the loop for lengths that aren't multiples
19001900
// of four.)

library/std/src/sync/mpmc/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<T> Channel<T> {
225225
let slot = unsafe { self.buffer.get_unchecked(index) };
226226
let stamp = slot.stamp.load(Ordering::Acquire);
227227

228-
// If the the stamp is ahead of the head by 1, we may attempt to pop.
228+
// If the stamp is ahead of the head by 1, we may attempt to pop.
229229
if head + 1 == stamp {
230230
let new = if index + 1 < self.cap {
231231
// Same lap, incremented index.

0 commit comments

Comments
 (0)