Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5f6cfd2
mention `remove` in `swap_remove`
Nov 1, 2021
169b84f
Replace where-bounded Clean impl with function
camelid Nov 10, 2021
cf6a73c
Remove where bound from `clean_fn_decl_with_args`
camelid Nov 10, 2021
c615b11
Remove unnecessary reborrows
camelid Nov 10, 2021
c20ee3e
Add comments ensuring that generics are cleaned before args
camelid Nov 10, 2021
1642fdf
Add `-Zassert-incr-state` to assert state of incremental cache
pierwill Oct 31, 2021
498ebc4
require full validity when determining the discriminant of a value
RalfJung Nov 14, 2021
cf6f64a
Make slice->str conversion and related functions const
WaffleLapkin Nov 5, 2021
a7261c3
Avoid suggesting literal formatting that turns into member access
notriddle Nov 17, 2021
91e0217
rustc: Remove `#[rustc_synthetic]`
petrochenkov Nov 18, 2021
530eaa8
Clean up mess for --show-coverage documentation
GuillaumeGomez Nov 8, 2021
573a00e
Fill in tracking issues for `const_str_from_utf8` and `const_str_from…
WaffleLapkin Nov 18, 2021
728b3f2
Rollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011
JohnTitor Nov 18, 2021
153e4dc
Rollup merge of #90438 - GuillaumeGomez:doc-show-coverage, r=camelid
JohnTitor Nov 18, 2021
3e97d9b
Rollup merge of #90480 - r00ster91:remove, r=kennytm
JohnTitor Nov 18, 2021
77c985f
Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk
JohnTitor Nov 18, 2021
47c1bd1
Rollup merge of #90750 - camelid:rm-tuple-impls-1, r=jyn514
JohnTitor Nov 18, 2021
0a2b7d7
Rollup merge of #90895 - RalfJung:read-discriminant-valid, r=oli-obk
JohnTitor Nov 18, 2021
dfbbb3b
Rollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-endi…
JohnTitor Nov 18, 2021
08c1639
Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwco
JohnTitor Nov 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace where-bounded Clean impl with function
This was the only Clean impl I found with `where` bounds.

This impl was doubly-confusing: it was implemented on a tuple and it
was polymorphic. Combined, this caused a "spooky action at a distance"
effect to make the code very confusing.
  • Loading branch information
camelid committed Nov 10, 2021
commit 169b84fee38827d0e4e437696baf7149d9c2adf7
30 changes: 17 additions & 13 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,9 @@ fn clean_fn_or_proc_macro(

impl<'a> Clean<Function> for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId) {
fn clean(&self, cx: &mut DocContext<'_>) -> Function {
let (generics, decl) =
enter_impl_trait(cx, |cx| (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx)));
let (generics, decl) = enter_impl_trait(cx, |cx| {
(self.1.clean(cx), clean_fn_decl_with_args(cx, &*self.0.decl, self.2))
});
Function { decl, generics, header: self.0.header }
}
}
Expand Down Expand Up @@ -804,16 +805,18 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
}
}

impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl<'a>, A)
fn clean_fn_decl_with_args<'a, A: Copy>(
cx: &mut DocContext<'_>,
decl: &'a hir::FnDecl<'a>,
args: A,
) -> FnDecl
where
(&'a [hir::Ty<'a>], A): Clean<Arguments>,
{
fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl {
FnDecl {
inputs: (self.0.inputs, self.1).clean(cx),
output: self.0.output.clean(cx),
c_variadic: self.0.c_variadic,
}
FnDecl {
inputs: (decl.inputs, args).clean(cx),
output: decl.output.clean(cx),
c_variadic: decl.c_variadic,
}
}

Expand Down Expand Up @@ -894,7 +897,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
}
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
let (generics, decl) = enter_impl_trait(cx, |cx| {
(self.generics.clean(cx), (sig.decl, names).clean(cx))
(self.generics.clean(cx), clean_fn_decl_with_args(cx, sig.decl, names))
});
let mut t = Function { header: sig.header, decl, generics };
if t.header.constness == hir::Constness::Const
Expand Down Expand Up @@ -1728,7 +1731,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
let generic_params = self.generic_params.iter().map(|x| x.clean(cx)).collect();
let decl = (self.decl, self.param_names).clean(cx);
let decl = clean_fn_decl_with_args(cx, self.decl, self.param_names);
(generic_params, decl)
});
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
Expand Down Expand Up @@ -2025,8 +2028,9 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
let kind = match item.kind {
hir::ForeignItemKind::Fn(decl, names, ref generics) => {
let abi = cx.tcx.hir().get_foreign_abi(item.hir_id());
let (generics, decl) =
enter_impl_trait(cx, |cx| (generics.clean(cx), (decl, names).clean(cx)));
let (generics, decl) = enter_impl_trait(cx, |cx| {
(generics.clean(cx), clean_fn_decl_with_args(cx, decl, names))
});
ForeignFunctionItem(Function {
decl,
generics,
Expand Down