Skip to content

Commit 1509254

Browse files
committed
prevent TrivialClone implementations from appearing in rustdoc output
1 parent c5e262c commit 1509254

File tree

22 files changed

+48
-1
lines changed

22 files changed

+48
-1
lines changed

compiler/rustc_builtin_macros/src/deriving/bounds.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(crate) fn expand_deriving_copy(
2424
associated_types: Vec::new(),
2525
is_const,
2626
safety: Safety::Default,
27+
document: true,
2728
};
2829

2930
trait_def.expand(cx, mitem, item, push);
@@ -48,6 +49,7 @@ pub(crate) fn expand_deriving_const_param_ty(
4849
associated_types: Vec::new(),
4950
is_const,
5051
safety: Safety::Default,
52+
document: true,
5153
};
5254

5355
trait_def.expand(cx, mitem, item, push);
@@ -63,6 +65,7 @@ pub(crate) fn expand_deriving_const_param_ty(
6365
associated_types: Vec::new(),
6466
is_const,
6567
safety: Safety::Default,
68+
document: true,
6669
};
6770

6871
trait_def.expand(cx, mitem, item, push);
@@ -87,6 +90,7 @@ pub(crate) fn expand_deriving_unsized_const_param_ty(
8790
associated_types: Vec::new(),
8891
is_const,
8992
safety: Safety::Default,
93+
document: true,
9094
};
9195

9296
trait_def.expand(cx, mitem, item, push);

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ pub(crate) fn expand_deriving_clone(
8282
associated_types: Vec::new(),
8383
is_const,
8484
safety: Safety::Unsafe(DUMMY_SP),
85+
// `TrivialClone` is not part of an API guarantee, so it shouldn't
86+
// appear in rustdoc output.
87+
document: false,
8588
};
8689

8790
trivial_def.expand_ext(cx, mitem, item, push, true);
@@ -107,6 +110,7 @@ pub(crate) fn expand_deriving_clone(
107110
associated_types: Vec::new(),
108111
is_const,
109112
safety: Safety::Default,
113+
document: true,
110114
};
111115

112116
trait_def.expand_ext(cx, mitem, item, push, is_simple)

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub(crate) fn expand_deriving_eq(
4444
associated_types: Vec::new(),
4545
is_const,
4646
safety: Safety::Default,
47+
document: true,
4748
};
4849
trait_def.expand_ext(cx, mitem, item, push, true)
4950
}

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(crate) fn expand_deriving_ord(
3535
associated_types: Vec::new(),
3636
is_const,
3737
safety: Safety::Default,
38+
document: true,
3839
};
3940

4041
trait_def.expand(cx, mitem, item, push)

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub(crate) fn expand_deriving_partial_eq(
8585
associated_types: Vec::new(),
8686
is_const: false,
8787
safety: Safety::Default,
88+
document: true,
8889
};
8990
structural_trait_def.expand(cx, mitem, item, push);
9091

@@ -112,6 +113,7 @@ pub(crate) fn expand_deriving_partial_eq(
112113
associated_types: Vec::new(),
113114
is_const,
114115
safety: Safety::Default,
116+
document: true,
115117
};
116118
trait_def.expand(cx, mitem, item, push)
117119
}

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(crate) fn expand_deriving_partial_ord(
6565
associated_types: Vec::new(),
6666
is_const,
6767
safety: Safety::Default,
68+
document: true,
6869
};
6970
trait_def.expand(cx, mitem, item, push)
7071
}

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub(crate) fn expand_deriving_debug(
4242
associated_types: Vec::new(),
4343
is_const,
4444
safety: Safety::Default,
45+
document: true,
4546
};
4647
trait_def.expand(cx, mitem, item, push)
4748
}

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub(crate) fn expand_deriving_default(
5151
associated_types: Vec::new(),
5252
is_const,
5353
safety: Safety::Default,
54+
document: true,
5455
};
5556
trait_def.expand(cx, mitem, item, push)
5657
}

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ pub(crate) struct TraitDef<'a> {
224224

225225
/// The safety of the `impl`.
226226
pub safety: Safety,
227+
228+
/// Whether the added `impl` should appear in rustdoc output.
229+
pub document: bool,
227230
}
228231

229232
pub(crate) struct MethodDef<'a> {
@@ -787,7 +790,11 @@ impl<'a> TraitDef<'a> {
787790
let path = cx.path_all(self.span, false, vec![type_ident], self_params);
788791
let self_type = cx.ty_path(path);
789792

790-
let attrs = thin_vec![cx.attr_word(sym::automatically_derived, self.span),];
793+
let mut attrs = thin_vec![cx.attr_word(sym::automatically_derived, self.span),];
794+
if !self.document {
795+
attrs.push(cx.attr_nested_word(sym::doc, sym::hidden, self.span));
796+
}
797+
791798
let opt_trait_ref = Some(trait_ref);
792799

793800
cx.item(

compiler/rustc_builtin_macros/src/deriving/hash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub(crate) fn expand_deriving_hash(
4242
associated_types: Vec::new(),
4343
is_const,
4444
safety: Safety::Default,
45+
document: true,
4546
};
4647

4748
hash_trait_def.expand(cx, mitem, item, push);

0 commit comments

Comments
 (0)