Skip to content

Commit 300b0ac

Browse files
committed
fix tidy, small cleanup
1 parent 8667f93 commit 300b0ac

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ declare_features! (
586586
(active, if_let_guard, "1.47.0", Some(51114), None),
587587

588588
/// Allows non trivial generic constants which have to be manually propageted upwards.
589-
(active, const_evaluatable_checked, "1.48.0", Some(0), None),
589+
(active, const_evaluatable_checked, "1.48.0", Some(76560), None),
590590

591591
// -------------------------------------------------------------------------
592592
// feature-group-end: actual feature gates

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
7373
}
7474
}
7575

76-
if concrete.is_ok() {
77-
debug!("is_const_evaluatable: concrete ~~> ok");
78-
} else {
79-
debug!("is_const_evaluatable: concrete ~~> err");
80-
}
76+
debug!(?concrete, "is_const_evaluatable");
8177
concrete.map(drop)
8278
}

compiler/rustc_typeck/src/collect.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1678,13 +1678,8 @@ fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicate
16781678

16791679
if tcx.features().const_evaluatable_checked {
16801680
let const_evaluatable = const_evaluatable_predicates_of(tcx, def_id, &result);
1681-
if result.predicates.is_empty() {
1682-
result.predicates = tcx.arena.alloc_from_iter(const_evaluatable);
1683-
} else {
1684-
result.predicates = tcx
1685-
.arena
1686-
.alloc_from_iter(result.predicates.iter().copied().chain(const_evaluatable));
1687-
}
1681+
result.predicates =
1682+
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(const_evaluatable));
16881683
}
16891684

16901685
debug!("predicates_defined_on({:?}) = {:?}", def_id, result);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(const_generics)]
2+
#![allow(incomplete_features)]
3+
4+
type Arr<const N: usize> = [u8; N - 1];
5+
6+
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
7+
//~^ ERROR constant expression depends
8+
Default::default()
9+
}
10+
11+
fn main() {
12+
let x = test::<33>();
13+
assert_eq!(x, [0; 32]);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:30
3+
|
4+
LL | fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
5+
| ^^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)