Skip to content

Commit 8f1202c

Browse files
authored
Rollup merge of #145235 - compiler-errors:comment, r=BoxyUwU
Minor `[const]` tweaks Self explanatory
2 parents df4f2aa + 42475af commit 8f1202c

4 files changed

Lines changed: 2 additions & 61 deletions

File tree

‎compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs‎

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -390,45 +390,13 @@ fn check_predicates<'tcx>(
390390

391391
letmut res = Ok(());
392392
for(clause, span)in impl1_predicates {
393-
if !impl2_predicates.iter().any(|pred2| trait_predicates_eq(clause.as_predicate(),*pred2))
394-
{
393+
if !impl2_predicates.iter().any(|&pred2| clause.as_predicate() == pred2){
395394
res = res.and(check_specialization_on(tcx, clause, span))
396395
}
397396
}
398397
res
399398
}
400399

401-
/// Checks if some predicate on the specializing impl (`predicate1`) is the same
402-
/// as some predicate on the base impl (`predicate2`).
403-
///
404-
/// This basically just checks syntactic equivalence, but is a little more
405-
/// forgiving since we want to equate `T: Tr` with `T: [const] Tr` so this can work:
406-
///
407-
/// ```ignore (illustrative)
408-
/// #[rustc_specialization_trait]
409-
/// trait Specialize { }
410-
///
411-
/// impl<T: Bound> Tr for T { }
412-
/// impl<T: [const] Bound + Specialize> const Tr for T { }
413-
/// ```
414-
///
415-
/// However, we *don't* want to allow the reverse, i.e., when the bound on the
416-
/// specializing impl is not as const as the bound on the base impl:
417-
///
418-
/// ```ignore (illustrative)
419-
/// impl<T: [const] Bound> const Tr for T { }
420-
/// impl<T: Bound + Specialize> const Tr for T { } // should be T: [const] Bound
421-
/// ```
422-
///
423-
/// So we make that check in this function and try to raise a helpful error message.
424-
fntrait_predicates_eq<'tcx>(
425-
predicate1: ty::Predicate<'tcx>,
426-
predicate2: ty::Predicate<'tcx>,
427-
) -> bool{
428-
// FIXME(const_trait_impl)
429-
predicate1 == predicate2
430-
}
431-
432400
#[instrument(level = "debug", skip(tcx))]
433401
fncheck_specialization_on<'tcx>(
434402
tcx:TyCtxt<'tcx>,

‎compiler/rustc_hir_typeck/src/callee.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
910910
// const stability checking here too, I guess.
911911
ifself.tcx.is_conditionally_const(callee_did){
912912
let q = self.tcx.const_conditions(callee_did);
913-
// FIXME(const_trait_impl): Use this span with a better cause code.
914913
for(idx,(cond, pred_span))in
915914
q.instantiate(self.tcx, callee_args).into_iter().enumerate()
916915
{

‎compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
3737
usesuper::suggestions::get_explanation_based_on_obligation;
3838
usesuper::{
3939
ArgKind,CandidateSimilarity,FindExprBySpan,GetSafeTransmuteErrorAndReason,ImplCandidate,
40-
UnsatisfiedConst,
4140
};
4241
usecrate::error_reporting::TypeErrCtxt;
4342
usecrate::error_reporting::infer::TyCategory;
@@ -374,13 +373,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
374373
}
375374
}
376375

377-
letUnsatisfiedConst(unsatisfied_const) = self
378-
.maybe_add_note_for_unsatisfied_const(
379-
leaf_trait_predicate,
380-
&mut err,
381-
span,
382-
);
383-
384376
ifletSome((msg, span)) = type_def {
385377
err.span_label(span, msg);
386378
}
@@ -506,7 +498,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
506498
span,
507499
is_fn_trait,
508500
suggested,
509-
unsatisfied_const,
510501
);
511502

512503
// Changing mutability doesn't make a difference to whether we have
@@ -2716,7 +2707,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
27162707
span:Span,
27172708
is_fn_trait:bool,
27182709
suggested:bool,
2719-
unsatisfied_const:bool,
27202710
){
27212711
let body_def_id = obligation.cause.body_id;
27222712
let span = ifletObligationCauseCode::BinOp{rhs_span:Some(rhs_span), .. } =
@@ -2763,10 +2753,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
27632753
self.tcx.def_span(trait_def_id),
27642754
crate::fluent_generated::trait_selection_trait_has_no_impls,
27652755
);
2766-
}elseif !suggested
2767-
&& !unsatisfied_const
2768-
&& trait_predicate.polarity() == ty::PredicatePolarity::Positive
2769-
{
2756+
}elseif !suggested && trait_predicate.polarity() == ty::PredicatePolarity::Positive{
27702757
// Can't show anything else useful, try to find similar impls.
27712758
let impl_candidates = self.find_similar_impl_candidates(trait_predicate);
27722759
if !self.report_similar_impl_candidates(
@@ -2878,17 +2865,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
28782865
}
28792866
}
28802867

2881-
fnmaybe_add_note_for_unsatisfied_const(
2882-
&self,
2883-
_trait_predicate: ty::PolyTraitPredicate<'tcx>,
2884-
_err:&mutDiag<'_>,
2885-
_span:Span,
2886-
) -> UnsatisfiedConst{
2887-
let unsatisfied_const = UnsatisfiedConst(false);
2888-
// FIXME(const_trait_impl)
2889-
unsatisfied_const
2890-
}
2891-
28922868
fnreport_closure_error(
28932869
&self,
28942870
obligation:&PredicateObligation<'tcx>,

‎compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ enum GetSafeTransmuteErrorAndReason {
5151
Error{err_msg:String,safe_transmute_explanation:Option<String>},
5252
}
5353

54-
structUnsatisfiedConst(pubbool);
55-
5654
/// Crude way of getting back an `Expr` from a `Span`.
5755
pubstructFindExprBySpan<'hir>{
5856
pubspan:Span,

0 commit comments

Comments
 (0)