Skip to content

Commit c5351ad

Browse files
committed
Auto merge of rust-lang#105348 - JohnTitor:rollup-q9bichr, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#104967 (Fix UI issues with Rustdoc scrape-examples feature.) - rust-lang#105207 (interpret: clobber return place when calling function) - rust-lang#105246 (Fix --pass in compiletest) - rust-lang#105256 (Add small comment explaining what `method-margins.goml` test is about) - rust-lang#105289 (Fix dupe word typos) - rust-lang#105309 (rustdoc: remove no-op mobile CSS `.sidebar { margin: 0; padding: 0 }`) - rust-lang#105313 (Update books) - rust-lang#105315 (Normalize inherent associated types after substitution) - rust-lang#105324 (Point at GAT `where` clause when an obligation is unsatisfied) - rust-lang#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

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+1-1
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(

Diff for: compiler/rustc_const_eval/src/interpret/eval_context.rs

+4
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,

Diff for: compiler/rustc_hir_analysis/src/astconv/mod.rs

+1
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
}

Diff for: compiler/rustc_mir_dataflow/src/value_analysis.rs

+1-1
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

Diff for: compiler/rustc_resolve/src/late.rs

+1-1
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
}

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+10-2
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(

Diff for: compiler/rustc_trait_selection/src/traits/project.rs

+25-5
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,

Diff for: library/core/src/iter/sources/repeat_n.rs

+1-1
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());

Diff for: library/core/src/str/pattern.rs

+1-1
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.)

Diff for: library/std/src/sync/mpmc/array.rs

+1-1
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.

Diff for: library/std/src/thread/scoped.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ScopeData {
4646
// We check for 'overflow' with usize::MAX / 2, to make sure there's no
4747
// chance it overflows to 0, which would result in unsoundness.
4848
if self.num_running_threads.fetch_add(1, Ordering::Relaxed) > usize::MAX / 2 {
49-
// This can only reasonably happen by mem::forget()'ing many many ScopedJoinHandles.
49+
// This can only reasonably happen by mem::forget()'ing a lot of ScopedJoinHandles.
5050
self.decrement_num_running_threads(false);
5151
panic!("too many running threads in thread scope");
5252
}

Diff for: src/doc/book

Submodule book updated 1 file

Diff for: src/librustdoc/html/static/css/rustdoc.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,6 @@ in storage.js
16601660
/* Hide the sidebar offscreen while not in use. Doing this instead of display: none means
16611661
the sidebar stays visible for screen readers, which is useful for navigation. */
16621662
left: -1000px;
1663-
margin: 0;
1664-
padding: 0;
16651663
z-index: 11;
16661664
/* Reduce height slightly to account for mobile topbar. */
16671665
height: calc(100vh - 45px);
@@ -1978,7 +1976,9 @@ in storage.js
19781976
}
19791977

19801978
.scraped-example .code-wrapper .example-wrap {
1981-
flex: 1;
1979+
display: grid;
1980+
grid-template-columns: max-content auto;
1981+
width: 100%;
19821982
overflow-x: auto;
19831983
overflow-y: hidden;
19841984
margin-bottom: 0;

Diff for: src/librustdoc/html/static/js/scrape-examples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
});
5858
});
5959

60-
example.querySelector("next")
60+
example.querySelector(".next")
6161
.addEventListener("click", () => {
6262
onChangeLoc(() => {
6363
locIndex = (locIndex + 1) % locs.length;

Diff for: src/librustdoc/html/static_files.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ static_files! {
130130
nanum_barun_gothic_license => "static/fonts/NanumBarunGothic-LICENSE.txt",
131131
}
132132

133-
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/js/scrape-examples.js");
133+
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");

Diff for: src/test/rustdoc-gui/method-margins.goml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// This test ensures that the margins on methods are coherent inside an impl block.
12
goto: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait"
23

34
assert-count: ("#trait-implementations-list > .rustdoc-toggle", 1)

Diff for: src/test/rustdoc-gui/scrape-examples-button-focus.goml

+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
2+
3+
store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre", "scrollTop")
4+
focus: ".scraped-example-list > .scraped-example .next"
5+
press-key: "Enter"
6+
assert-property-false: (".scraped-example-list > .scraped-example pre", {
7+
"scrollTop": |initialScrollTop|
8+
})
9+
focus: ".scraped-example-list > .scraped-example .prev"
10+
press-key: "Enter"
11+
assert-property: (".scraped-example-list > .scraped-example pre", {
12+
"scrollTop": |initialScrollTop|
13+
})
14+
215
store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
316
assert-property-false: (".scraped-example-list > .scraped-example pre", {
417
"scrollHeight": |smallOffsetHeight|

Diff for: src/test/rustdoc-gui/src/scrape_examples/examples/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ fn main() {
2222
println!("hello world!");
2323
println!("hello world!");
2424
}
25+
scrape_examples::test();
2526
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
3+
#![feature(inherent_associated_types)]
4+
#![allow(incomplete_features)]
5+
6+
struct S<T>(T);
7+
8+
impl<T: O> S<T> {
9+
type P = <T as O>::P;
10+
}
11+
12+
trait O {
13+
type P;
14+
}
15+
16+
impl O for i32 {
17+
type P = String;
18+
}
19+
20+
fn main() {
21+
let _: S<i32>::P = String::new();
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
3+
#![feature(inherent_associated_types)]
4+
#![allow(incomplete_features)]
5+
6+
struct S;
7+
8+
impl S {
9+
type P<T: O> = <T as O>::P;
10+
}
11+
12+
trait O {
13+
type P;
14+
}
15+
16+
impl O for i32 {
17+
type P = String;
18+
}
19+
20+
fn main() {
21+
let _: S::P<i32> = String::new();
22+
}

Diff for: src/test/ui/binop/binop-mul-i32-f32.stderr

+3-8
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ LL | x * y
66
|
77
= help: the trait `Mul<f32>` is not implemented for `i32`
88
= help: the following other types implement trait `Mul<Rhs>`:
9-
<&'a f32 as Mul<f32>>
10-
<&'a f64 as Mul<f64>>
11-
<&'a i128 as Mul<i128>>
12-
<&'a i16 as Mul<i16>>
139
<&'a i32 as Mul<i32>>
14-
<&'a i64 as Mul<i64>>
15-
<&'a i8 as Mul<i8>>
16-
<&'a isize as Mul<isize>>
17-
and 49 others
10+
<&i32 as Mul<&i32>>
11+
<i32 as Mul<&i32>>
12+
<i32 as Mul>
1813

1914
error: aborting due to previous error
2015

Diff for: src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ LL |
1818
LL | 1_u32
1919
| ----- return type was inferred to be `u32` here
2020
|
21-
= help: the following other types implement trait `Traitor<N, M>`:
22-
<u32 as Traitor<N, 2>>
23-
<u64 as Traitor<1, 2>>
21+
= help: the trait `Traitor<N, 2>` is implemented for `u32`
2422

2523
error[E0277]: the trait bound `u64: Traitor` is not satisfied
2624
--> $DIR/rp_impl_trait_fail.rs:21:13
@@ -31,9 +29,7 @@ LL |
3129
LL | 1_u64
3230
| ----- return type was inferred to be `u64` here
3331
|
34-
= help: the following other types implement trait `Traitor<N, M>`:
35-
<u32 as Traitor<N, 2>>
36-
<u64 as Traitor<1, 2>>
32+
= help: the trait `Traitor<1, 2>` is implemented for `u64`
3733

3834
error: aborting due to 3 previous errors
3935

Diff for: src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize];
1212
|
1313
= help: the trait `~const Add<u8>` is not implemented for `i8`
1414
= help: the following other types implement trait `Add<Rhs>`:
15-
<&'a f32 as Add<f32>>
16-
<&'a f64 as Add<f64>>
17-
<&'a i128 as Add<i128>>
18-
<&'a i16 as Add<i16>>
19-
<&'a i32 as Add<i32>>
20-
<&'a i64 as Add<i64>>
2115
<&'a i8 as Add<i8>>
22-
<&'a isize as Add<isize>>
23-
and 48 others
16+
<&i8 as Add<&i8>>
17+
<i8 as Add<&i8>>
18+
<i8 as Add>
2419

2520
error: aborting due to 2 previous errors
2621

Diff for: src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
1212
|
1313
= help: the trait `~const Add<u8>` is not implemented for `i8`
1414
= help: the following other types implement trait `Add<Rhs>`:
15-
<&'a f32 as Add<f32>>
16-
<&'a f64 as Add<f64>>
17-
<&'a i128 as Add<i128>>
18-
<&'a i16 as Add<i16>>
19-
<&'a i32 as Add<i32>>
20-
<&'a i64 as Add<i64>>
2115
<&'a i8 as Add<i8>>
22-
<&'a isize as Add<isize>>
23-
and 48 others
16+
<&i8 as Add<&i8>>
17+
<i8 as Add<&i8>>
18+
<i8 as Add>
2419

2520
error[E0604]: only `u8` can be cast as `char`, not `i8`
2621
--> $DIR/const-eval-overflow-4b.rs:22:13

Diff for: src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr

-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ LL | Foo::<i32>::bar(&1i8);
1212
<i8 as Foo<u32>>
1313
<i8 as Foo<u64>>
1414
<i8 as Foo<u8>>
15-
<u8 as Foo<bool>>
16-
<u8 as Foo<u16>>
17-
<u8 as Foo<u32>>
18-
<u8 as Foo<u64>>
1915

2016
error[E0277]: the trait bound `u8: Foo<i32>` is not satisfied
2117
--> $DIR/issue-39802-show-5-trait-impls.rs:25:21
@@ -26,11 +22,6 @@ LL | Foo::<i32>::bar(&1u8);
2622
| required by a bound introduced by this call
2723
|
2824
= help: the following other types implement trait `Foo<B>`:
29-
<i8 as Foo<bool>>
30-
<i8 as Foo<u16>>
31-
<i8 as Foo<u32>>
32-
<i8 as Foo<u64>>
33-
<i8 as Foo<u8>>
3425
<u8 as Foo<bool>>
3526
<u8 as Foo<u16>>
3627
<u8 as Foo<u32>>

0 commit comments

Comments
 (0)