don't let const_fn feature flag affect impl-block-level trait bounds

This commit is contained in:
Ralf Jung 2021-04-25 18:42:53 +02:00
parent ada102456d
commit 9a852776f4
11 changed files with 9 additions and 21 deletions

View File

@ -426,7 +426,7 @@ impl Validator<'mir, 'tcx> {
ty::PredicateKind::Subtype(_) => {
bug!("subtype predicate on function: {:#?}", predicate)
}
ty::PredicateKind::Trait(pred, constness) => {
ty::PredicateKind::Trait(pred, _constness) => {
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
continue;
}
@ -440,16 +440,7 @@ impl Validator<'mir, 'tcx> {
// arguments when determining importance.
let kind = LocalKind::Arg;
if constness == hir::Constness::Const {
self.check_op_spanned(ops::ty::TraitBound(kind), span);
} else if !tcx.features().const_fn
|| self.ccx.is_const_stable_const_fn()
{
// HACK: We shouldn't need the conditional above, but trait
// bounds on containing impl blocks are wrongly being marked as
// "not-const".
self.check_op_spanned(ops::ty::TraitBound(kind), span);
}
self.check_op_spanned(ops::ty::TraitBound(kind), span);
}
// other kinds of bounds are either tautologies
// or cause errors in other passes

View File

@ -21,7 +21,8 @@
#![feature(rustc_allow_const_fn_unstable)]
#![feature(nll)]
#![feature(staged_api)]
#![feature(const_fn)]
#![cfg_attr(bootstrap, feature(const_fn))]
#![cfg_attr(not(bootstrap), feature(const_fn_trait_bound))]
#![feature(const_fn_fn_ptr_basics)]
#![feature(allow_internal_unstable)]
#![feature(decl_macro)]

View File

@ -5,7 +5,6 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
struct NonConstAdd(i32);

View File

@ -1,6 +1,5 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
pub trait Plus {
fn plus(self, rhs: Self) -> Self;

View File

@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/call-const-trait-method-fail.rs:26:5
--> $DIR/call-const-trait-method-fail.rs:25:5
|
LL | a.plus(b)
| ^^^^^^^^^

View File

@ -2,7 +2,6 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
struct Int(i32);

View File

@ -1,4 +1,4 @@
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]

View File

@ -1,6 +1,6 @@
// check-pass
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]

View File

@ -1,7 +1,6 @@
// FIXME(jschievink): this is not rejected correctly (only when the non-const impl is actually used)
// ignore-test
#![feature(const_fn)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

View File

@ -4,7 +4,7 @@
#![cfg_attr(gated, feature(const_trait_bound_opt_out))]
#![allow(incomplete_features)]
#![feature(rustc_attrs)]
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
trait T {
const CONST: i32;

View File

@ -1,6 +1,6 @@
// Regression test for #69615.
#![feature(const_trait_impl, const_fn)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]
pub trait MyTrait {