Skip to content

Commit 4f29f3c

Browse files
committed
Add impl polarity to fields
1 parent b200511 commit 4f29f3c

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+27-26
Original file line numberDiff line numberDiff line change
@@ -284,32 +284,32 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
284284
// structs and enums.
285285
self.assemble_candidates_from_impls(obligation, &mut candidates);
286286

287-
// For other types, we'll use the builtin rules.
288-
let copy_conditions = self.copy_clone_conditions(obligation);
289-
self.assemble_builtin_bound_candidates(copy_conditions, &mut candidates);
290-
} else if lang_items.discriminant_kind_trait() == Some(def_id) {
291-
// `DiscriminantKind` is automatically implemented for every type.
292-
candidates.vec.push(DiscriminantKindCandidate);
293-
} else if lang_items.pointee_trait() == Some(def_id) {
294-
// `Pointee` is automatically implemented for every type.
295-
candidates.vec.push(PointeeCandidate);
296-
} else if lang_items.sized_trait() == Some(def_id) {
297-
// Sized is never implementable by end-users, it is
298-
// always automatically computed.
299-
let sized_conditions = self.sized_conditions(obligation);
300-
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
301-
} else if lang_items.unsize_trait() == Some(def_id) {
302-
self.assemble_candidates_for_unsizing(obligation, &mut candidates);
303-
} else if lang_items.drop_trait() == Some(def_id)
304-
&& obligation.predicate.skip_binder().constness == ty::BoundConstness::ConstIfConst
305-
{
306-
if self.is_in_const_context {
307-
self.assemble_const_drop_candidates(obligation, stack, &mut candidates)?;
308-
} else {
309-
debug!("passing ~const Drop bound; in non-const context");
310-
// `~const Drop` when we are not in a const context has no effect.
311-
candidates.vec.push(ConstDropCandidate)
312-
}
287+
// For other types, we'll use the builtin rules.
288+
let copy_conditions = self.copy_clone_conditions(obligation);
289+
self.assemble_builtin_bound_candidates(copy_conditions, &mut candidates);
290+
} else if lang_items.discriminant_kind_trait() == Some(def_id) {
291+
// `DiscriminantKind` is automatically implemented for every type.
292+
candidates.vec.push(DiscriminantKindCandidate);
293+
} else if lang_items.pointee_trait() == Some(def_id) {
294+
// `Pointee` is automatically implemented for every type.
295+
candidates.vec.push(PointeeCandidate);
296+
} else if lang_items.sized_trait() == Some(def_id) {
297+
// Sized is never implementable by end-users, it is
298+
// always automatically computed.
299+
let sized_conditions = self.sized_conditions(obligation);
300+
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
301+
} else if lang_items.unsize_trait() == Some(def_id) {
302+
self.assemble_candidates_for_unsizing(obligation, &mut candidates);
303+
} else if lang_items.drop_trait() == Some(def_id)
304+
&& obligation.predicate.skip_binder().constness == ty::BoundConstness::ConstIfConst
305+
{
306+
if self.is_in_const_context {
307+
self.assemble_const_drop_candidates(obligation, stack, &mut candidates)?;
308+
} else {
309+
debug!("passing ~const Drop bound; in non-const context");
310+
// `~const Drop` when we are not in a const context has no effect.
311+
candidates.vec.push(ConstDropCandidate)
312+
}
313313
} else {
314314
if lang_items.clone_trait() == Some(def_id) {
315315
// Same builtin conditions as `Copy`, i.e., every type which has builtin support
@@ -947,6 +947,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
947947
substs: self.tcx().mk_substs_trait(ty, &[]),
948948
},
949949
constness: ty::BoundConstness::ConstIfConst,
950+
polarity: ty::ImplPolarity::Positive,
950951
}));
951952

952953
let const_drop_stack = self.push_stack(obligation_stack.list(), &const_drop_obligation);

0 commit comments

Comments
 (0)