add test
This commit is contained in:
parent
0b095a60d2
commit
30b21b758a
2 changed files with 35 additions and 2 deletions
|
@ -9,7 +9,7 @@ use rustc_hir::def_id::LocalDefId;
|
|||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::{sym, Span};
|
||||
|
||||
pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
||||
use rustc_hir::*;
|
||||
|
@ -295,7 +295,11 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
})
|
||||
}
|
||||
GenericParamKind::Const { default, .. } => {
|
||||
if !matches!(allow_defaults, Defaults::Allowed) && default.is_some() {
|
||||
// `rustc_host` effect params are allowed to have defaults.
|
||||
if !matches!(allow_defaults, Defaults::Allowed)
|
||||
&& default.is_some()
|
||||
&& !tcx.has_attr(param.def_id, sym::rustc_host)
|
||||
{
|
||||
tcx.sess.span_err(
|
||||
param.span,
|
||||
"defaults for const parameters are only allowed in \
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// check-pass
|
||||
|
||||
// gate-test-effects
|
||||
// ^ effects doesn't have a gate so we will trick tidy into thinking this is a gate test
|
||||
|
||||
#![feature(const_trait_impl, effects, rustc_attrs)]
|
||||
|
||||
// ensure we are passing in the correct host effect in always const contexts.
|
||||
|
||||
pub const fn hmm</* T, */ #[rustc_host] const host: bool = true>() -> usize {
|
||||
if host {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
let x = hmm();
|
||||
assert!(0 == x);
|
||||
};
|
||||
|
||||
/* FIXME(effects)
|
||||
pub const fn uwu(x: [u8; hmm::<()>()]) {
|
||||
let [] = x;
|
||||
}
|
||||
*/
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Reference in a new issue