Skip to content

Commit

Permalink
fix tidy, small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Sep 10, 2020
1 parent 8667f93 commit 300b0ac
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
9 changes: 2 additions & 7 deletions compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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]);
}
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 300b0ac

Please sign in to comment.