Skip to content

Commit 6c869d3

Browse files
committed
Auto merge of #81057 - GuillaumeGomez:rollup-yl2kqst, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #77693 (Add test for #59352) - #80515 (Improve JS performance by storing length before comparing to it in loops) - #81030 (Update mdbook) - #81033 (Remove useless `clean::Variant` struct) - #81049 (inline: Round word-size cost estimates up) - #81054 (Drop a few unneeded borrows) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents fcbd305 + f8b1baa commit 6c869d3

File tree

15 files changed

+231
-112
lines changed

15 files changed

+231
-112
lines changed

Diff for: Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1973,9 +1973,9 @@ dependencies = [
19731973

19741974
[[package]]
19751975
name = "mdbook"
1976-
version = "0.4.5"
1976+
version = "0.4.6"
19771977
source = "registry+https://github.com/rust-lang/crates.io-index"
1978-
checksum = "21251d3eb9ca5e8ac5b73384ddaa483a9bbc7d7dcd656b1fa8f266634810334a"
1978+
checksum = "b3d948b64449003363127ed6c6139f03273982c3fe97da4cb3dee933e38ce38f"
19791979
dependencies = [
19801980
"ammonia",
19811981
"anyhow",

Diff for: compiler/rustc_mir/src/transform/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl Inliner<'tcx> {
382382
// Cost of the var is the size in machine-words, if we know
383383
// it.
384384
if let Some(size) = type_size_of(tcx, self.param_env, ty) {
385-
cost += (size / ptr_size) as usize;
385+
cost += ((size + ptr_size - 1) / ptr_size) as usize;
386386
} else {
387387
cost += UNKNOWN_SIZE_COST;
388388
}

Diff for: compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -813,25 +813,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
813813
if ty.is_never() {
814814
None
815815
} else {
816-
Some(match &elem.kind {
816+
Some(match elem.kind {
817817
// Point at the tail expression when possible.
818818
hir::ExprKind::Block(block, _) => {
819-
block.expr.as_ref().map_or(block.span, |e| e.span)
819+
block.expr.map_or(block.span, |e| e.span)
820820
}
821821
_ => elem.span,
822822
})
823823
}
824824
})
825825
};
826826

827-
if let hir::ExprKind::If(_, _, Some(el)) = &expr.kind {
827+
if let hir::ExprKind::If(_, _, Some(el)) = expr.kind {
828828
if let Some(rslt) = check_in_progress(el) {
829829
return rslt;
830830
}
831831
}
832832

833-
if let hir::ExprKind::Match(_, arms, _) = &expr.kind {
834-
let mut iter = arms.iter().filter_map(|arm| check_in_progress(&arm.body));
833+
if let hir::ExprKind::Match(_, arms, _) = expr.kind {
834+
let mut iter = arms.iter().filter_map(|arm| check_in_progress(arm.body));
835835
if let Some(span) = iter.next() {
836836
if iter.next().is_none() {
837837
return span;

Diff for: src/librustdoc/clean/mod.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -1840,11 +1840,11 @@ impl Clean<VariantStruct> for rustc_hir::VariantData<'_> {
18401840
impl Clean<Item> for ty::VariantDef {
18411841
fn clean(&self, cx: &DocContext<'_>) -> Item {
18421842
let kind = match self.ctor_kind {
1843-
CtorKind::Const => VariantKind::CLike,
1844-
CtorKind::Fn => VariantKind::Tuple(
1843+
CtorKind::Const => Variant::CLike,
1844+
CtorKind::Fn => Variant::Tuple(
18451845
self.fields.iter().map(|f| cx.tcx.type_of(f.did).clean(cx)).collect(),
18461846
),
1847-
CtorKind::Fictive => VariantKind::Struct(VariantStruct {
1847+
CtorKind::Fictive => Variant::Struct(VariantStruct {
18481848
struct_type: doctree::Plain,
18491849
fields_stripped: false,
18501850
fields: self
@@ -1861,25 +1861,21 @@ impl Clean<Item> for ty::VariantDef {
18611861
.collect(),
18621862
}),
18631863
};
1864-
let what_rustc_thinks = Item::from_def_id_and_parts(
1865-
self.def_id,
1866-
Some(self.ident.name),
1867-
VariantItem(Variant { kind }),
1868-
cx,
1869-
);
1864+
let what_rustc_thinks =
1865+
Item::from_def_id_and_parts(self.def_id, Some(self.ident.name), VariantItem(kind), cx);
18701866
// don't show `pub` for fields, which are always public
18711867
Item { visibility: Inherited, ..what_rustc_thinks }
18721868
}
18731869
}
18741870

1875-
impl Clean<VariantKind> for hir::VariantData<'_> {
1876-
fn clean(&self, cx: &DocContext<'_>) -> VariantKind {
1871+
impl Clean<Variant> for hir::VariantData<'_> {
1872+
fn clean(&self, cx: &DocContext<'_>) -> Variant {
18771873
match self {
1878-
hir::VariantData::Struct(..) => VariantKind::Struct(self.clean(cx)),
1874+
hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)),
18791875
hir::VariantData::Tuple(..) => {
1880-
VariantKind::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
1876+
Variant::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
18811877
}
1882-
hir::VariantData::Unit(..) => VariantKind::CLike,
1878+
hir::VariantData::Unit(..) => Variant::CLike,
18831879
}
18841880
}
18851881
}
@@ -2048,7 +2044,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
20482044

20492045
impl Clean<Item> for hir::Variant<'_> {
20502046
fn clean(&self, cx: &DocContext<'_>) -> Item {
2051-
let kind = VariantItem(Variant { kind: self.data.clean(cx) });
2047+
let kind = VariantItem(self.data.clean(cx));
20522048
let what_rustc_thinks =
20532049
Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx);
20542050
// don't show `pub` for variants, which are always public

Diff for: src/librustdoc/clean/types.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ impl Item {
237237
match *self.kind {
238238
StructItem(ref _struct) => Some(_struct.fields_stripped),
239239
UnionItem(ref union) => Some(union.fields_stripped),
240-
VariantItem(Variant { kind: VariantKind::Struct(ref vstruct) }) => {
241-
Some(vstruct.fields_stripped)
242-
}
240+
VariantItem(Variant::Struct(ref vstruct)) => Some(vstruct.fields_stripped),
243241
_ => None,
244242
}
245243
}
@@ -353,7 +351,7 @@ impl ItemKind {
353351
match self {
354352
StructItem(s) => s.fields.iter(),
355353
UnionItem(u) => u.fields.iter(),
356-
VariantItem(Variant { kind: VariantKind::Struct(v) }) => v.fields.iter(),
354+
VariantItem(Variant::Struct(v)) => v.fields.iter(),
357355
EnumItem(e) => e.variants.iter(),
358356
TraitItem(t) => t.items.iter(),
359357
ImplItem(i) => i.items.iter(),
@@ -1719,12 +1717,7 @@ crate struct Enum {
17191717
}
17201718

17211719
#[derive(Clone, Debug)]
1722-
crate struct Variant {
1723-
crate kind: VariantKind,
1724-
}
1725-
1726-
#[derive(Clone, Debug)]
1727-
crate enum VariantKind {
1720+
crate enum Variant {
17281721
CLike,
17291722
Tuple(Vec<Type>),
17301723
Struct(VariantStruct),

Diff for: src/librustdoc/fold.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ crate trait DocFolder: Sized {
5555
}
5656
VariantItem(i) => {
5757
let i2 = i.clone(); // this clone is small
58-
match i.kind {
59-
VariantKind::Struct(mut j) => {
58+
match i {
59+
Variant::Struct(mut j) => {
6060
let num_fields = j.fields.len();
6161
j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect();
6262
j.fields_stripped |= num_fields != j.fields.len()
6363
|| j.fields.iter().any(|f| f.is_stripped());
64-
VariantItem(Variant { kind: VariantKind::Struct(j) })
64+
VariantItem(Variant::Struct(j))
6565
}
6666
_ => VariantItem(i2),
6767
}

Diff for: src/librustdoc/html/render/mod.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -3200,9 +3200,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
32003200
write!(w, " ");
32013201
let name = v.name.as_ref().unwrap();
32023202
match *v.kind {
3203-
clean::VariantItem(ref var) => match var.kind {
3204-
clean::VariantKind::CLike => write!(w, "{}", name),
3205-
clean::VariantKind::Tuple(ref tys) => {
3203+
clean::VariantItem(ref var) => match var {
3204+
clean::Variant::CLike => write!(w, "{}", name),
3205+
clean::Variant::Tuple(ref tys) => {
32063206
write!(w, "{}(", name);
32073207
for (i, ty) in tys.iter().enumerate() {
32083208
if i > 0 {
@@ -3212,7 +3212,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
32123212
}
32133213
write!(w, ")");
32143214
}
3215-
clean::VariantKind::Struct(ref s) => {
3215+
clean::Variant::Struct(ref s) => {
32163216
render_struct(w, v, None, s.struct_type, &s.fields, " ", false, cx);
32173217
}
32183218
},
@@ -3249,25 +3249,22 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
32493249
id = id,
32503250
name = variant.name.as_ref().unwrap()
32513251
);
3252-
if let clean::VariantItem(ref var) = *variant.kind {
3253-
if let clean::VariantKind::Tuple(ref tys) = var.kind {
3254-
write!(w, "(");
3255-
for (i, ty) in tys.iter().enumerate() {
3256-
if i > 0 {
3257-
write!(w, ",&nbsp;");
3258-
}
3259-
write!(w, "{}", ty.print());
3252+
if let clean::VariantItem(clean::Variant::Tuple(ref tys)) = *variant.kind {
3253+
write!(w, "(");
3254+
for (i, ty) in tys.iter().enumerate() {
3255+
if i > 0 {
3256+
write!(w, ",&nbsp;");
32603257
}
3261-
write!(w, ")");
3258+
write!(w, "{}", ty.print());
32623259
}
3260+
write!(w, ")");
32633261
}
32643262
write!(w, "</code></div>");
32653263
document(w, cx, variant, Some(it));
32663264
document_non_exhaustive(w, variant);
32673265

3268-
use crate::clean::{Variant, VariantKind};
3269-
if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) = *variant.kind
3270-
{
3266+
use crate::clean::Variant;
3267+
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
32713268
let variant_id = cx.derive_id(format!(
32723269
"{}.{}.fields",
32733270
ItemType::Variant,

0 commit comments

Comments
 (0)