Auto merge of #77557 - Dylan-DPC:rollup-aib9ptp, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #75853 (Use more intra-doc-links in `core::fmt`) - #75928 (Remove trait_selection error message in specific case) - #76329 (Add check for doc alias attribute at crate level) - #77219 (core::global_allocator docs link to std::alloc::GlobalAlloc) - #77395 (BTreeMap: admit the existence of leaf edges in comments) - #77407 (Improve build-manifest to work with the improved promote-release) - #77426 (Include scope id in SocketAddrV6::Display) - #77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`) - #77471 (BTreeMap: refactoring around edges, missed spots) - #77512 (Allow `Abort` terminators in all const-contexts) - #77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter) Failed merges: r? `@ghost`
This commit is contained in:
commit
efbaa41306
72
Cargo.lock
72
Cargo.lock
|
@ -183,7 +183,16 @@ dependencies = [
|
||||||
"block-padding",
|
"block-padding",
|
||||||
"byte-tools",
|
"byte-tools",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"generic-array",
|
"generic-array 0.12.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array 0.14.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -233,8 +242,11 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
"hex 0.4.2",
|
||||||
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
"tar",
|
"tar",
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
@ -687,6 +699,12 @@ version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
|
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpuid-bool"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crates-io"
|
name = "crates-io"
|
||||||
version = "0.31.1"
|
version = "0.31.1"
|
||||||
|
@ -884,7 +902,16 @@ version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array",
|
"generic-array 0.12.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array 0.14.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1166,6 +1193,16 @@ dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getopts"
|
name = "getopts"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
|
@ -1835,9 +1872,9 @@ version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8"
|
checksum = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer",
|
"block-buffer 0.7.3",
|
||||||
"digest",
|
"digest 0.8.1",
|
||||||
"opaque-debug",
|
"opaque-debug 0.2.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2097,6 +2134,12 @@ version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "opaque-debug"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "open"
|
name = "open"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -4362,10 +4405,23 @@ version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer",
|
"block-buffer 0.7.3",
|
||||||
"digest",
|
"digest 0.8.1",
|
||||||
"fake-simd",
|
"fake-simd",
|
||||||
"opaque-debug",
|
"opaque-debug 0.2.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha2"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer 0.9.0",
|
||||||
|
"cfg-if",
|
||||||
|
"cpuid-bool",
|
||||||
|
"digest 0.9.0",
|
||||||
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -581,7 +581,7 @@ declare_features! (
|
||||||
/// Allows `if let` guard in match arms.
|
/// Allows `if let` guard in match arms.
|
||||||
(active, if_let_guard, "1.47.0", Some(51114), None),
|
(active, if_let_guard, "1.47.0", Some(51114), None),
|
||||||
|
|
||||||
/// Allows non trivial generic constants which have to be manually propageted upwards.
|
/// Allows non-trivial generic constants which have to be manually propageted upwards.
|
||||||
(active, const_evaluatable_checked, "1.48.0", Some(76560), None),
|
(active, const_evaluatable_checked, "1.48.0", Some(76560), None),
|
||||||
|
|
||||||
/// Allows basic arithmetic on floating point types in a `const fn`.
|
/// Allows basic arithmetic on floating point types in a `const fn`.
|
||||||
|
|
|
@ -341,9 +341,7 @@ impl<T> PerNS<Option<T>> {
|
||||||
|
|
||||||
/// Returns an iterator over the items which are `Some`.
|
/// Returns an iterator over the items which are `Some`.
|
||||||
pub fn present_items(self) -> impl Iterator<Item = T> {
|
pub fn present_items(self) -> impl Iterator<Item = T> {
|
||||||
use std::iter::once;
|
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
|
||||||
|
|
||||||
once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@ use crate::{Item, ItemKind, TraitItem, TraitItemKind};
|
||||||
|
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum MethodKind {
|
pub enum MethodKind {
|
||||||
Trait { body: bool },
|
Trait { body: bool },
|
||||||
Inherent,
|
Inherent,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum Target {
|
pub enum Target {
|
||||||
ExternCrate,
|
ExternCrate,
|
||||||
Use,
|
Use,
|
||||||
|
|
|
@ -41,18 +41,6 @@ pub trait NonConstOp: std::fmt::Debug {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
|
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Abort;
|
|
||||||
impl NonConstOp for Abort {
|
|
||||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
|
||||||
mcf_status_in_item(ccx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
|
||||||
mcf_build_error(ccx, span, "abort is not stable in const fn")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FloatingPointOp;
|
pub struct FloatingPointOp;
|
||||||
impl NonConstOp for FloatingPointOp {
|
impl NonConstOp for FloatingPointOp {
|
||||||
|
|
|
@ -434,11 +434,13 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
||||||
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
|
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
|
||||||
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
||||||
|
|
||||||
// Just as the old checker did, we skip const-checking basic blocks on the unwind path.
|
// We don't const-check basic blocks on the cleanup path since we never unwind during
|
||||||
// These blocks often drop locals that would otherwise be returned from the function.
|
// const-eval: a panic causes an immediate compile error. In other words, cleanup blocks
|
||||||
|
// are unreachable during const-eval.
|
||||||
//
|
//
|
||||||
// FIXME: This shouldn't be unsound since a panic at compile time will cause a compiler
|
// We can't be more conservative (e.g., by const-checking cleanup blocks anyways) because
|
||||||
// error anyway, but maybe we should do more here?
|
// locals that would never be dropped during normal execution are sometimes dropped during
|
||||||
|
// unwinding, which means backwards-incompatible live-drop errors.
|
||||||
if block.is_cleanup {
|
if block.is_cleanup {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -874,12 +876,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
|
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
|
||||||
TerminatorKind::Abort => self.check_op(ops::Abort),
|
|
||||||
|
|
||||||
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
|
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
|
||||||
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
|
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TerminatorKind::Abort => {
|
||||||
|
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
|
||||||
|
span_bug!(self.span, "`Abort` terminator outside of cleanup block")
|
||||||
|
}
|
||||||
|
|
||||||
TerminatorKind::Assert { .. }
|
TerminatorKind::Assert { .. }
|
||||||
| TerminatorKind::FalseEdge { .. }
|
| TerminatorKind::FalseEdge { .. }
|
||||||
| TerminatorKind::FalseUnwind { .. }
|
| TerminatorKind::FalseUnwind { .. }
|
||||||
|
|
|
@ -13,12 +13,14 @@ use rustc_errors::{pluralize, struct_span_err};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||||
use rustc_hir::{self, FnSig, ForeignItem, ForeignItemKind, HirId, Item, ItemKind, TraitItem};
|
use rustc_hir::{
|
||||||
|
self, FnSig, ForeignItem, ForeignItemKind, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID,
|
||||||
|
};
|
||||||
use rustc_hir::{MethodKind, Target};
|
use rustc_hir::{MethodKind, Target};
|
||||||
use rustc_session::lint::builtin::{CONFLICTING_REPR_HINTS, UNUSED_ATTRIBUTES};
|
use rustc_session::lint::builtin::{CONFLICTING_REPR_HINTS, UNUSED_ATTRIBUTES};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
pub(crate) fn target_from_impl_item<'tcx>(
|
pub(crate) fn target_from_impl_item<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
@ -333,6 +335,17 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
.emit();
|
.emit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if CRATE_HIR_ID == hir_id {
|
||||||
|
self.tcx
|
||||||
|
.sess
|
||||||
|
.struct_span_err(
|
||||||
|
meta.span(),
|
||||||
|
"`#![doc(alias = \"...\")]` isn't allowed as a crate \
|
||||||
|
level attribute",
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -808,9 +821,46 @@ fn is_c_like_enum(item: &Item<'_>) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
|
||||||
|
const ATTRS_TO_CHECK: &[Symbol] = &[
|
||||||
|
sym::macro_export,
|
||||||
|
sym::repr,
|
||||||
|
sym::path,
|
||||||
|
sym::automatically_derived,
|
||||||
|
sym::start,
|
||||||
|
sym::main,
|
||||||
|
];
|
||||||
|
|
||||||
|
for attr in attrs {
|
||||||
|
for attr_to_check in ATTRS_TO_CHECK {
|
||||||
|
if tcx.sess.check_name(attr, *attr_to_check) {
|
||||||
|
tcx.sess
|
||||||
|
.struct_span_err(
|
||||||
|
attr.span,
|
||||||
|
&format!(
|
||||||
|
"`{}` attribute cannot be used at crate level",
|
||||||
|
attr_to_check.to_ident_string()
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||||
tcx.hir()
|
tcx.hir()
|
||||||
.visit_item_likes_in_module(module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor());
|
.visit_item_likes_in_module(module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor());
|
||||||
|
if module_def_id.is_top_level_module() {
|
||||||
|
CheckAttrVisitor { tcx }.check_attributes(
|
||||||
|
CRATE_HIR_ID,
|
||||||
|
tcx.hir().krate_attrs(),
|
||||||
|
&DUMMY_SP,
|
||||||
|
Target::Mod,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
|
|
|
@ -78,29 +78,38 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType)
|
||||||
// Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs`
|
// Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs`
|
||||||
// (with `ast::Item`), so make sure to keep them in sync.
|
// (with `ast::Item`), so make sure to keep them in sync.
|
||||||
fn entry_point_type(sess: &Session, item: &Item<'_>, at_root: bool) -> EntryPointType {
|
fn entry_point_type(sess: &Session, item: &Item<'_>, at_root: bool) -> EntryPointType {
|
||||||
match item.kind {
|
if sess.contains_name(&item.attrs, sym::start) {
|
||||||
ItemKind::Fn(..) => {
|
EntryPointType::Start
|
||||||
if sess.contains_name(&item.attrs, sym::start) {
|
} else if sess.contains_name(&item.attrs, sym::main) {
|
||||||
EntryPointType::Start
|
EntryPointType::MainAttr
|
||||||
} else if sess.contains_name(&item.attrs, sym::main) {
|
} else if item.ident.name == sym::main {
|
||||||
EntryPointType::MainAttr
|
if at_root {
|
||||||
} else if item.ident.name == sym::main {
|
// This is a top-level function so can be `main`.
|
||||||
if at_root {
|
EntryPointType::MainNamed
|
||||||
// This is a top-level function so can be `main`.
|
} else {
|
||||||
EntryPointType::MainNamed
|
EntryPointType::OtherMain
|
||||||
} else {
|
|
||||||
EntryPointType::OtherMain
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
EntryPointType::None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => EntryPointType::None,
|
} else {
|
||||||
|
EntryPointType::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
|
||||||
|
sess.struct_span_err(span, &format!("`{}` attribute can only be used on functions", attr))
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
|
||||||
fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
||||||
match entry_point_type(&ctxt.session, item, at_root) {
|
match entry_point_type(&ctxt.session, item, at_root) {
|
||||||
|
EntryPointType::None => (),
|
||||||
|
_ if !matches!(item.kind, ItemKind::Fn(..)) => {
|
||||||
|
if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::start) {
|
||||||
|
throw_attr_err(&ctxt.session, attr.span, "start");
|
||||||
|
}
|
||||||
|
if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::main) {
|
||||||
|
throw_attr_err(&ctxt.session, attr.span, "main");
|
||||||
|
}
|
||||||
|
}
|
||||||
EntryPointType::MainNamed => {
|
EntryPointType::MainNamed => {
|
||||||
if ctxt.main_fn.is_none() {
|
if ctxt.main_fn.is_none() {
|
||||||
ctxt.main_fn = Some((item.hir_id, item.span));
|
ctxt.main_fn = Some((item.hir_id, item.span));
|
||||||
|
@ -137,7 +146,6 @@ fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EntryPointType::None => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ impl<'a> Resolver<'a> {
|
||||||
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
|
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
|
||||||
let mut err = self.session.struct_span_err(
|
let mut err = self.session.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"generic parameters must not be used inside of non trivial constant values",
|
"generic parameters must not be used inside of non-trivial constant values",
|
||||||
);
|
);
|
||||||
err.span_label(
|
err.span_label(
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -218,7 +218,7 @@ enum ResolutionError<'a> {
|
||||||
ParamInTyOfConstParam(Symbol),
|
ParamInTyOfConstParam(Symbol),
|
||||||
/// constant values inside of type parameter defaults must not depend on generic parameters.
|
/// constant values inside of type parameter defaults must not depend on generic parameters.
|
||||||
ParamInAnonConstInTyDefault(Symbol),
|
ParamInAnonConstInTyDefault(Symbol),
|
||||||
/// generic parameters must not be used inside of non trivial constant values.
|
/// generic parameters must not be used inside of non-trivial constant values.
|
||||||
///
|
///
|
||||||
/// This error is only emitted when using `min_const_generics`.
|
/// This error is only emitted when using `min_const_generics`.
|
||||||
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
|
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
|
||||||
|
|
|
@ -518,7 +518,7 @@ declare_lint! {
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![macro_export]
|
/// #![ignore]
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// {{produces}}
|
/// {{produces}}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
//! This API is completely unstable and subject to change.
|
//! This API is completely unstable and subject to change.
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
|
#![feature(array_value_iter)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
|
|
|
@ -1907,6 +1907,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
|
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
|
||||||
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
||||||
let ty = parent_trait_ref.skip_binder().self_ty();
|
let ty = parent_trait_ref.skip_binder().self_ty();
|
||||||
|
if parent_trait_ref.references_error() {
|
||||||
|
err.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
err.note(&format!("required because it appears within the type `{}`", ty));
|
err.note(&format!("required because it appears within the type `{}`", ty));
|
||||||
obligated_types.push(ty);
|
obligated_types.push(ty);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
use std::array;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation};
|
pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation};
|
||||||
|
@ -652,8 +653,7 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
let caller_bounds: Vec<Predicate<'tcx>> = param_env
|
let caller_bounds: Vec<Predicate<'tcx>> = param_env
|
||||||
.caller_bounds()
|
.caller_bounds()
|
||||||
.iter()
|
.iter()
|
||||||
.chain(iter::once(unsize_predicate))
|
.chain(array::IntoIter::new([unsize_predicate, trait_predicate]))
|
||||||
.chain(iter::once(trait_predicate))
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
|
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
|
||||||
|
|
|
@ -562,7 +562,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
.args
|
.args
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|arg| match arg {
|
.filter_map(|arg| match arg {
|
||||||
GenericArg::Type(_) => Some(arg.span()),
|
GenericArg::Type(_) | GenericArg::Const(_) => Some(arg.span()),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
|
@ -35,8 +35,8 @@ use rustc_trait_selection::traits::error_reporting::report_object_safety_error;
|
||||||
use rustc_trait_selection::traits::wf::object_region_bounds;
|
use rustc_trait_selection::traits::wf::object_region_bounds;
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::array;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::iter;
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -1346,7 +1346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
|
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
|
||||||
|
|
||||||
let is_equality = is_equality();
|
let is_equality = is_equality();
|
||||||
let bounds = iter::once(bound).chain(iter::once(bound2)).chain(matching_candidates);
|
let bounds = array::IntoIter::new([bound, bound2]).chain(matching_candidates);
|
||||||
let mut err = if is_equality.is_some() {
|
let mut err = if is_equality.is_some() {
|
||||||
// More specific Error Index entry.
|
// More specific Error Index entry.
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
|
|
|
@ -222,6 +222,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||||
hir::GenericParamKind::Const { .. } => {
|
hir::GenericParamKind::Const { .. } => {
|
||||||
let def_id = self.tcx.hir().local_def_id(param.hir_id);
|
let def_id = self.tcx.hir().local_def_id(param.hir_id);
|
||||||
self.tcx.ensure().type_of(def_id);
|
self.tcx.ensure().type_of(def_id);
|
||||||
|
// FIXME(const_generics:defaults)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ This API is completely unstable and subject to change.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
|
#![feature(array_value_iter)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
|
|
|
@ -9,11 +9,8 @@
|
||||||
// struct Node<K, V, height: usize> {
|
// struct Node<K, V, height: usize> {
|
||||||
// keys: [K; 2 * B - 1],
|
// keys: [K; 2 * B - 1],
|
||||||
// vals: [V; 2 * B - 1],
|
// vals: [V; 2 * B - 1],
|
||||||
// edges: if height > 0 {
|
// edges: [if height > 0 { Box<Node<K, V, height - 1>> } else { () }; 2 * B],
|
||||||
// [Box<Node<K, V, height - 1>>; 2 * B]
|
// parent: Option<(NonNull<Node<K, V, height + 1>>, u16)>,
|
||||||
// } else { () },
|
|
||||||
// parent: Option<NonNull<Node<K, V, height + 1>>>,
|
|
||||||
// parent_idx: u16,
|
|
||||||
// len: u16,
|
// len: u16,
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
|
@ -28,8 +25,8 @@
|
||||||
//
|
//
|
||||||
// - Trees must have uniform depth/height. This means that every path down to a leaf from a
|
// - Trees must have uniform depth/height. This means that every path down to a leaf from a
|
||||||
// given node has exactly the same length.
|
// given node has exactly the same length.
|
||||||
// - A node of length `n` has `n` keys, `n` values, and (in an internal node) `n + 1` edges.
|
// - A node of length `n` has `n` keys, `n` values, and `n + 1` edges.
|
||||||
// This implies that even an empty internal node has at least one edge.
|
// This implies that even an empty node has at least one edge.
|
||||||
|
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
@ -298,9 +295,8 @@ impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
|
impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
|
||||||
/// Finds the length of the node. This is the number of keys or values. In an
|
/// Finds the length of the node. This is the number of keys or values.
|
||||||
/// internal node, the number of edges is `len() + 1`.
|
/// The number of edges is `len() + 1`.
|
||||||
/// For any node, the number of possible edge handles is also `len() + 1`.
|
|
||||||
/// Note that, despite being safe, calling this function can have the side effect
|
/// Note that, despite being safe, calling this function can have the side effect
|
||||||
/// of invalidating mutable references that unsafe code has created.
|
/// of invalidating mutable references that unsafe code has created.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
|
@ -321,9 +317,6 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exposes the leaf portion of any leaf or internal node.
|
/// Exposes the leaf portion of any leaf or internal node.
|
||||||
/// If the node is a leaf, this function simply opens up its data.
|
|
||||||
/// If the node is an internal node, so not a leaf, it does have all the data a leaf has
|
|
||||||
/// (header, keys and values), and this function exposes that.
|
|
||||||
///
|
///
|
||||||
/// Returns a raw ptr to avoid invalidating other references to this node,
|
/// Returns a raw ptr to avoid invalidating other references to this node,
|
||||||
/// which is possible when BorrowType is marker::ValMut.
|
/// which is possible when BorrowType is marker::ValMut.
|
||||||
|
@ -471,9 +464,6 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exposes the leaf portion of any leaf or internal node for writing.
|
/// Exposes the leaf portion of any leaf or internal node for writing.
|
||||||
/// If the node is a leaf, this function simply opens up its data.
|
|
||||||
/// If the node is an internal node, so not a leaf, it does have all the data a leaf has
|
|
||||||
/// (header, keys and values), and this function exposes that.
|
|
||||||
///
|
///
|
||||||
/// We don't need to return a raw ptr because we have unique access to the entire node.
|
/// We don't need to return a raw ptr because we have unique access to the entire node.
|
||||||
fn as_leaf_mut(&mut self) -> &'a mut LeafNode<K, V> {
|
fn as_leaf_mut(&mut self) -> &'a mut LeafNode<K, V> {
|
||||||
|
@ -484,7 +474,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// The node has more than `idx` initialized elements.
|
/// The node has more than `idx` initialized elements.
|
||||||
pub unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
|
unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
|
||||||
unsafe { self.reborrow_mut().into_key_mut_at(idx) }
|
unsafe { self.reborrow_mut().into_key_mut_at(idx) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +482,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// The node has more than `idx` initialized elements.
|
/// The node has more than `idx` initialized elements.
|
||||||
pub unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
|
unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
|
||||||
unsafe { self.reborrow_mut().into_val_mut_at(idx) }
|
unsafe { self.reborrow_mut().into_val_mut_at(idx) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +645,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
|
||||||
|
|
||||||
/// Adds a key/value pair, and an edge to go to the left of that pair,
|
/// Adds a key/value pair, and an edge to go to the left of that pair,
|
||||||
/// to the beginning of the node.
|
/// to the beginning of the node.
|
||||||
pub fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
|
fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
|
||||||
assert!(edge.height == self.height - 1);
|
assert!(edge.height == self.height - 1);
|
||||||
assert!(self.len() < CAPACITY);
|
assert!(self.len() < CAPACITY);
|
||||||
|
|
||||||
|
@ -679,9 +669,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
|
impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
|
||||||
/// Removes a key/value pair from the end of this node and returns the pair.
|
/// Removes a key/value pair from the end of the node and returns the pair.
|
||||||
/// If this is an internal node, also removes the edge that was to the right
|
/// Also removes the edge that was to the right of that pair and, if the node
|
||||||
/// of that pair and returns the orphaned node that this edge owned.
|
/// is internal, returns the orphaned subtree that this edge owned.
|
||||||
fn pop(&mut self) -> (K, V, Option<Root<K, V>>) {
|
fn pop(&mut self) -> (K, V, Option<Root<K, V>>) {
|
||||||
debug_assert!(self.len() > 0);
|
debug_assert!(self.len() > 0);
|
||||||
|
|
||||||
|
@ -705,9 +695,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes a key/value pair from the beginning of this node and returns the pair.
|
/// Removes a key/value pair from the beginning of the node and returns the pair.
|
||||||
/// If this is an internal node, also removes the edge that was to the left
|
/// Also removes the edge that was to the left of that pair and, if the node is
|
||||||
/// of that pair and returns the orphaned node that this edge owned.
|
/// internal, returns the orphaned subtree that this edge owned.
|
||||||
fn pop_front(&mut self) -> (K, V, Option<Root<K, V>>) {
|
fn pop_front(&mut self) -> (K, V, Option<Root<K, V>>) {
|
||||||
debug_assert!(self.len() > 0);
|
debug_assert!(self.len() > 0);
|
||||||
|
|
||||||
|
@ -1011,18 +1001,18 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
|
||||||
let (middle_kv_idx, insertion) = splitpoint(self.idx);
|
let (middle_kv_idx, insertion) = splitpoint(self.idx);
|
||||||
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
|
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
|
||||||
let (mut left, k, v, mut right) = middle.split();
|
let (mut left, k, v, mut right) = middle.split();
|
||||||
match insertion {
|
let mut insertion_edge = match insertion {
|
||||||
InsertionPlace::Left(insert_idx) => unsafe {
|
InsertionPlace::Left(insert_idx) => unsafe {
|
||||||
Handle::new_edge(left.reborrow_mut(), insert_idx).insert_fit(key, val, edge);
|
Handle::new_edge(left.reborrow_mut(), insert_idx)
|
||||||
},
|
},
|
||||||
InsertionPlace::Right(insert_idx) => unsafe {
|
InsertionPlace::Right(insert_idx) => unsafe {
|
||||||
Handle::new_edge(
|
Handle::new_edge(
|
||||||
right.node_as_mut().cast_unchecked::<marker::Internal>(),
|
right.node_as_mut().cast_unchecked::<marker::Internal>(),
|
||||||
insert_idx,
|
insert_idx,
|
||||||
)
|
)
|
||||||
.insert_fit(key, val, edge);
|
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
insertion_edge.insert_fit(key, val, edge);
|
||||||
InsertResult::Split(SplitResult { left: left.forget_type(), k, v, right })
|
InsertResult::Split(SplitResult { left: left.forget_type(), k, v, right })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
// ignore-tidy-filelength
|
// ignore-tidy-filelength
|
||||||
|
|
||||||
|
use core::array;
|
||||||
use core::cmp::{self, Ordering};
|
use core::cmp::{self, Ordering};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
use core::iter::{once, repeat_with, FromIterator, FusedIterator};
|
use core::iter::{repeat_with, FromIterator, FusedIterator};
|
||||||
use core::mem::{self, replace, ManuallyDrop};
|
use core::mem::{self, replace, ManuallyDrop};
|
||||||
use core::ops::{Index, IndexMut, Range, RangeBounds, Try};
|
use core::ops::{Index, IndexMut, Range, RangeBounds, Try};
|
||||||
use core::ptr::{self, NonNull};
|
use core::ptr::{self, NonNull};
|
||||||
|
@ -99,7 +100,7 @@ impl<'a, 'b, T> PairSlices<'a, 'b, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remainder(self) -> impl Iterator<Item = &'b [T]> {
|
fn remainder(self) -> impl Iterator<Item = &'b [T]> {
|
||||||
once(self.b0).chain(once(self.b1))
|
array::IntoIter::new([self.b0, self.b1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
#![cfg_attr(test, feature(new_uninit))]
|
#![cfg_attr(test, feature(new_uninit))]
|
||||||
#![feature(allocator_api)]
|
#![feature(allocator_api)]
|
||||||
#![feature(array_chunks)]
|
#![feature(array_chunks)]
|
||||||
|
#![feature(array_value_iter)]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
#![feature(allow_internal_unstable)]
|
#![feature(allow_internal_unstable)]
|
||||||
#![feature(arbitrary_self_types)]
|
#![feature(arbitrary_self_types)]
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub struct Error;
|
||||||
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
|
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
|
||||||
/// [`io::Write`] trait is favored over implementing this trait.
|
/// [`io::Write`] trait is favored over implementing this trait.
|
||||||
///
|
///
|
||||||
/// [`write!`]: ../../std/macro.write.html
|
/// [`write!`]: crate::write!
|
||||||
/// [`io::Write`]: ../../std/io/trait.Write.html
|
/// [`io::Write`]: ../../std/io/trait.Write.html
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait Write {
|
pub trait Write {
|
||||||
|
@ -1058,7 +1058,7 @@ pub trait UpperExp {
|
||||||
/// assert_eq!(output, "Hello world!");
|
/// assert_eq!(output, "Hello world!");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`write!`]: ../../std/macro.write.html
|
/// [`write!`]: crate::write!
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
|
pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
|
||||||
let mut formatter = Formatter {
|
let mut formatter = Formatter {
|
||||||
|
@ -1886,7 +1886,7 @@ impl<'a> Formatter<'a> {
|
||||||
/// assert_eq!(format!("{:?}", Foo(vec![10, 11])), "{10, 11}");
|
/// assert_eq!(format!("{:?}", Foo(vec![10, 11])), "{10, 11}");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`format_args!`]: ../../std/macro.format_args.html
|
/// [`format_args!`]: crate::format_args
|
||||||
///
|
///
|
||||||
/// In this more complex example, we use [`format_args!`] and `.debug_set()`
|
/// In this more complex example, we use [`format_args!`] and `.debug_set()`
|
||||||
/// to build a list of match arms:
|
/// to build a list of match arms:
|
||||||
|
|
|
@ -1365,6 +1365,8 @@ pub(crate) mod builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attribute macro applied to a static to register it as a global allocator.
|
/// Attribute macro applied to a static to register it as a global allocator.
|
||||||
|
///
|
||||||
|
/// See also [`std::alloc::GlobalAlloc`](../std/alloc/trait.GlobalAlloc.html).
|
||||||
#[stable(feature = "global_allocator", since = "1.28.0")]
|
#[stable(feature = "global_allocator", since = "1.28.0")]
|
||||||
#[allow_internal_unstable(rustc_attrs)]
|
#[allow_internal_unstable(rustc_attrs)]
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
|
|
|
@ -623,19 +623,27 @@ impl fmt::Display for SocketAddrV6 {
|
||||||
// Fast path: if there's no alignment stuff, write to the output
|
// Fast path: if there's no alignment stuff, write to the output
|
||||||
// buffer directly
|
// buffer directly
|
||||||
if f.precision().is_none() && f.width().is_none() {
|
if f.precision().is_none() && f.width().is_none() {
|
||||||
write!(f, "[{}]:{}", self.ip(), self.port())
|
match self.scope_id() {
|
||||||
|
0 => write!(f, "[{}]:{}", self.ip(), self.port()),
|
||||||
|
scope_id => write!(f, "[{}%{}]:{}", self.ip(), scope_id, self.port()),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const IPV6_SOCKET_BUF_LEN: usize = (4 * 8) // The address
|
const IPV6_SOCKET_BUF_LEN: usize = (4 * 8) // The address
|
||||||
+ 7 // The colon separators
|
+ 7 // The colon separators
|
||||||
+ 2 // The brackets
|
+ 2 // The brackets
|
||||||
|
+ 1 + 10 // The scope id
|
||||||
+ 1 + 5; // The port
|
+ 1 + 5; // The port
|
||||||
|
|
||||||
let mut buf = [0; IPV6_SOCKET_BUF_LEN];
|
let mut buf = [0; IPV6_SOCKET_BUF_LEN];
|
||||||
let mut buf_slice = &mut buf[..];
|
let mut buf_slice = &mut buf[..];
|
||||||
|
|
||||||
|
match self.scope_id() {
|
||||||
|
0 => write!(buf_slice, "[{}]:{}", self.ip(), self.port()),
|
||||||
|
scope_id => write!(buf_slice, "[{}%{}]:{}", self.ip(), scope_id, self.port()),
|
||||||
|
}
|
||||||
// Unwrap is fine because writing to a sufficiently-sized
|
// Unwrap is fine because writing to a sufficiently-sized
|
||||||
// buffer is infallible
|
// buffer is infallible
|
||||||
write!(buf_slice, "[{}]:{}", self.ip(), self.port()).unwrap();
|
.unwrap();
|
||||||
let len = IPV6_SOCKET_BUF_LEN - buf_slice.len();
|
let len = IPV6_SOCKET_BUF_LEN - buf_slice.len();
|
||||||
|
|
||||||
// This unsafe is OK because we know what is being written to the buffer
|
// This unsafe is OK because we know what is being written to the buffer
|
||||||
|
|
|
@ -178,13 +178,21 @@ fn socket_v4_to_str() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn socket_v6_to_str() {
|
fn socket_v6_to_str() {
|
||||||
let socket: SocketAddrV6 = "[2a02:6b8:0:1::1]:53".parse().unwrap();
|
let mut socket = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53, 0, 0);
|
||||||
|
|
||||||
assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53");
|
assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53");
|
||||||
assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53 ");
|
assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53 ");
|
||||||
assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1]:53");
|
assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1]:53");
|
||||||
assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1]:53 ");
|
assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1]:53 ");
|
||||||
assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::");
|
assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::");
|
||||||
|
|
||||||
|
socket.set_scope_id(5);
|
||||||
|
|
||||||
|
assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1%5]:53");
|
||||||
|
assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1%5]:53 ");
|
||||||
|
assert_eq!(format!("{:>24}", socket), " [2a02:6b8:0:1::1%5]:53");
|
||||||
|
assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1%5]:53 ");
|
||||||
|
assert_eq!(format!("{:.18}", socket), "[2a02:6b8:0:1::1%5");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -477,7 +477,7 @@ impl<'a> Builder<'a> {
|
||||||
install::Src,
|
install::Src,
|
||||||
install::Rustc
|
install::Rustc
|
||||||
),
|
),
|
||||||
Kind::Run => describe!(run::ExpandYamlAnchors,),
|
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest,),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn distdir(builder: &Builder<'_>) -> PathBuf {
|
pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf {
|
||||||
builder.out.join("dist")
|
builder.out.join("dist")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2371,6 +2371,7 @@ impl Step for HashSign {
|
||||||
cmd.arg(addr);
|
cmd.arg(addr);
|
||||||
cmd.arg(&builder.config.channel);
|
cmd.arg(&builder.config.channel);
|
||||||
cmd.arg(&builder.src);
|
cmd.arg(&builder.src);
|
||||||
|
cmd.env("BUILD_MANIFEST_LEGACY", "1");
|
||||||
|
|
||||||
builder.create_dir(&distdir(builder));
|
builder.create_dir(&distdir(builder));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
|
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
|
||||||
|
use crate::dist::distdir;
|
||||||
use crate::tool::Tool;
|
use crate::tool::Tool;
|
||||||
|
use build_helper::output;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -41,3 +43,43 @@ fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
|
pub struct BuildManifest;
|
||||||
|
|
||||||
|
impl Step for BuildManifest {
|
||||||
|
type Output = ();
|
||||||
|
const ONLY_HOSTS: bool = true;
|
||||||
|
|
||||||
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
|
run.path("src/tools/build-manifest")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_run(run: RunConfig<'_>) {
|
||||||
|
run.builder.ensure(BuildManifest);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(self, builder: &Builder<'_>) {
|
||||||
|
// This gets called by `promote-release`
|
||||||
|
// (https://github.com/rust-lang/promote-release).
|
||||||
|
let mut cmd = builder.tool_cmd(Tool::BuildManifest);
|
||||||
|
let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
|
||||||
|
panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n")
|
||||||
|
});
|
||||||
|
let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| {
|
||||||
|
panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n")
|
||||||
|
});
|
||||||
|
|
||||||
|
let today = output(Command::new("date").arg("+%Y-%m-%d"));
|
||||||
|
|
||||||
|
cmd.arg(sign);
|
||||||
|
cmd.arg(distdir(builder));
|
||||||
|
cmd.arg(today.trim());
|
||||||
|
cmd.arg(addr);
|
||||||
|
cmd.arg(&builder.config.channel);
|
||||||
|
cmd.arg(&builder.src);
|
||||||
|
|
||||||
|
builder.create_dir(&distdir(builder));
|
||||||
|
builder.run(&mut cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#![feature(doc_alias)]
|
||||||
|
|
||||||
|
#![doc(alias = "crate-level-not-working")] //~ ERROR
|
||||||
|
|
||||||
|
#[doc(alias = "shouldn't work!")] //~ ERROR
|
||||||
|
pub fn foo() {}
|
|
@ -0,0 +1,14 @@
|
||||||
|
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
|
||||||
|
--> $DIR/doc-alias-crate-level.rs:5:7
|
||||||
|
|
|
||||||
|
LL | #[doc(alias = "shouldn't work!")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute
|
||||||
|
--> $DIR/doc-alias-crate-level.rs:3:8
|
||||||
|
|
|
||||||
|
LL | #![doc(alias = "crate-level-not-working")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
||||||
|
|
|
|
||||||
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||||
|
@ -6,7 +6,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
||||||
|
|
|
|
||||||
LL | arr: [u8; CFG.arr_size],
|
LL | arr: [u8; CFG.arr_size],
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -19,7 +19,7 @@ struct B<const CFG: Config> {
|
||||||
//[min]~^ ERROR `Config` is forbidden
|
//[min]~^ ERROR `Config` is forbidden
|
||||||
arr: [u8; CFG.arr_size],
|
arr: [u8; CFG.arr_size],
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||||
}
|
}
|
||||||
|
|
||||||
const C: Config = Config { arr_size: 5 };
|
const C: Config = Config { arr_size: 5 };
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||||
|
--> $DIR/const-argument-if-length.rs:8:28
|
||||||
|
|
|
||||||
|
LL | pub const fn is_zst<T: ?Sized>() -> usize {
|
||||||
|
| - this type parameter needs to be `Sized`
|
||||||
|
LL | if std::mem::size_of::<T>() == 0 {
|
||||||
|
| ^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||||
|
|
|
||||||
|
LL | pub const fn size_of<T>() -> usize {
|
||||||
|
| - required by this bound in `std::mem::size_of`
|
||||||
|
|
||||||
|
error[E0080]: evaluation of constant value failed
|
||||||
|
--> $DIR/const-argument-if-length.rs:19:15
|
||||||
|
|
|
||||||
|
LL | pad: [u8; is_zst::<T>()],
|
||||||
|
| ^^^^^^^^^^^^^ referenced constant has errors
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||||
|
--> $DIR/const-argument-if-length.rs:17:12
|
||||||
|
|
|
||||||
|
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||||
|
| - this type parameter needs to be `Sized`
|
||||||
|
LL | value: T,
|
||||||
|
| ^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= note: only the last field of a struct may have a dynamically sized type
|
||||||
|
= help: change the field's type to have a statically known size
|
||||||
|
help: borrowed types always have a statically known size
|
||||||
|
|
|
||||||
|
LL | value: &T,
|
||||||
|
| ^
|
||||||
|
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
||||||
|
|
|
||||||
|
LL | value: Box<T>,
|
||||||
|
| ^^^^ ^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0080, E0277.
|
||||||
|
For more information about an error, try `rustc --explain E0080`.
|
|
@ -0,0 +1,30 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/const-argument-if-length.rs:19:24
|
||||||
|
|
|
||||||
|
LL | pad: [u8; is_zst::<T>()],
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||||
|
--> $DIR/const-argument-if-length.rs:17:12
|
||||||
|
|
|
||||||
|
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||||
|
| - this type parameter needs to be `Sized`
|
||||||
|
LL | value: T,
|
||||||
|
| ^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= note: only the last field of a struct may have a dynamically sized type
|
||||||
|
= help: change the field's type to have a statically known size
|
||||||
|
help: borrowed types always have a statically known size
|
||||||
|
|
|
||||||
|
LL | value: &T,
|
||||||
|
| ^
|
||||||
|
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
||||||
|
|
|
||||||
|
LL | value: Box<T>,
|
||||||
|
| ^^^^ ^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
|
@ -0,0 +1,24 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
pub const fn is_zst<T: ?Sized>() -> usize {
|
||||||
|
if std::mem::size_of::<T>() == 0 {
|
||||||
|
//[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AtLeastByte<T: ?Sized> {
|
||||||
|
value: T,
|
||||||
|
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||||
|
pad: [u8; is_zst::<T>()],
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ ERROR evaluation of constant value failed
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
||||||
|
|
|
|
||||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#![cfg_attr(min, feature(min_const_generics))]
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
type Arr<const N: usize> = [u8; N - 1];
|
type Arr<const N: usize> = [u8; N - 1];
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
|
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
|
||||||
//[full]~^ ERROR constant expression depends
|
//[full]~^ ERROR constant expression depends
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/simple.rs:8:53
|
--> $DIR/simple.rs:8:53
|
||||||
|
|
|
|
||||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||||
|
@ -6,7 +6,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/simple.rs:8:35
|
--> $DIR/simple.rs:8:35
|
||||||
|
|
|
|
||||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/simple_fail.rs:7:33
|
--> $DIR/simple_fail.rs:7:33
|
||||||
|
|
|
|
||||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
|
type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
|
fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
error: constant expression depends on a generic parameter
|
||||||
|
--> $DIR/generic-function-call-in-array-length.rs:9:29
|
||||||
|
|
|
||||||
|
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this may fail depending on what value the parameter takes
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/generic-function-call-in-array-length.rs:9:39
|
||||||
|
|
|
||||||
|
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
||||||
|
|
|
||||||
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/generic-function-call-in-array-length.rs:12:13
|
||||||
|
|
|
||||||
|
LL | [0; foo(N)]
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
||||||
|
|
|
||||||
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
const fn foo(n: usize) -> usize { n * 2 }
|
||||||
|
|
||||||
|
fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||||
|
[0; foo(N)]
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,10 @@
|
||||||
|
error: constant expression depends on a generic parameter
|
||||||
|
--> $DIR/generic-sum-in-array-length.rs:7:45
|
||||||
|
|
|
||||||
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this may fail depending on what value the parameter takes
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/generic-sum-in-array-length.rs:7:53
|
||||||
|
|
|
||||||
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `A`
|
||||||
|
|
|
||||||
|
= help: it is currently only allowed to use either `A` or `{ A }` as generic constants
|
||||||
|
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/generic-sum-in-array-length.rs:7:57
|
||||||
|
|
|
||||||
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `B`
|
||||||
|
|
|
||||||
|
= help: it is currently only allowed to use either `B` or `{ B }` as generic constants
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^^ ERROR constant expression depends on a generic parameter
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||||
|
--> $DIR/impl-trait-with-const-arguments.rs:24:20
|
||||||
|
|
|
||||||
|
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||||
|
| ^^^^^^ explicit generic argument not allowed
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||||
|
--> $DIR/impl-trait-with-const-arguments.rs:24:20
|
||||||
|
|
|
||||||
|
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||||
|
| ^^^^^^ explicit generic argument not allowed
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
trait Usizer {
|
||||||
|
fn m(self) -> usize;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f<const N: usize>(u: impl Usizer) -> usize {
|
||||||
|
N + u.m()
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Usizable;
|
||||||
|
|
||||||
|
impl Usizer for Usizable {
|
||||||
|
fn m(self) -> usize {
|
||||||
|
16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||||
|
//~^ ERROR cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
error: constant expression depends on a generic parameter
|
||||||
|
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:8
|
||||||
|
|
|
||||||
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this may fail depending on what value the parameter takes
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
||||||
|
|
|
||||||
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error: `&'static str` is forbidden as the type of a const generic parameter
|
||||||
|
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
|
||||||
|
|
|
||||||
|
LL | trait Trait<const S: &'static str> {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: the only supported types are integers, `bool` and `char`
|
||||||
|
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
#![feature(core_intrinsics)]
|
||||||
|
#![feature(const_type_name)]
|
||||||
|
|
||||||
|
trait Trait<const S: &'static str> {}
|
||||||
|
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
|
||||||
|
|
||||||
|
struct Bug<T>
|
||||||
|
where
|
||||||
|
T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||||
|
{
|
||||||
|
t: T
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
||||||
|
|
|
|
||||||
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
||||||
|
@ -6,7 +6,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
|
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
||||||
|
|
|
|
||||||
LL | fn inner(&self) -> &[u8; COUNT + 1] {
|
LL | fn inner(&self) -> &[u8; COUNT + 1] {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
warning: cannot use constants which depend on generic parameters in types
|
||||||
|
--> $DIR/issue-67375.rs:9:12
|
||||||
|
|
|
||||||
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[warn(const_evaluatable_unchecked)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
|
||||||
|
|
||||||
|
error[E0392]: parameter `T` is never used
|
||||||
|
--> $DIR/issue-67375.rs:7:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<T> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
|
@ -0,0 +1,19 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/issue-67375.rs:9:25
|
||||||
|
|
|
||||||
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error[E0392]: parameter `T` is never used
|
||||||
|
--> $DIR/issue-67375.rs:7:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<T> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
|
@ -0,0 +1,15 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
struct Bug<T> {
|
||||||
|
//~^ ERROR parameter `T` is never used
|
||||||
|
inner: [(); { [|_: &T| {}; 0].len() }],
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ WARN cannot use constants which depend on generic parameters in types
|
||||||
|
//[full]~^^^ WARN this was previously accepted by the compiler
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,26 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/issue-67945-1.rs:14:20
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| - this type parameter
|
||||||
|
...
|
||||||
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
|
| - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected type parameter `S`
|
||||||
|
found union `MaybeUninit<_>`
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-1.rs:11:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0308, E0392.
|
||||||
|
For more information about an error, try `rustc --explain E0308`.
|
|
@ -0,0 +1,27 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/issue-67945-1.rs:14:16
|
||||||
|
|
|
||||||
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/issue-67945-1.rs:17:45
|
||||||
|
|
|
||||||
|
LL | let b = &*(&x as *const _ as *const S);
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-1.rs:11:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
|
@ -0,0 +1,23 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use std::mem::{self, MaybeUninit};
|
||||||
|
|
||||||
|
struct Bug<S> {
|
||||||
|
//~^ ERROR parameter `S` is never used
|
||||||
|
A: [(); {
|
||||||
|
let x: S = MaybeUninit::uninit();
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ ERROR mismatched types
|
||||||
|
let b = &*(&x as *const _ as *const S);
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
0
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,26 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/issue-67945-2.rs:12:20
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| - this type parameter
|
||||||
|
...
|
||||||
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
|
| - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected type parameter `S`
|
||||||
|
found union `MaybeUninit<_>`
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-2.rs:9:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0308, E0392.
|
||||||
|
For more information about an error, try `rustc --explain E0308`.
|
|
@ -0,0 +1,27 @@
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/issue-67945-2.rs:12:16
|
||||||
|
|
|
||||||
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
|
--> $DIR/issue-67945-2.rs:15:45
|
||||||
|
|
|
||||||
|
LL | let b = &*(&x as *const _ as *const S);
|
||||||
|
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
||||||
|
|
|
||||||
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
|
error[E0392]: parameter `S` is never used
|
||||||
|
--> $DIR/issue-67945-2.rs:9:12
|
||||||
|
|
|
||||||
|
LL | struct Bug<S> {
|
||||||
|
| ^ unused parameter
|
||||||
|
|
|
||||||
|
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0392`.
|
|
@ -0,0 +1,21 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
|
struct Bug<S> {
|
||||||
|
//~^ ERROR parameter `S` is never used
|
||||||
|
A: [(); {
|
||||||
|
let x: S = MaybeUninit::uninit();
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
//[full]~^^ ERROR mismatched types
|
||||||
|
let b = &*(&x as *const _ as *const S);
|
||||||
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
0
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,16 @@
|
||||||
|
error: constant expression depends on a generic parameter
|
||||||
|
--> $DIR/issue-67945-3.rs:8:8
|
||||||
|
|
|
||||||
|
LL | A: [(); {
|
||||||
|
| ________^
|
||||||
|
LL | |
|
||||||
|
LL | | let x: Option<Box<Self>> = None;
|
||||||
|
LL | |
|
||||||
|
LL | | 0
|
||||||
|
LL | | }],
|
||||||
|
| |______^
|
||||||
|
|
|
||||||
|
= note: this may fail depending on what value the parameter takes
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
error: generic `Self` types are currently not permitted in anonymous constants
|
||||||
|
--> $DIR/issue-67945-3.rs:10:27
|
||||||
|
|
|
||||||
|
LL | let x: Option<Box<Self>> = None;
|
||||||
|
| ^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// revisions: full min
|
||||||
|
|
||||||
|
#![cfg_attr(full, allow(incomplete_features))]
|
||||||
|
#![cfg_attr(full, feature(const_generics))]
|
||||||
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
|
struct Bug<S: ?Sized> {
|
||||||
|
A: [(); {
|
||||||
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
|
let x: Option<Box<Self>> = None;
|
||||||
|
//[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants
|
||||||
|
0
|
||||||
|
}],
|
||||||
|
B: S
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-61747.rs:8:30
|
--> $DIR/issue-61747.rs:8:30
|
||||||
|
|
|
|
||||||
LL | fn successor() -> Const<{C + 1}> {
|
LL | fn successor() -> Const<{C + 1}> {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-61935.rs:10:23
|
--> $DIR/issue-61935.rs:10:23
|
||||||
|
|
|
|
||||||
LL | Self:FooImpl<{N==0}>
|
LL | Self:FooImpl<{N==0}>
|
||||||
|
|
|
@ -9,7 +9,7 @@ impl<const N: usize> Foo for [(); N]
|
||||||
where
|
where
|
||||||
Self:FooImpl<{N==0}>
|
Self:FooImpl<{N==0}>
|
||||||
//[full]~^ERROR constant expression depends on a generic parameter
|
//[full]~^ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
{}
|
{}
|
||||||
|
|
||||||
trait FooImpl<const IS_ZERO: bool>{}
|
trait FooImpl<const IS_ZERO: bool>{}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-62220.rs:8:59
|
--> $DIR/issue-62220.rs:8:59
|
||||||
|
|
|
|
||||||
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
pub struct Vector<T, const N: usize>([T; N]);
|
pub struct Vector<T, const N: usize>([T; N]);
|
||||||
|
|
||||||
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
impl<T, const N: usize> Vector<T, { N }> {
|
impl<T, const N: usize> Vector<T, { N }> {
|
||||||
/// Drop the last component and return the vector with one fewer dimension.
|
/// Drop the last component and return the vector with one fewer dimension.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-62456.rs:7:20
|
--> $DIR/issue-62456.rs:7:20
|
||||||
|
|
|
|
||||||
LL | let _ = [0u64; N + 1];
|
LL | let _ = [0u64; N + 1];
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
fn foo<const N: usize>() {
|
fn foo<const N: usize>() {
|
||||||
let _ = [0u64; N + 1];
|
let _ = [0u64; N + 1];
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-64494.rs:16:38
|
--> $DIR/issue-64494.rs:16:38
|
||||||
|
|
|
|
||||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||||
|
@ -6,7 +6,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-64494.rs:19:38
|
--> $DIR/issue-64494.rs:19:38
|
||||||
|
|
|
|
||||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||||
|
|
|
@ -15,10 +15,10 @@ impl True for Is<{true}> {}
|
||||||
|
|
||||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-66205.rs:8:14
|
--> $DIR/issue-66205.rs:8:14
|
||||||
|
|
|
|
||||||
LL | fact::<{ N - 1 }>();
|
LL | fact::<{ N - 1 }>();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
fn fact<const N: usize>() {
|
fn fact<const N: usize>() {
|
||||||
fact::<{ N - 1 }>();
|
fact::<{ N - 1 }>();
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-67739.rs:12:30
|
--> $DIR/issue-67739.rs:12:30
|
||||||
|
|
|
|
||||||
LL | [0u8; mem::size_of::<Self::Associated>()];
|
LL | [0u8; mem::size_of::<Self::Associated>()];
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub trait Trait {
|
||||||
fn associated_size(&self) -> usize {
|
fn associated_size(&self) -> usize {
|
||||||
[0u8; mem::size_of::<Self::Associated>()];
|
[0u8; mem::size_of::<Self::Associated>()];
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-68366.rs:12:37
|
--> $DIR/issue-68366.rs:12:37
|
||||||
|
|
|
|
||||||
LL | impl <const N: usize> Collatz<{Some(N)}> {}
|
LL | impl <const N: usize> Collatz<{Some(N)}> {}
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct Collatz<const N: Option<usize>>;
|
||||||
|
|
||||||
impl <const N: usize> Collatz<{Some(N)}> {}
|
impl <const N: usize> Collatz<{Some(N)}> {}
|
||||||
//~^ ERROR the const parameter
|
//~^ ERROR the const parameter
|
||||||
//[min]~^^ generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-68977.rs:29:17
|
--> $DIR/issue-68977.rs:29:17
|
||||||
|
|
|
|
||||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
|
@ -6,7 +6,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants
|
= help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-68977.rs:29:28
|
--> $DIR/issue-68977.rs:29:28
|
||||||
|
|
|
|
||||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
|
|
|
@ -27,8 +27,8 @@ fxp_storage_impls! {
|
||||||
|
|
||||||
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
||||||
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
//[min]~| ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-72787.rs:11:17
|
--> $DIR/issue-72787.rs:11:17
|
||||||
|
|
|
|
||||||
LL | Condition<{ LHS <= RHS }>: True
|
LL | Condition<{ LHS <= RHS }>: True
|
||||||
|
@ -6,7 +6,7 @@ LL | Condition<{ LHS <= RHS }>: True
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants
|
= help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-72787.rs:11:24
|
--> $DIR/issue-72787.rs:11:24
|
||||||
|
|
|
|
||||||
LL | Condition<{ LHS <= RHS }>: True
|
LL | Condition<{ LHS <= RHS }>: True
|
||||||
|
@ -14,7 +14,7 @@ LL | Condition<{ LHS <= RHS }>: True
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants
|
= help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-72787.rs:26:25
|
--> $DIR/issue-72787.rs:26:25
|
||||||
|
|
|
|
||||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||||
|
@ -22,7 +22,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `I` or `{ I }` as generic constants
|
= help: it is currently only allowed to use either `I` or `{ I }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-72787.rs:26:36
|
--> $DIR/issue-72787.rs:26:36
|
||||||
|
|
|
|
||||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||||
|
|
|
@ -10,8 +10,8 @@ pub trait True {}
|
||||||
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
|
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
|
||||||
Condition<{ LHS <= RHS }>: True
|
Condition<{ LHS <= RHS }>: True
|
||||||
//[full]~^ Error constant expression depends on a generic parameter
|
//[full]~^ Error constant expression depends on a generic parameter
|
||||||
//[min]~^^ Error generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ Error generic parameters must not be used inside of non-trivial constant values
|
||||||
//[min]~| Error generic parameters must not be used inside of non trivial constant values
|
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl True for Condition<true> {}
|
impl True for Condition<true> {}
|
||||||
|
@ -28,8 +28,8 @@ where
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[min]~^^^^^ Error generic parameters must not be used inside of non trivial constant values
|
//[min]~^^^^^ Error generic parameters must not be used inside of non-trivial constant values
|
||||||
//[min]~| Error generic parameters must not be used inside of non trivial constant values
|
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
||||||
// Condition<{ 8 - I <= 8 - J }>: True,
|
// Condition<{ 8 - I <= 8 - J }>: True,
|
||||||
{
|
{
|
||||||
fn print() {
|
fn print() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
||||||
|
|
|
|
||||||
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
struct Arr<const N: usize>
|
struct Arr<const N: usize>
|
||||||
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-76701-ty-param-in-const.rs:6:46
|
--> $DIR/issue-76701-ty-param-in-const.rs:6:46
|
||||||
|
|
|
|
||||||
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||||
|
@ -6,7 +6,7 @@ LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters are currently not permitted in anonymous constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/issue-76701-ty-param-in-const.rs:12:42
|
--> $DIR/issue-76701-ty-param-in-const.rs:12:42
|
||||||
|
|
|
|
||||||
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
|
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_param<const N: usize>() -> [u8; N + 1] {
|
fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,19 @@ fn ok<const M: usize>() -> [u8; M] {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Break0<const N: usize>([u8; { N + 1 }]);
|
struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
struct Break1<const N: usize>([u8; { { N } }]);
|
struct Break1<const N: usize>([u8; { { N } }]);
|
||||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
|
|
||||||
fn break2<const N: usize>() {
|
fn break2<const N: usize>() {
|
||||||
let _: [u8; N + 1];
|
let _: [u8; N + 1];
|
||||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
}
|
}
|
||||||
|
|
||||||
fn break3<const N: usize>() {
|
fn break3<const N: usize>() {
|
||||||
let _ = [0; N + 1];
|
let _ = [0; N + 1];
|
||||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/complex-expression.rs:9:38
|
--> $DIR/complex-expression.rs:9:38
|
||||||
|
|
|
|
||||||
LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||||
|
@ -6,7 +6,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/complex-expression.rs:12:40
|
--> $DIR/complex-expression.rs:12:40
|
||||||
|
|
|
|
||||||
LL | struct Break1<const N: usize>([u8; { { N } }]);
|
LL | struct Break1<const N: usize>([u8; { { N } }]);
|
||||||
|
@ -14,7 +14,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]);
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/complex-expression.rs:16:17
|
--> $DIR/complex-expression.rs:16:17
|
||||||
|
|
|
|
||||||
LL | let _: [u8; N + 1];
|
LL | let _: [u8; N + 1];
|
||||||
|
@ -22,7 +22,7 @@ LL | let _: [u8; N + 1];
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/complex-expression.rs:21:17
|
--> $DIR/complex-expression.rs:21:17
|
||||||
|
|
|
|
||||||
LL | let _ = [0; N + 1];
|
LL | let _ = [0; N + 1];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/self-ty-in-const-1.rs:4:41
|
--> $DIR/self-ty-in-const-1.rs:4:41
|
||||||
|
|
|
|
||||||
LL | fn t1() -> [u8; std::mem::size_of::<Self>()];
|
LL | fn t1() -> [u8; std::mem::size_of::<Self>()];
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#![feature(min_const_generics)]
|
||||||
|
|
||||||
|
fn a<const X: &'static [u32]>() {}
|
||||||
|
//~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
a::<{&[]}>();
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
error: `&'static [u32]` is forbidden as the type of a const generic parameter
|
||||||
|
--> $DIR/static-reference-array-const-param.rs:3:15
|
||||||
|
|
|
||||||
|
LL | fn a<const X: &'static [u32]>() {}
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: the only supported types are integers, `bool` and `char`
|
||||||
|
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#![feature(min_const_generics)]
|
||||||
|
|
||||||
|
struct Const<const P: &'static ()>;
|
||||||
|
//~^ ERROR `&'static ()` is forbidden as the type of a const generic parameter
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
const A: &'static () = unsafe {
|
||||||
|
std::mem::transmute(10 as *const ())
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = Const::<{A}>;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
error: `&'static ()` is forbidden as the type of a const generic parameter
|
||||||
|
--> $DIR/transmute-const-param-static-reference.rs:3:23
|
||||||
|
|
|
||||||
|
LL | struct Const<const P: &'static ()>;
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: the only supported types are integers, `bool` and `char`
|
||||||
|
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | struct Bar<T = [u8; N], const N: usize>(T);
|
||||||
|
|
|
|
||||||
= note: using type defaults and const parameters in the same parameter list is currently not permitted
|
= note: using type defaults and const parameters in the same parameter list is currently not permitted
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44
|
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44
|
||||||
|
|
|
|
||||||
LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
|
||||||
//[full]~^ ERROR constant values inside of type parameter defaults
|
//[full]~^ ERROR constant values inside of type parameter defaults
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||||
|
|
||||||
// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults.
|
// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults.
|
||||||
struct Bar<T = [u8; N], const N: usize>(T);
|
struct Bar<T = [u8; N], const N: usize>(T);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/wf-misc.rs:9:17
|
--> $DIR/wf-misc.rs:9:17
|
||||||
|
|
|
|
||||||
LL | let _: [u8; N + 1];
|
LL | let _: [u8; N + 1];
|
||||||
|
@ -6,7 +6,7 @@ LL | let _: [u8; N + 1];
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non trivial constant values
|
error: generic parameters must not be used inside of non-trivial constant values
|
||||||
--> $DIR/wf-misc.rs:17:21
|
--> $DIR/wf-misc.rs:17:21
|
||||||
|
|
|
|
||||||
LL | let _: Const::<{N + 1}>;
|
LL | let _: Const::<{N + 1}>;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
pub fn arr_len<const N: usize>() {
|
pub fn arr_len<const N: usize>() {
|
||||||
let _: [u8; N + 1];
|
let _: [u8; N + 1];
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Const<const N: usize>;
|
struct Const<const N: usize>;
|
||||||
|
@ -16,7 +16,7 @@ struct Const<const N: usize>;
|
||||||
pub fn func_call<const N: usize>() {
|
pub fn func_call<const N: usize>() {
|
||||||
let _: Const::<{N + 1}>;
|
let _: Const::<{N + 1}>;
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#![feature(unwind_attributes, const_panic)]
|
||||||
|
|
||||||
|
#[unwind(aborts)]
|
||||||
|
const fn foo() {
|
||||||
|
panic!() //~ evaluation of constant value failed
|
||||||
|
}
|
||||||
|
|
||||||
|
const _: () = foo(); //~ any use of this value will cause an error
|
||||||
|
// Ensure that the CTFE engine handles calls to `#[unwind(aborts)]` gracefully
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = foo();
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue