summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_builtin_macros/src/deriving
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_builtin_macros/src/deriving')
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/bounds.rs23
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/clone.rs8
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/mod.rs4
3 files changed, 29 insertions, 6 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/bounds.rs b/compiler/rustc_builtin_macros/src/deriving/bounds.rs
index 0481a1189..2c8e6f99c 100644
--- a/compiler/rustc_builtin_macros/src/deriving/bounds.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/bounds.rs
@@ -27,3 +27,26 @@ pub fn expand_deriving_copy(
trait_def.expand(cx, mitem, item, push);
}
+
+pub fn expand_deriving_const_param_ty(
+ cx: &mut ExtCtxt<'_>,
+ span: Span,
+ mitem: &MetaItem,
+ item: &Annotatable,
+ push: &mut dyn FnMut(Annotatable),
+ is_const: bool,
+) {
+ let trait_def = TraitDef {
+ span,
+ path: path_std!(marker::ConstParamTy),
+ skip_path_as_bound: false,
+ needs_copy_as_bound_if_packed: false,
+ additional_bounds: Vec::new(),
+ supports_unions: false,
+ methods: Vec::new(),
+ associated_types: Vec::new(),
+ is_const,
+ };
+
+ trait_def.expand(cx, mitem, item, push);
+}
diff --git a/compiler/rustc_builtin_macros/src/deriving/clone.rs b/compiler/rustc_builtin_macros/src/deriving/clone.rs
index dfee2d3ce..988356374 100644
--- a/compiler/rustc_builtin_macros/src/deriving/clone.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/clone.rs
@@ -145,7 +145,7 @@ fn cs_clone_simple(
}
_ => cx.span_bug(
trait_span,
- &format!("unexpected substructure in simple `derive({})`", name),
+ format!("unexpected substructure in simple `derive({})`", name),
),
}
}
@@ -179,10 +179,10 @@ fn cs_clone(
vdata = &variant.data;
}
EnumTag(..) | AllFieldlessEnum(..) => {
- cx.span_bug(trait_span, &format!("enum tags in `derive({})`", name,))
+ cx.span_bug(trait_span, format!("enum tags in `derive({})`", name,))
}
StaticEnum(..) | StaticStruct(..) => {
- cx.span_bug(trait_span, &format!("associated function in `derive({})`", name))
+ cx.span_bug(trait_span, format!("associated function in `derive({})`", name))
}
}
@@ -194,7 +194,7 @@ fn cs_clone(
let Some(ident) = field.name else {
cx.span_bug(
trait_span,
- &format!("unnamed field in normal struct in `derive({})`", name,),
+ format!("unnamed field in normal struct in `derive({})`", name,),
);
};
let call = subcall(cx, field);
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
index e5a003315..4ba09335c 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
@@ -1038,7 +1038,7 @@ impl<'a> MethodDef<'a> {
/// `&self.x` because that might cause an unaligned ref. So for any trait
/// method that takes a reference, we use a local block to force a copy.
/// This requires that the field impl `Copy`.
- /// ```
+ /// ```rust,ignore (example)
/// # struct A { x: u8, y: u8 }
/// impl PartialEq for A {
/// fn eq(&self, other: &A) -> bool {
@@ -1591,7 +1591,7 @@ impl<'a> TraitDef<'a> {
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
sp,
ast::CRATE_NODE_ID,
- &format!(
+ format!(
"{} slice in a packed struct that derives a built-in trait",
ty
),