fix tidy, small cleanup

This commit is contained in:
Bastian Kauschke 2020-09-10 09:48:02 +02:00
parent 8667f93040
commit 300b0acb85
5 changed files with 28 additions and 13 deletions

View File

@ -586,7 +586,7 @@ declare_features! (
(active, if_let_guard, "1.47.0", Some(51114), None),
/// Allows non trivial generic constants which have to be manually propageted upwards.
(active, const_evaluatable_checked, "1.48.0", Some(0), None),
(active, const_evaluatable_checked, "1.48.0", Some(76560), None),
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates

View File

@ -73,10 +73,6 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
}
}
if concrete.is_ok() {
debug!("is_const_evaluatable: concrete ~~> ok");
} else {
debug!("is_const_evaluatable: concrete ~~> err");
}
debug!(?concrete, "is_const_evaluatable");
concrete.map(drop)
}

View File

@ -1678,13 +1678,8 @@ fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicate
if tcx.features().const_evaluatable_checked {
let const_evaluatable = const_evaluatable_predicates_of(tcx, def_id, &result);
if result.predicates.is_empty() {
result.predicates = tcx.arena.alloc_from_iter(const_evaluatable);
} else {
result.predicates = tcx
.arena
.alloc_from_iter(result.predicates.iter().copied().chain(const_evaluatable));
}
result.predicates =
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(const_evaluatable));
}
debug!("predicates_defined_on({:?}) = {:?}", def_id, result);

View File

@ -0,0 +1,14 @@
#![feature(const_generics)]
#![allow(incomplete_features)]
type Arr<const N: usize> = [u8; N - 1];
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
//~^ ERROR constant expression depends
Default::default()
}
fn main() {
let x = test::<33>();
assert_eq!(x, [0; 32]);
}

View File

@ -0,0 +1,10 @@
error: constant expression depends on a generic parameter
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:30
|
LL | fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
| ^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error