Skip to content

Commit f83e026

Browse files
committed
Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #98218 (Document the conditional existence of `alloc::sync` and `alloc::task`.) - #99216 (docs: be less harsh in wording for Vec::from_raw_parts) - #99460 (docs: Improve AsRef / AsMut docs on blanket impls) - #100470 (Tweak `FpCategory` example order.) - #101040 (Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds) - #101308 (introduce `{char, u8}::is_ascii_octdigit`) - #102486 (Add diagnostic struct for const eval error in `rustc_middle`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0922559 + 1b9014f commit f83e026

File tree

27 files changed

+450
-34
lines changed

27 files changed

+450
-34
lines changed

compiler/rustc_builtin_macros/src/deriving/bounds.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn expand_deriving_copy(
1616
let trait_def = TraitDef {
1717
span,
1818
path: path_std!(marker::Copy),
19+
skip_path_as_bound: false,
1920
additional_bounds: Vec::new(),
2021
generics: Bounds::empty(),
2122
supports_unions: true,

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub fn expand_deriving_clone(
7272
let trait_def = TraitDef {
7373
span,
7474
path: path_std!(clone::Clone),
75+
skip_path_as_bound: false,
7576
additional_bounds: bounds,
7677
generics: Bounds::empty(),
7778
supports_unions: true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn expand_deriving_eq(
2525
let trait_def = TraitDef {
2626
span,
2727
path: path_std!(cmp::Eq),
28+
skip_path_as_bound: false,
2829
additional_bounds: Vec::new(),
2930
generics: Bounds::empty(),
3031
supports_unions: true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn expand_deriving_ord(
1919
let trait_def = TraitDef {
2020
span,
2121
path: path_std!(cmp::Ord),
22+
skip_path_as_bound: false,
2223
additional_bounds: Vec::new(),
2324
generics: Bounds::empty(),
2425
supports_unions: false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub fn expand_deriving_partial_eq(
8383
let trait_def = TraitDef {
8484
span,
8585
path: path_std!(cmp::PartialEq),
86+
skip_path_as_bound: false,
8687
additional_bounds: Vec::new(),
8788
generics: Bounds::empty(),
8889
supports_unions: false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub fn expand_deriving_partial_ord(
3737
let trait_def = TraitDef {
3838
span,
3939
path: path_std!(cmp::PartialOrd),
40+
skip_path_as_bound: false,
4041
additional_bounds: vec![],
4142
generics: Bounds::empty(),
4243
supports_unions: false,

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn expand_deriving_debug(
2020
let trait_def = TraitDef {
2121
span,
2222
path: path_std!(fmt::Debug),
23+
skip_path_as_bound: false,
2324
additional_bounds: Vec::new(),
2425
generics: Bounds::empty(),
2526
supports_unions: false,

compiler/rustc_builtin_macros/src/deriving/decodable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn expand_deriving_rustc_decodable(
2323
let trait_def = TraitDef {
2424
span,
2525
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
26+
skip_path_as_bound: false,
2627
additional_bounds: Vec::new(),
2728
generics: Bounds::empty(),
2829
supports_unions: false,

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn expand_deriving_default(
2424
let trait_def = TraitDef {
2525
span,
2626
path: Path::new(vec![kw::Default, sym::Default]),
27+
skip_path_as_bound: has_a_default_variant(item),
2728
additional_bounds: Vec::new(),
2829
generics: Bounds::empty(),
2930
supports_unions: false,
@@ -262,3 +263,22 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for DetectNonVariantDefaultAttr<'a, '
262263
}
263264
}
264265
}
266+
267+
fn has_a_default_variant(item: &Annotatable) -> bool {
268+
struct HasDefaultAttrOnVariant {
269+
found: bool,
270+
}
271+
272+
impl<'ast> rustc_ast::visit::Visitor<'ast> for HasDefaultAttrOnVariant {
273+
fn visit_variant(&mut self, v: &'ast rustc_ast::Variant) {
274+
if v.attrs.iter().any(|attr| attr.has_name(kw::Default)) {
275+
self.found = true;
276+
}
277+
// no need to subrecurse.
278+
}
279+
}
280+
281+
let mut visitor = HasDefaultAttrOnVariant { found: false };
282+
item.visit_with(&mut visitor);
283+
visitor.found
284+
}

compiler/rustc_builtin_macros/src/deriving/encodable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ pub fn expand_deriving_rustc_encodable(
107107
let trait_def = TraitDef {
108108
span,
109109
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
110+
skip_path_as_bound: false,
110111
additional_bounds: Vec::new(),
111112
generics: Bounds::empty(),
112113
supports_unions: false,

0 commit comments

Comments
 (0)