}
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
- for param in &self.params {
- match param.kind {
- GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => return true,
- GenericParamDefKind::Lifetime => {}
- }
+ if self.own_requires_monomorphization() {
+ return true;
}
+
if let Some(parent_def_id) = self.parent {
let parent = tcx.generics_of(parent_def_id);
parent.requires_monomorphization(tcx)
}
}
+ pub fn own_requires_monomorphization(&self) -> bool {
+ for param in &self.params {
+ match param.kind {
+ GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => return true,
+ GenericParamDefKind::Lifetime => {}
+ }
+ }
+ false
+ }
+
pub fn region_param(&'tcx self,
param: &EarlyBoundRegion,
tcx: TyCtxt<'a, 'gcx, 'tcx>)
// FIXME: when we make this a hard error, this should have its
// own error code.
- let counts = tcx.generics_of(def_id).own_counts();
- let message = if counts.types + counts.consts != 0 {
+ let message = if tcx.generics_of(def_id).own_requires_monomorphization() {
"#[derive] can't be used on a #[repr(packed)] struct with \
type or const parameters (error E0133)".to_string()
} else {