Skip to content

Commit 0ead26f

Browse files
committed
avoid empty where clauses
1 parent 0d29398 commit 0ead26f

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,17 @@ impl<'a> TraitDef<'a> {
724724
));
725725
}
726726

727-
let predicate = ast::WhereBoundPredicate {
728-
span: self.span,
729-
bound_generic_params: field_ty_param.bound_generic_params,
730-
bounded_ty: field_ty_param.ty,
731-
bounds,
732-
};
733-
734-
let predicate = ast::WherePredicate::BoundPredicate(predicate);
735-
where_clause.predicates.push(predicate);
727+
if !bounds.is_empty() {
728+
let predicate = ast::WhereBoundPredicate {
729+
span: self.span,
730+
bound_generic_params: field_ty_param.bound_generic_params,
731+
bounded_ty: field_ty_param.ty,
732+
bounds,
733+
};
734+
735+
let predicate = ast::WherePredicate::BoundPredicate(predicate);
736+
where_clause.predicates.push(predicate);
737+
}
736738
}
737739
}
738740
}

tests/ui/deriving/deriving-all-codegen.stdout

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,7 @@ impl<T: ::core::hash::Hash + Trait, U: ::core::hash::Hash> ::core::hash::Hash
598598
}
599599
}
600600
#[automatically_derived]
601-
impl<T: Trait, U> ::core::marker::StructuralPartialEq for Generic<T, U> where
602-
T::A: {
603-
}
601+
impl<T: Trait, U> ::core::marker::StructuralPartialEq for Generic<T, U> { }
604602
#[automatically_derived]
605603
impl<T: ::core::cmp::PartialEq + Trait, U: ::core::cmp::PartialEq>
606604
::core::cmp::PartialEq for Generic<T, U> where
@@ -611,8 +609,7 @@ impl<T: ::core::cmp::PartialEq + Trait, U: ::core::cmp::PartialEq>
611609
}
612610
}
613611
#[automatically_derived]
614-
impl<T: Trait, U> ::core::marker::StructuralEq for Generic<T, U> where T::A: {
615-
}
612+
impl<T: Trait, U> ::core::marker::StructuralEq for Generic<T, U> { }
616613
#[automatically_derived]
617614
impl<T: ::core::cmp::Eq + Trait, U: ::core::cmp::Eq> ::core::cmp::Eq for
618615
Generic<T, U> where T::A: ::core::cmp::Eq {
@@ -720,7 +717,7 @@ impl<T: ::core::hash::Hash + ::core::marker::Copy + Trait,
720717
}
721718
#[automatically_derived]
722719
impl<T: Trait, U> ::core::marker::StructuralPartialEq for PackedGeneric<T, U>
723-
where T::A: {
720+
{
724721
}
725722
#[automatically_derived]
726723
impl<T: ::core::cmp::PartialEq + ::core::marker::Copy + Trait,
@@ -734,9 +731,7 @@ impl<T: ::core::cmp::PartialEq + ::core::marker::Copy + Trait,
734731
}
735732
}
736733
#[automatically_derived]
737-
impl<T: Trait, U> ::core::marker::StructuralEq for PackedGeneric<T, U> where
738-
T::A: {
739-
}
734+
impl<T: Trait, U> ::core::marker::StructuralEq for PackedGeneric<T, U> { }
740735
#[automatically_derived]
741736
impl<T: ::core::cmp::Eq + ::core::marker::Copy + Trait, U: ::core::cmp::Eq +
742737
::core::marker::Copy> ::core::cmp::Eq for PackedGeneric<T, U> where

0 commit comments

Comments
 (0)