Skip to content

Commit 8f2c56a

Browse files
committed
Auto merge of rust-lang#103375 - matthiaskrgr:rollup-4xrs7f2, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#102635 (make `order_dependent_trait_objects` show up in future-breakage reports) - rust-lang#103335 (Replaced wrong test with the correct mcve) - rust-lang#103339 (Fix some typos) - rust-lang#103340 (WinConsole::new is not actually fallible) - rust-lang#103341 (Add test for issue 97607) - rust-lang#103351 (Require Drop impls to have the same constness on its bounds as the bounds on the struct have) - rust-lang#103359 (Remove incorrect comment in `Vec::drain`) - rust-lang#103364 (rustdoc: clean up rustdoc-toggle CSS) - rust-lang#103370 (rustdoc: remove unused CSS `.out-of-band { font-weight: normal }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5c8bff7 + 1d3aa7b commit 8f2c56a

File tree

27 files changed

+293
-163
lines changed

27 files changed

+293
-163
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+3-49
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,6 @@ impl<'a> AstValidator<'a> {
252252
}
253253
}
254254

255-
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
256-
if let Some(ident) = field.ident {
257-
if ident.name == kw::Underscore {
258-
self.visit_vis(&field.vis);
259-
self.visit_ident(ident);
260-
self.visit_ty_common(&field.ty);
261-
self.walk_ty(&field.ty);
262-
walk_list!(self, visit_attribute, &field.attrs);
263-
return;
264-
}
265-
}
266-
self.visit_field_def(field);
267-
}
268-
269255
fn err_handler(&self) -> &rustc_errors::Handler {
270256
&self.session.diagnostic()
271257
}
@@ -1006,8 +992,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1006992
visit::walk_lifetime(self, lifetime);
1007993
}
1008994

1009-
fn visit_field_def(&mut self, s: &'a FieldDef) {
1010-
visit::walk_field_def(self, s)
995+
fn visit_field_def(&mut self, field: &'a FieldDef) {
996+
visit::walk_field_def(self, field)
1011997
}
1012998

1013999
fn visit_item(&mut self, item: &'a Item) {
@@ -1195,42 +1181,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11951181
self.check_mod_file_item_asciionly(item.ident);
11961182
}
11971183
}
1198-
ItemKind::Struct(ref vdata, ref generics) => match vdata {
1199-
// Duplicating the `Visitor` logic allows catching all cases
1200-
// of `Anonymous(Struct, Union)` outside of a field struct or union.
1201-
//
1202-
// Inside `visit_ty` the validator catches every `Anonymous(Struct, Union)` it
1203-
// encounters, and only on `ItemKind::Struct` and `ItemKind::Union`
1204-
// it uses `visit_ty_common`, which doesn't contain that specific check.
1205-
VariantData::Struct(ref fields, ..) => {
1206-
self.visit_vis(&item.vis);
1207-
self.visit_ident(item.ident);
1208-
self.visit_generics(generics);
1209-
self.with_banned_assoc_ty_bound(|this| {
1210-
walk_list!(this, visit_struct_field_def, fields);
1211-
});
1212-
walk_list!(self, visit_attribute, &item.attrs);
1213-
return;
1214-
}
1215-
_ => {}
1216-
},
1217-
ItemKind::Union(ref vdata, ref generics) => {
1184+
ItemKind::Union(ref vdata, ..) => {
12181185
if vdata.fields().is_empty() {
12191186
self.err_handler().span_err(item.span, "unions cannot have zero fields");
12201187
}
1221-
match vdata {
1222-
VariantData::Struct(ref fields, ..) => {
1223-
self.visit_vis(&item.vis);
1224-
self.visit_ident(item.ident);
1225-
self.visit_generics(generics);
1226-
self.with_banned_assoc_ty_bound(|this| {
1227-
walk_list!(this, visit_struct_field_def, fields);
1228-
});
1229-
walk_list!(self, visit_attribute, &item.attrs);
1230-
return;
1231-
}
1232-
_ => {}
1233-
}
12341188
}
12351189
ItemKind::Const(def, .., None) => {
12361190
self.check_defaultness(item.span, def);

compiler/rustc_data_structures/src/sso/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct SsoHashSet<T> {
2727
map: SsoHashMap<T, ()>,
2828
}
2929

30-
/// Adapter function used ot return
30+
/// Adapter function used to return
3131
/// result if SsoHashMap functions into
3232
/// result SsoHashSet should return.
3333
#[inline(always)]

compiler/rustc_hir_analysis/src/check/dropck.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
184184
let p = p.kind();
185185
match (predicate.skip_binder(), p.skip_binder()) {
186186
(ty::PredicateKind::Trait(a), ty::PredicateKind::Trait(b)) => {
187-
// Since struct predicates cannot have ~const, project the impl predicate
188-
// onto one that ignores the constness. This is equivalent to saying that
189-
// we match a `Trait` bound on the struct with a `Trait` or `~const Trait`
190-
// in the impl.
191-
let non_const_a =
192-
ty::TraitPredicate { constness: ty::BoundConstness::NotConst, ..a };
193-
relator.relate(predicate.rebind(non_const_a), p.rebind(b)).is_ok()
187+
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
194188
}
195189
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
196190
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()

compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ declare_lint! {
14271427
"trait-object types were treated as different depending on marker-trait order",
14281428
@future_incompatible = FutureIncompatibleInfo {
14291429
reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
1430+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
14301431
};
14311432
}
14321433

compiler/rustc_middle/src/mir/interpret/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> {
5151

5252
match ty::Instance::resolve_opt_const_arg(
5353
self, param_env,
54-
// FIXME: maybe have a seperate version for resolving mir::UnevaluatedConst?
54+
// FIXME: maybe have a separate version for resolving mir::UnevaluatedConst?
5555
ct.def, ct.substs,
5656
) {
5757
Ok(Some(instance)) => {

compiler/rustc_trait_selection/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn project_and_unify_type<'cx, 'tcx>(
264264
};
265265
debug!(?normalized, ?obligations, "project_and_unify_type result");
266266
let actual = obligation.predicate.term;
267-
// For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs
267+
// For an example where this is necessary see src/test/ui/impl-trait/nested-return-type2.rs
268268
// This allows users to omit re-mentioning all bounds on an associated type and just use an
269269
// `impl Trait` for the assoc type to add more bounds.
270270
let InferOk { value: actual, obligations: new } =

library/alloc/src/vec/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1999,9 +1999,7 @@ impl<T, A: Allocator> Vec<T, A> {
19991999
unsafe {
20002000
// set self.vec length's to start, to be safe in case Drain is leaked
20012001
self.set_len(start);
2002-
// Use the borrow in the IterMut to indicate borrowing behavior of the
2003-
// whole Drain iterator (like &mut T).
2004-
let range_slice = slice::from_raw_parts_mut(self.as_mut_ptr().add(start), end - start);
2002+
let range_slice = slice::from_raw_parts(self.as_ptr().add(start), end - start);
20052003
Drain {
20062004
tail_start: end,
20072005
tail_len: len - end,

library/test/src/term.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
3939
pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
4040
TerminfoTerminal::new(io::stdout())
4141
.map(|t| Box::new(t) as Box<StdoutTerminal>)
42-
.or_else(|| WinConsole::new(io::stdout()).ok().map(|t| Box::new(t) as Box<StdoutTerminal>))
42+
.or_else(|| Some(Box::new(WinConsole::new(io::stdout())) as Box<StdoutTerminal>))
4343
}
4444

4545
/// Terminal color definitions

library/test/src/term/win.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ impl<T: Write + Send + 'static> WinConsole<T> {
113113
}
114114
}
115115

116-
/// Returns `None` whenever the terminal cannot be created for some reason.
117-
pub(crate) fn new(out: T) -> io::Result<WinConsole<T>> {
116+
pub(crate) fn new(out: T) -> WinConsole<T> {
118117
use std::mem::MaybeUninit;
119118

120119
let fg;
@@ -132,13 +131,13 @@ impl<T: Write + Send + 'static> WinConsole<T> {
132131
bg = color::BLACK;
133132
}
134133
}
135-
Ok(WinConsole {
134+
WinConsole {
136135
buf: out,
137136
def_foreground: fg,
138137
def_background: bg,
139138
foreground: fg,
140139
background: bg,
141-
})
140+
}
142141
}
143142
}
144143

src/librustdoc/html/static/css/rustdoc.css

+4-11
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ pre.example-line-numbers {
634634
.out-of-band {
635635
flex-grow: 0;
636636
font-size: 1.125rem;
637-
font-weight: normal;
638637
}
639638

640639
.docblock code, .docblock-short code,
@@ -1536,6 +1535,7 @@ details.dir-entry a {
15361535
https://developer.mozilla.org/en-US/docs/Web/CSS/contain */
15371536
details.rustdoc-toggle {
15381537
contain: layout;
1538+
position: relative;
15391539
}
15401540

15411541
/* The hideme class is used on summary tags that contain a span with
@@ -1629,10 +1629,6 @@ details.rustdoc-toggle[open] > summary.hideme {
16291629
position: absolute;
16301630
}
16311631

1632-
details.rustdoc-toggle {
1633-
position: relative;
1634-
}
1635-
16361632
details.rustdoc-toggle[open] > summary.hideme > span {
16371633
display: none;
16381634
}
@@ -1983,8 +1979,8 @@ in storage.js
19831979
}
19841980
}
19851981

1986-
.method-toggle summary,
1987-
.implementors-toggle summary,
1982+
.method-toggle > summary,
1983+
.implementors-toggle > summary,
19881984
.impl,
19891985
#implementors-list > .docblock,
19901986
.impl-items > section,
@@ -1993,10 +1989,7 @@ in storage.js
19931989
margin-bottom: 0.75em;
19941990
}
19951991

1996-
.method-toggle[open]:not(:last-child) {
1997-
margin-bottom: 2em;
1998-
}
1999-
1992+
.method-toggle[open]:not(:last-child),
20001993
.implementors-toggle[open]:not(:last-child) {
20011994
margin-bottom: 2em;
20021995
}

src/test/rustdoc-gui/docblock-details.goml

+11
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"})
2121
assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"})
2222
// So `33 + 15 + 5` == `53`
2323
assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"})
24+
25+
// We now check the `<summary>` on a method.
26+
assert-css: (
27+
".method-toggle .docblock summary h4",
28+
{"border-bottom-width": "0px"},
29+
)
30+
// This allows to ensure that summary is on one line only!
31+
assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"})
32+
assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"})
33+
// So `30 + 15 + 5` == `50`
34+
assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"})

src/test/rustdoc-gui/src/test_docs/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ pub mod details {
317317
/// <div>I'm the content of the details!</div>
318318
/// </details>
319319
pub struct Details;
320+
321+
impl Details {
322+
/// We check the appearance of the `<details>`/`<summary>` in here.
323+
///
324+
/// ## Hello
325+
///
326+
/// <details>
327+
/// <summary><h4>I'm a summary</h4></summary>
328+
/// <div>I'm the content of the details!</div>
329+
/// </details>
330+
pub fn method() {}
331+
}
320332
}
321333

322334
pub mod doc_block_table {

src/test/ui/closures/issue-97607.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
#[allow(unused)]
3+
4+
fn test<T, F, U>(f: F) -> Box<dyn Fn(T) -> U + 'static>
5+
where
6+
F: 'static + Fn(T) -> U,
7+
for<'a> U: 'a, // < This is the problematic line, see #97607
8+
{
9+
Box::new(move |t| f(t))
10+
}
11+
12+
fn main() {}

src/test/ui/generic-associated-types/bugs/issue-89008.stderr

-19
This file was deleted.

src/test/ui/generic-associated-types/bugs/issue-91762.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// check-fail
22
// known-bug
33

4-
// We almost certaintly want this to pass, but
4+
// We almost certainly want this to pass, but
55
// it's particularly difficult currently, because we need a way of specifying
66
// that `<Self::Base as Functor>::With<T> = Self` without using that when we have
77
// a `U`. See `https://github.com/rust-lang/rust/pull/92728` for a (hacky)

src/test/ui/generic-associated-types/bugs/issue-89008.rs renamed to src/test/ui/generic-associated-types/issue-89008.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
// check-fail
1+
// check-pass
22
// edition:2021
3-
// known-bug: #88908
4-
5-
// This should pass, but seems to run into a TAIT bug.
63

74
#![feature(type_alias_impl_trait)]
85

96
use std::future::Future;
7+
use std::marker::PhantomData;
108

119
trait Stream {
1210
type Item;
1311
}
1412

15-
struct Empty<T>(T);
16-
impl<T> Stream for Empty<T> {
17-
type Item = ();
13+
struct Empty<T> {
14+
_phantom: PhantomData<T>,
1815
}
19-
fn empty<T>() -> Empty<T> {
20-
todo!()
16+
17+
impl<T> Stream for Empty<T> {
18+
type Item = T;
2119
}
2220

2321
trait X {
2422
type LineStream<'a, Repr>: Stream<Item = Repr> where Self: 'a;
25-
26-
type LineStreamFut<'a,Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
27-
28-
fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>;
23+
type LineStreamFut<'a, Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
24+
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr>;
2925
}
3026

3127
struct Y;
3228

3329
impl X for Y {
3430
type LineStream<'a, Repr> = impl Stream<Item = Repr>;
35-
36-
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
37-
31+
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
3832
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
39-
async {empty()}
33+
async { Empty { _phantom: PhantomData } }
4034
}
4135
}
4236

src/test/ui/let-else/let-else-non-diverging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() {
1111

1212
// Ensure that uninhabited types do not "diverge".
1313
// This might be relaxed in the future, but when it is,
14-
// it should be an explicitly wanted descision.
14+
// it should be an explicitly wanted decision.
1515
let Some(x) = Some(1) else { foo::<Uninhabited>() }; //~ ERROR does not diverge
1616
}
1717

0 commit comments

Comments
 (0)