Get rid of HIR const checker
This commit is contained in:
parent
75703c1a78
commit
01ff36a6b9
38 changed files with 151 additions and 604 deletions
|
@ -110,7 +110,7 @@ const_eval_extern_type_field = `extern type` field does not have a known offset
|
||||||
const_eval_fn_ptr_call =
|
const_eval_fn_ptr_call =
|
||||||
function pointers need an RFC before allowed to be called in {const_eval_const_context}s
|
function pointers need an RFC before allowed to be called in {const_eval_const_context}s
|
||||||
const_eval_for_loop_into_iter_non_const =
|
const_eval_for_loop_into_iter_non_const =
|
||||||
cannot convert `{$ty}` into an iterator in {const_eval_const_context}s
|
cannot use `for` loop on `{$ty}` in {const_eval_const_context}s
|
||||||
|
|
||||||
const_eval_frame_note = {$times ->
|
const_eval_frame_note = {$times ->
|
||||||
[0] {const_eval_frame_note_inner}
|
[0] {const_eval_frame_note_inner}
|
||||||
|
@ -324,11 +324,11 @@ const_eval_ptr_as_bytes_1 =
|
||||||
this code performed an operation that depends on the underlying bytes representing a pointer
|
this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
const_eval_ptr_as_bytes_2 =
|
const_eval_ptr_as_bytes_2 =
|
||||||
the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||||
const_eval_question_branch_non_const =
|
|
||||||
`?` cannot determine the branch of `{$ty}` in {const_eval_const_context}s
|
|
||||||
|
|
||||||
|
const_eval_question_branch_non_const =
|
||||||
|
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
|
||||||
const_eval_question_from_residual_non_const =
|
const_eval_question_from_residual_non_const =
|
||||||
`?` cannot convert from residual of `{$ty}` in {const_eval_const_context}s
|
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
|
||||||
|
|
||||||
const_eval_range = in the range {$lo}..={$hi}
|
const_eval_range = in the range {$lo}..={$hi}
|
||||||
const_eval_range_lower = greater or equal to {$lo}
|
const_eval_range_lower = greater or equal to {$lo}
|
||||||
|
|
|
@ -180,8 +180,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut err = match kind {
|
// Don't point at the trait if this is a desugaring...
|
||||||
CallDesugaringKind::ForLoopIntoIter => {
|
// FIXME(const_trait_impl): we could perhaps do this for `Iterator`.
|
||||||
|
match kind {
|
||||||
|
CallDesugaringKind::ForLoopIntoIter | CallDesugaringKind::ForLoopNext => {
|
||||||
error!(NonConstForLoopIntoIter)
|
error!(NonConstForLoopIntoIter)
|
||||||
}
|
}
|
||||||
CallDesugaringKind::QuestionBranch => {
|
CallDesugaringKind::QuestionBranch => {
|
||||||
|
@ -196,10 +198,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||||
CallDesugaringKind::Await => {
|
CallDesugaringKind::Await => {
|
||||||
error!(NonConstAwait)
|
error!(NonConstAwait)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
diag_trait(&mut err, self_ty, kind.trait_def_id(tcx));
|
|
||||||
err
|
|
||||||
}
|
}
|
||||||
CallKind::FnCall { fn_trait_id, self_ty } => {
|
CallKind::FnCall { fn_trait_id, self_ty } => {
|
||||||
let note = match self_ty.kind() {
|
let note = match self_ty.kind() {
|
||||||
|
|
|
@ -828,7 +828,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
|
||||||
tcx.ensure().check_mod_attrs(module);
|
tcx.ensure().check_mod_attrs(module);
|
||||||
tcx.ensure().check_mod_naked_functions(module);
|
tcx.ensure().check_mod_naked_functions(module);
|
||||||
tcx.ensure().check_mod_unstable_api_usage(module);
|
tcx.ensure().check_mod_unstable_api_usage(module);
|
||||||
tcx.ensure().check_mod_const_bodies(module);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -958,11 +958,6 @@ rustc_queries! {
|
||||||
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
|
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
|
|
||||||
query check_mod_const_bodies(key: LocalModDefId) {
|
|
||||||
desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks the loops in the module.
|
/// Checks the loops in the module.
|
||||||
query check_mod_loops(key: LocalModDefId) {
|
query check_mod_loops(key: LocalModDefId) {
|
||||||
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
|
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
|
||||||
|
|
|
@ -14,6 +14,8 @@ use crate::ty::{AssocItemContainer, GenericArgsRef, Instance, Ty, TyCtxt, Typing
|
||||||
pub enum CallDesugaringKind {
|
pub enum CallDesugaringKind {
|
||||||
/// for _ in x {} calls x.into_iter()
|
/// for _ in x {} calls x.into_iter()
|
||||||
ForLoopIntoIter,
|
ForLoopIntoIter,
|
||||||
|
/// for _ in x {} calls iter.next()
|
||||||
|
ForLoopNext,
|
||||||
/// x? calls x.branch()
|
/// x? calls x.branch()
|
||||||
QuestionBranch,
|
QuestionBranch,
|
||||||
/// x? calls type_of(x)::from_residual()
|
/// x? calls type_of(x)::from_residual()
|
||||||
|
@ -28,6 +30,7 @@ impl CallDesugaringKind {
|
||||||
pub fn trait_def_id(self, tcx: TyCtxt<'_>) -> DefId {
|
pub fn trait_def_id(self, tcx: TyCtxt<'_>) -> DefId {
|
||||||
match self {
|
match self {
|
||||||
Self::ForLoopIntoIter => tcx.get_diagnostic_item(sym::IntoIterator).unwrap(),
|
Self::ForLoopIntoIter => tcx.get_diagnostic_item(sym::IntoIterator).unwrap(),
|
||||||
|
Self::ForLoopNext => tcx.require_lang_item(LangItem::Iterator, None),
|
||||||
Self::QuestionBranch | Self::TryBlockFromOutput => {
|
Self::QuestionBranch | Self::TryBlockFromOutput => {
|
||||||
tcx.require_lang_item(LangItem::Try, None)
|
tcx.require_lang_item(LangItem::Try, None)
|
||||||
}
|
}
|
||||||
|
@ -121,6 +124,10 @@ pub fn call_kind<'tcx>(
|
||||||
&& fn_call_span.desugaring_kind() == Some(DesugaringKind::ForLoop)
|
&& fn_call_span.desugaring_kind() == Some(DesugaringKind::ForLoop)
|
||||||
{
|
{
|
||||||
Some((CallDesugaringKind::ForLoopIntoIter, method_args.type_at(0)))
|
Some((CallDesugaringKind::ForLoopIntoIter, method_args.type_at(0)))
|
||||||
|
} else if tcx.is_lang_item(method_did, LangItem::IteratorNext)
|
||||||
|
&& fn_call_span.desugaring_kind() == Some(DesugaringKind::ForLoop)
|
||||||
|
{
|
||||||
|
Some((CallDesugaringKind::ForLoopNext, method_args.type_at(0)))
|
||||||
} else if fn_call_span.desugaring_kind() == Some(DesugaringKind::QuestionMark) {
|
} else if fn_call_span.desugaring_kind() == Some(DesugaringKind::QuestionMark) {
|
||||||
if tcx.is_lang_item(method_did, LangItem::TryTraitBranch) {
|
if tcx.is_lang_item(method_did, LangItem::TryTraitBranch) {
|
||||||
Some((CallDesugaringKind::QuestionBranch, method_args.type_at(0)))
|
Some((CallDesugaringKind::QuestionBranch, method_args.type_at(0)))
|
||||||
|
|
|
@ -705,8 +705,6 @@ passes_should_be_applied_to_trait =
|
||||||
attribute should be applied to a trait
|
attribute should be applied to a trait
|
||||||
.label = not a trait
|
.label = not a trait
|
||||||
|
|
||||||
passes_skipping_const_checks = skipping const checks
|
|
||||||
|
|
||||||
passes_stability_promotable =
|
passes_stability_promotable =
|
||||||
attribute cannot be applied to an expression
|
attribute cannot be applied to an expression
|
||||||
|
|
||||||
|
|
|
@ -1,236 +0,0 @@
|
||||||
//! This pass checks HIR bodies that may be evaluated at compile-time (e.g., `const`, `static`,
|
|
||||||
//! `const fn`) for structured control flow (e.g. `if`, `while`), which is forbidden in a const
|
|
||||||
//! context.
|
|
||||||
//!
|
|
||||||
//! By the time the MIR const-checker runs, these high-level constructs have been lowered to
|
|
||||||
//! control-flow primitives (e.g., `Goto`, `SwitchInt`), making it tough to properly attribute
|
|
||||||
//! errors. We still look for those primitives in the MIR const-checker to ensure nothing slips
|
|
||||||
//! through, but errors for structured control flow in a `const` should be emitted here.
|
|
||||||
|
|
||||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
|
||||||
use rustc_middle::hir::nested_filter;
|
|
||||||
use rustc_middle::query::Providers;
|
|
||||||
use rustc_middle::span_bug;
|
|
||||||
use rustc_middle::ty::TyCtxt;
|
|
||||||
use rustc_session::parse::feature_err;
|
|
||||||
use rustc_span::{Span, Symbol, sym};
|
|
||||||
use {rustc_attr as attr, rustc_hir as hir};
|
|
||||||
|
|
||||||
use crate::errors::SkippingConstChecks;
|
|
||||||
|
|
||||||
/// An expression that is not *always* legal in a const context.
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
enum NonConstExpr {
|
|
||||||
Loop(hir::LoopSource),
|
|
||||||
Match(hir::MatchSource),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NonConstExpr {
|
|
||||||
fn name(self) -> String {
|
|
||||||
match self {
|
|
||||||
Self::Loop(src) => format!("`{}`", src.name()),
|
|
||||||
Self::Match(src) => format!("`{}`", src.name()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn required_feature_gates(self) -> Option<&'static [Symbol]> {
|
|
||||||
use hir::LoopSource::*;
|
|
||||||
use hir::MatchSource::*;
|
|
||||||
|
|
||||||
let gates: &[_] = match self {
|
|
||||||
Self::Match(AwaitDesugar) => {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Self::Loop(ForLoop) | Self::Match(ForLoopDesugar) => &[sym::const_for],
|
|
||||||
|
|
||||||
Self::Match(TryDesugar(_)) => &[sym::const_try],
|
|
||||||
|
|
||||||
// All other expressions are allowed.
|
|
||||||
Self::Loop(Loop | While) | Self::Match(Normal | Postfix | FormatArgs) => &[],
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(gates)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
|
|
||||||
let mut vis = CheckConstVisitor::new(tcx);
|
|
||||||
tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
|
||||||
*providers = Providers { check_mod_const_bodies, ..*providers };
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
struct CheckConstVisitor<'tcx> {
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
const_kind: Option<hir::ConstContext>,
|
|
||||||
def_id: Option<LocalDefId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> CheckConstVisitor<'tcx> {
|
|
||||||
fn new(tcx: TyCtxt<'tcx>) -> Self {
|
|
||||||
CheckConstVisitor { tcx, const_kind: None, def_id: None }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emits an error when an unsupported expression is found in a const context.
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
|
||||||
fn const_check_violated(&self, expr: NonConstExpr, span: Span) {
|
|
||||||
let Self { tcx, def_id, const_kind } = *self;
|
|
||||||
|
|
||||||
let features = tcx.features();
|
|
||||||
let required_gates = expr.required_feature_gates();
|
|
||||||
|
|
||||||
let is_feature_allowed = |feature_gate| {
|
|
||||||
// All features require that the corresponding gate be enabled,
|
|
||||||
// even if the function has `#[rustc_allow_const_fn_unstable(the_gate)]`.
|
|
||||||
if !tcx.features().enabled(feature_gate) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If `def_id` is `None`, we don't need to consider stability attributes.
|
|
||||||
let def_id = match def_id {
|
|
||||||
Some(x) => x,
|
|
||||||
None => return true,
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the function belongs to a trait, then it must enable the const_trait_impl
|
|
||||||
// feature to use that trait function (with a const default body).
|
|
||||||
if tcx.trait_of_item(def_id.to_def_id()).is_some() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this crate is not using stability attributes, or this function is not claiming to be a
|
|
||||||
// stable `const fn`, that is all that is required.
|
|
||||||
if !tcx.features().staged_api() || tcx.has_attr(def_id, sym::rustc_const_unstable) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
|
|
||||||
// opt-in via `rustc_allow_const_fn_unstable`.
|
|
||||||
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
|
|
||||||
attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate)
|
|
||||||
};
|
|
||||||
|
|
||||||
match required_gates {
|
|
||||||
// Don't emit an error if the user has enabled the requisite feature gates.
|
|
||||||
Some(gates) if gates.iter().copied().all(is_feature_allowed) => return,
|
|
||||||
|
|
||||||
// `-Zunleash-the-miri-inside-of-you` only works for expressions that don't have a
|
|
||||||
// corresponding feature gate. This encourages nightly users to use feature gates when
|
|
||||||
// possible.
|
|
||||||
None if tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you => {
|
|
||||||
tcx.dcx().emit_warn(SkippingConstChecks { span });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let const_kind =
|
|
||||||
const_kind.expect("`const_check_violated` may only be called inside a const context");
|
|
||||||
|
|
||||||
let required_gates = required_gates.unwrap_or(&[]);
|
|
||||||
let missing_gates: Vec<_> =
|
|
||||||
required_gates.iter().copied().filter(|&g| !features.enabled(g)).collect();
|
|
||||||
|
|
||||||
match missing_gates.as_slice() {
|
|
||||||
[] => {
|
|
||||||
span_bug!(
|
|
||||||
span,
|
|
||||||
"we should not have reached this point, since `.await` is denied earlier"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
[missing_primary, ref missing_secondary @ ..] => {
|
|
||||||
let msg =
|
|
||||||
format!("{} is not allowed in a `{}`", expr.name(), const_kind.keyword_name());
|
|
||||||
let mut err = feature_err(&tcx.sess, *missing_primary, span, msg);
|
|
||||||
|
|
||||||
// If multiple feature gates would be required to enable this expression, include
|
|
||||||
// them as help messages. Don't emit a separate error for each missing feature gate.
|
|
||||||
//
|
|
||||||
// FIXME(ecstaticmorse): Maybe this could be incorporated into `feature_err`? This
|
|
||||||
// is a pretty narrow case, however.
|
|
||||||
tcx.disabled_nightly_features(
|
|
||||||
&mut err,
|
|
||||||
def_id.map(|id| tcx.local_def_id_to_hir_id(id)),
|
|
||||||
missing_secondary.into_iter().map(|gate| (String::new(), *gate)),
|
|
||||||
);
|
|
||||||
|
|
||||||
err.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Saves the parent `const_kind` before calling `f` and restores it afterwards.
|
|
||||||
fn recurse_into(
|
|
||||||
&mut self,
|
|
||||||
kind: Option<hir::ConstContext>,
|
|
||||||
def_id: Option<LocalDefId>,
|
|
||||||
f: impl FnOnce(&mut Self),
|
|
||||||
) {
|
|
||||||
let parent_def_id = self.def_id;
|
|
||||||
let parent_kind = self.const_kind;
|
|
||||||
self.def_id = def_id;
|
|
||||||
self.const_kind = kind;
|
|
||||||
f(self);
|
|
||||||
self.def_id = parent_def_id;
|
|
||||||
self.const_kind = parent_kind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
|
|
||||||
type NestedFilter = nested_filter::OnlyBodies;
|
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> Self::Map {
|
|
||||||
self.tcx.hir()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_anon_const(&mut self, anon: &'tcx hir::AnonConst) {
|
|
||||||
let kind = Some(hir::ConstContext::Const { inline: false });
|
|
||||||
self.recurse_into(kind, None, |this| intravisit::walk_anon_const(this, anon));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_inline_const(&mut self, block: &'tcx hir::ConstBlock) {
|
|
||||||
let kind = Some(hir::ConstContext::Const { inline: true });
|
|
||||||
self.recurse_into(kind, None, |this| intravisit::walk_inline_const(this, block));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
|
|
||||||
let owner = self.tcx.hir().body_owner_def_id(body.id());
|
|
||||||
let kind = self.tcx.hir().body_const_context(owner);
|
|
||||||
self.recurse_into(kind, Some(owner), |this| intravisit::walk_body(this, body));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
|
|
||||||
match &e.kind {
|
|
||||||
// Skip the following checks if we are not currently in a const context.
|
|
||||||
_ if self.const_kind.is_none() => {}
|
|
||||||
|
|
||||||
hir::ExprKind::Loop(_, _, source, _) => {
|
|
||||||
self.const_check_violated(NonConstExpr::Loop(*source), e.span);
|
|
||||||
}
|
|
||||||
|
|
||||||
hir::ExprKind::Match(_, _, source) => {
|
|
||||||
let non_const_expr = match source {
|
|
||||||
// These are handled by `ExprKind::Loop` above.
|
|
||||||
hir::MatchSource::ForLoopDesugar => None,
|
|
||||||
|
|
||||||
_ => Some(NonConstExpr::Match(*source)),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(expr) = non_const_expr {
|
|
||||||
self.const_check_violated(expr, e.span);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
intravisit::walk_expr(self, e);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1670,13 +1670,6 @@ pub(crate) struct ProcMacroBadSig {
|
||||||
pub kind: ProcMacroKind,
|
pub kind: ProcMacroKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(passes_skipping_const_checks)]
|
|
||||||
pub(crate) struct SkippingConstChecks {
|
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(passes_unreachable_due_to_uninhabited)]
|
#[diag(passes_unreachable_due_to_uninhabited)]
|
||||||
pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
|
pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
|
||||||
|
|
|
@ -19,7 +19,6 @@ use rustc_middle::query::Providers;
|
||||||
|
|
||||||
pub mod abi_test;
|
pub mod abi_test;
|
||||||
mod check_attr;
|
mod check_attr;
|
||||||
mod check_const;
|
|
||||||
pub mod dead;
|
pub mod dead;
|
||||||
mod debugger_visualizer;
|
mod debugger_visualizer;
|
||||||
mod diagnostic_items;
|
mod diagnostic_items;
|
||||||
|
@ -43,7 +42,6 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
check_attr::provide(providers);
|
check_attr::provide(providers);
|
||||||
check_const::provide(providers);
|
|
||||||
dead::provide(providers);
|
dead::provide(providers);
|
||||||
debugger_visualizer::provide(providers);
|
debugger_visualizer::provide(providers);
|
||||||
diagnostic_items::provide(providers);
|
diagnostic_items::provide(providers);
|
||||||
|
|
|
@ -39,8 +39,7 @@ fn for_single_line() -> bool { for i in 0.. { return false; } }
|
||||||
// b. format the suggestion correctly so
|
// b. format the suggestion correctly so
|
||||||
// that it's readable
|
// that it's readable
|
||||||
fn for_in_arg(a: &[(); for x in 0..2 {}]) -> bool {
|
fn for_in_arg(a: &[(); for x in 0..2 {}]) -> bool {
|
||||||
//~^ ERROR `for` is not allowed in a `const`
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR mismatched types
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,16 +83,14 @@ fn loop_() -> bool {
|
||||||
|
|
||||||
const C: i32 = {
|
const C: i32 = {
|
||||||
for i in 0.. {
|
for i in 0.. {
|
||||||
//~^ ERROR `for` is not allowed in a `const`
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = [10; {
|
let _ = [10; {
|
||||||
for i in 0..5 {
|
for i in 0..5 {
|
||||||
//~^ ERROR `for` is not allowed in a `const`
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -105,6 +102,5 @@ fn main() {
|
||||||
|
|
||||||
|
|
||||||
let _ = |a: &[(); for x in 0..2 {}]| {};
|
let _ = |a: &[(); for x in 0..2 {}]| {};
|
||||||
//~^ ERROR `for` is not allowed in a `const`
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
warning: denote infinite loops with `loop { ... }`
|
warning: denote infinite loops with `loop { ... }`
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:48:5
|
--> $DIR/coerce-loop-issue-122561.rs:47:5
|
||||||
|
|
|
|
||||||
LL | while true {
|
LL | while true {
|
||||||
| ^^^^^^^^^^ help: use `loop`
|
| ^^^^^^^^^^ help: use `loop`
|
||||||
|
@ -7,57 +7,11 @@ LL | while true {
|
||||||
= note: `#[warn(while_true)]` on by default
|
= note: `#[warn(while_true)]` on by default
|
||||||
|
|
||||||
warning: denote infinite loops with `loop { ... }`
|
warning: denote infinite loops with `loop { ... }`
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:72:5
|
--> $DIR/coerce-loop-issue-122561.rs:71:5
|
||||||
|
|
|
|
||||||
LL | while true {
|
LL | while true {
|
||||||
| ^^^^^^^^^^ help: use `loop`
|
| ^^^^^^^^^^ help: use `loop`
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:41:24
|
|
||||||
|
|
|
||||||
LL | fn for_in_arg(a: &[(); for x in 0..2 {}]) -> bool {
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:86:5
|
|
||||||
|
|
|
||||||
LL | / for i in 0.. {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:94:9
|
|
||||||
|
|
|
||||||
LL | / for i in 0..5 {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_________^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:107:23
|
|
||||||
|
|
|
||||||
LL | let _ = |a: &[(); for x in 0..2 {}]| {};
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:41:24
|
--> $DIR/coerce-loop-issue-122561.rs:41:24
|
||||||
|
|
|
|
||||||
|
@ -71,11 +25,10 @@ LL | fn for_in_arg(a: &[(); for x in 0..2 {} /* `usize` value */]) -> bool {
|
||||||
| +++++++++++++++++++
|
| +++++++++++++++++++
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:86:5
|
--> $DIR/coerce-loop-issue-122561.rs:85:5
|
||||||
|
|
|
|
||||||
LL | / for i in 0.. {
|
LL | / for i in 0.. {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____^ expected `i32`, found `()`
|
| |_____^ expected `i32`, found `()`
|
||||||
|
|
|
|
||||||
|
@ -174,7 +127,7 @@ LL | fn for_single_line() -> bool { for i in 0.. { return false; } /* `bool` val
|
||||||
| ++++++++++++++++++
|
| ++++++++++++++++++
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:48:5
|
--> $DIR/coerce-loop-issue-122561.rs:47:5
|
||||||
|
|
|
|
||||||
LL | fn while_inifinite() -> bool {
|
LL | fn while_inifinite() -> bool {
|
||||||
| ---- expected `bool` because of return type
|
| ---- expected `bool` because of return type
|
||||||
|
@ -193,7 +146,7 @@ LL + /* `bool` value */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:57:5
|
--> $DIR/coerce-loop-issue-122561.rs:56:5
|
||||||
|
|
|
|
||||||
LL | fn while_finite() -> bool {
|
LL | fn while_finite() -> bool {
|
||||||
| ---- expected `bool` because of return type
|
| ---- expected `bool` because of return type
|
||||||
|
@ -213,7 +166,7 @@ LL + /* `bool` value */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:65:5
|
--> $DIR/coerce-loop-issue-122561.rs:64:5
|
||||||
|
|
|
|
||||||
LL | fn while_zero_times() -> bool {
|
LL | fn while_zero_times() -> bool {
|
||||||
| ---- expected `bool` because of return type
|
| ---- expected `bool` because of return type
|
||||||
|
@ -231,7 +184,7 @@ LL + /* `bool` value */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:72:5
|
--> $DIR/coerce-loop-issue-122561.rs:71:5
|
||||||
|
|
|
|
||||||
LL | fn while_never_type() -> ! {
|
LL | fn while_never_type() -> ! {
|
||||||
| - expected `!` because of return type
|
| - expected `!` because of return type
|
||||||
|
@ -251,11 +204,10 @@ LL + /* `loop {}` or `panic!("...")` */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:94:9
|
--> $DIR/coerce-loop-issue-122561.rs:92:9
|
||||||
|
|
|
|
||||||
LL | / for i in 0..5 {
|
LL | / for i in 0..5 {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_________^ expected `usize`, found `()`
|
| |_________^ expected `usize`, found `()`
|
||||||
|
|
|
|
||||||
|
@ -267,7 +219,7 @@ LL + /* `usize` value */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:101:9
|
--> $DIR/coerce-loop-issue-122561.rs:98:9
|
||||||
|
|
|
|
||||||
LL | / while false {
|
LL | / while false {
|
||||||
LL | |
|
LL | |
|
||||||
|
@ -282,7 +234,7 @@ LL + /* `usize` value */
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/coerce-loop-issue-122561.rs:107:23
|
--> $DIR/coerce-loop-issue-122561.rs:104:23
|
||||||
|
|
|
|
||||||
LL | let _ = |a: &[(); for x in 0..2 {}]| {};
|
LL | let _ = |a: &[(); for x in 0..2 {}]| {};
|
||||||
| ^^^^^^^^^^^^^^^^ expected `usize`, found `()`
|
| ^^^^^^^^^^^^^^^^ expected `usize`, found `()`
|
||||||
|
@ -293,7 +245,6 @@ help: consider returning a value here
|
||||||
LL | let _ = |a: &[(); for x in 0..2 {} /* `usize` value */]| {};
|
LL | let _ = |a: &[(); for x in 0..2 {} /* `usize` value */]| {};
|
||||||
| +++++++++++++++++++
|
| +++++++++++++++++++
|
||||||
|
|
||||||
error: aborting due to 18 previous errors; 2 warnings emitted
|
error: aborting due to 14 previous errors; 2 warnings emitted
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0658.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ const X : usize = 2;
|
||||||
const fn f(x: usize) -> usize {
|
const fn f(x: usize) -> usize {
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
for i in 0..x {
|
for i in 0..x {
|
||||||
//~^ ERROR cannot convert
|
//~^ ERROR cannot use `for`
|
||||||
//~| ERROR `for` is not allowed in a `const fn`
|
//~| ERROR cannot use `for`
|
||||||
//~| ERROR cannot call non-const fn
|
|
||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
sum
|
sum
|
||||||
|
|
|
@ -1,29 +1,4 @@
|
||||||
error[E0658]: `for` is not allowed in a `const fn`
|
error[E0015]: cannot use `for` loop on `std::ops::Range<usize>` in constant functions
|
||||||
--> $DIR/const-fn-error.rs:5:5
|
|
||||||
|
|
|
||||||
LL | / for i in 0..x {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | sum += i;
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: cannot convert `std::ops::Range<usize>` into an iterator in constant functions
|
|
||||||
--> $DIR/const-fn-error.rs:5:14
|
|
||||||
|
|
|
||||||
LL | for i in 0..x {
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
|
|
||||||
--> $DIR/const-fn-error.rs:5:14
|
--> $DIR/const-fn-error.rs:5:14
|
||||||
|
|
|
|
||||||
LL | for i in 0..x {
|
LL | for i in 0..x {
|
||||||
|
@ -31,7 +6,15 @@ LL | for i in 0..x {
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error[E0015]: cannot use `for` loop on `std::ops::Range<usize>` in constant functions
|
||||||
|
--> $DIR/const-fn-error.rs:5:14
|
||||||
|
|
|
||||||
|
LL | for i in 0..x {
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
error: aborting due to 2 previous errors
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
const _: () = {
|
const _: () = {
|
||||||
for _ in 0..5 {}
|
for _ in 0..5 {}
|
||||||
//~^ error: `for` is not allowed in a `const`
|
//~^ ERROR cannot use `for`
|
||||||
//~| ERROR: cannot convert
|
//~| ERROR cannot use `for`
|
||||||
//~| ERROR: cannot call
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,24 +1,4 @@
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/const-for-feature-gate.rs:4:5
|
|
||||||
|
|
|
||||||
LL | for _ in 0..5 {}
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
|
||||||
--> $DIR/const-for-feature-gate.rs:4:14
|
|
||||||
|
|
|
||||||
LL | for _ in 0..5 {}
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
|
||||||
--> $DIR/const-for-feature-gate.rs:4:14
|
--> $DIR/const-for-feature-gate.rs:4:14
|
||||||
|
|
|
|
||||||
LL | for _ in 0..5 {}
|
LL | for _ in 0..5 {}
|
||||||
|
@ -26,7 +6,15 @@ LL | for _ in 0..5 {}
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
|
--> $DIR/const-for-feature-gate.rs:4:14
|
||||||
|
|
|
||||||
|
LL | for _ in 0..5 {}
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
error: aborting due to 2 previous errors
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const _: () = {
|
const _: () = {
|
||||||
for _ in 0..5 {}
|
for _ in 0..5 {}
|
||||||
//~^ error: cannot call
|
//~^ ERROR cannot use `for`
|
||||||
//~| error: cannot convert
|
//~| ERROR cannot use `for`
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/const-for.rs:4:14
|
--> $DIR/const-for.rs:4:14
|
||||||
|
|
|
|
||||||
LL | for _ in 0..5 {}
|
LL | for _ in 0..5 {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/const-for.rs:4:14
|
--> $DIR/const-for.rs:4:14
|
||||||
|
|
|
|
||||||
LL | for _ in 0..5 {}
|
LL | for _ in 0..5 {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
const fn t() -> Option<()> {
|
const fn t() -> Option<()> {
|
||||||
Some(())?;
|
Some(())?;
|
||||||
//~^ error: `?` is not allowed in a `const fn`
|
//~^ ERROR `?` is not allowed
|
||||||
//~| ERROR: cannot convert
|
//~| ERROR `?` is not allowed
|
||||||
//~| ERROR: cannot determine
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,19 @@
|
||||||
error[E0658]: `?` is not allowed in a `const fn`
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/const-try-feature-gate.rs:4:5
|
--> $DIR/const-try-feature-gate.rs:4:5
|
||||||
|
|
|
|
||||||
LL | Some(())?;
|
LL | Some(())?;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #74935 <https://github.com/rust-lang/rust/issues/74935> for more information
|
|
||||||
= help: add `#![feature(const_try)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `Option<()>` in constant functions
|
|
||||||
--> $DIR/const-try-feature-gate.rs:4:5
|
|
||||||
|
|
|
||||||
LL | Some(())?;
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `Option<()>` in constant functions
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/const-try-feature-gate.rs:4:5
|
--> $DIR/const-try-feature-gate.rs:4:5
|
||||||
|
|
|
|
||||||
LL | Some(())?;
|
LL | Some(())?;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ impl const Try for TryMe {
|
||||||
|
|
||||||
const fn t() -> TryMe {
|
const fn t() -> TryMe {
|
||||||
TryMe?;
|
TryMe?;
|
||||||
//~^ ERROR `?` cannot determine the branch of `TryMe` in constant functions
|
//~^ ERROR `?` is not allowed on
|
||||||
//~| ERROR `?` cannot convert from residual of `TryMe` in constant functions
|
//~| ERROR `?` is not allowed on
|
||||||
TryMe
|
TryMe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ LL | impl const Try for TryMe {
|
||||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||||
= note: adding a non-const method body in the future would be a breaking change
|
= note: adding a non-const method body in the future would be a breaking change
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `TryMe` in constant functions
|
error[E0015]: `?` is not allowed on `TryMe` in constant functions
|
||||||
--> $DIR/const-try.rs:35:5
|
--> $DIR/const-try.rs:35:5
|
||||||
|
|
|
|
||||||
LL | TryMe?;
|
LL | TryMe?;
|
||||||
|
@ -24,7 +24,7 @@ LL | TryMe?;
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions
|
error[E0015]: `?` is not allowed on `TryMe` in constant functions
|
||||||
--> $DIR/const-try.rs:35:5
|
--> $DIR/const-try.rs:35:5
|
||||||
|
|
|
|
||||||
LL | TryMe?;
|
LL | TryMe?;
|
||||||
|
|
|
@ -50,15 +50,15 @@ const _: i32 = {
|
||||||
const _: i32 = {
|
const _: i32 = {
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
|
|
||||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
for i in 0..4 {
|
||||||
//~^ ERROR: cannot call
|
//~^ ERROR: cannot use `for`
|
||||||
//~| ERROR: cannot convert
|
//~| ERROR: cannot use `for`
|
||||||
x += i;
|
x += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
for i in 0..4 {
|
||||||
//~^ ERROR: cannot call
|
//~^ ERROR: cannot use `for`
|
||||||
//~| ERROR: cannot convert
|
//~| ERROR: cannot use `for`
|
||||||
x += i;
|
x += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,42 +1,4 @@
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/loop.rs:53:5
|
|
||||||
|
|
|
||||||
LL | / for i in 0..4 {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | x += i;
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/loop.rs:59:5
|
|
||||||
|
|
|
||||||
LL | / for i in 0..4 {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | x += i;
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
|
||||||
--> $DIR/loop.rs:53:14
|
|
||||||
|
|
|
||||||
LL | for i in 0..4 {
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
|
||||||
--> $DIR/loop.rs:53:14
|
--> $DIR/loop.rs:53:14
|
||||||
|
|
|
|
||||||
LL | for i in 0..4 {
|
LL | for i in 0..4 {
|
||||||
|
@ -44,17 +6,16 @@ LL | for i in 0..4 {
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/loop.rs:59:14
|
--> $DIR/loop.rs:53:14
|
||||||
|
|
|
|
||||||
LL | for i in 0..4 {
|
LL | for i in 0..4 {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
--> $DIR/loop.rs:59:14
|
--> $DIR/loop.rs:59:14
|
||||||
|
|
|
|
||||||
LL | for i in 0..4 {
|
LL | for i in 0..4 {
|
||||||
|
@ -62,7 +23,15 @@ LL | for i in 0..4 {
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error[E0015]: cannot use `for` loop on `std::ops::Range<i32>` in constants
|
||||||
|
--> $DIR/loop.rs:59:14
|
||||||
|
|
|
||||||
|
LL | for i in 0..4 {
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
error: aborting due to 4 previous errors
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
const fn opt() -> Option<i32> {
|
const fn opt() -> Option<i32> {
|
||||||
let x = Some(2);
|
let x = Some(2);
|
||||||
x?; //~ ERROR `?` is not allowed in a `const fn`
|
x?;
|
||||||
//~^ ERROR: cannot convert
|
//~^ ERROR: `?` is not allowed
|
||||||
//~| ERROR: cannot determine
|
//~| ERROR: `?` is not allowed
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,19 @@
|
||||||
error[E0658]: `?` is not allowed in a `const fn`
|
error[E0015]: `?` is not allowed on `Option<i32>` in constant functions
|
||||||
--> $DIR/try.rs:6:5
|
--> $DIR/try.rs:6:5
|
||||||
|
|
|
|
||||||
LL | x?;
|
LL | x?;
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
= note: see issue #74935 <https://github.com/rust-lang/rust/issues/74935> for more information
|
|
||||||
= help: add `#![feature(const_try)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `Option<i32>` in constant functions
|
|
||||||
--> $DIR/try.rs:6:5
|
|
||||||
|
|
|
||||||
LL | x?;
|
|
||||||
| ^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `Option<i32>` in constant functions
|
error[E0015]: `?` is not allowed on `Option<i32>` in constant functions
|
||||||
--> $DIR/try.rs:6:5
|
--> $DIR/try.rs:6:5
|
||||||
|
|
|
|
||||||
LL | x?;
|
LL | x?;
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
|
|
@ -4,44 +4,36 @@ error[E0635]: unknown feature `const_convert`
|
||||||
LL | #![feature(const_convert)]
|
LL | #![feature(const_convert)]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `Result<(), ()>` in constant functions
|
error[E0015]: `?` is not allowed on `Result<(), ()>` in constant functions
|
||||||
--> $DIR/try-operator.rs:10:9
|
--> $DIR/try-operator.rs:10:9
|
||||||
|
|
|
|
||||||
LL | Err(())?;
|
LL | Err(())?;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/result.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `Result<bool, ()>` in constant functions
|
error[E0015]: `?` is not allowed on `Result<bool, ()>` in constant functions
|
||||||
--> $DIR/try-operator.rs:10:9
|
--> $DIR/try-operator.rs:10:9
|
||||||
|
|
|
|
||||||
LL | Err(())?;
|
LL | Err(())?;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/result.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `Option<()>` in constant functions
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/try-operator.rs:18:9
|
--> $DIR/try-operator.rs:18:9
|
||||||
|
|
|
|
||||||
LL | None?;
|
LL | None?;
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `Option<()>` in constant functions
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/try-operator.rs:18:9
|
--> $DIR/try-operator.rs:18:9
|
||||||
|
|
|
|
||||||
LL | None?;
|
LL | None?;
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
Vec::<[(); 1 + for x in 0..1 {}]>::new();
|
Vec::<[(); 1 + for x in 0..1 {}]>::new();
|
||||||
//~^ ERROR cannot add
|
//~^ ERROR cannot add
|
||||||
//~| ERROR `for` is not allowed in a `const`
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/issue-50582.rs:2:20
|
|
||||||
|
|
|
||||||
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0277]: cannot add `()` to `{integer}`
|
error[E0277]: cannot add `()` to `{integer}`
|
||||||
--> $DIR/issue-50582.rs:2:18
|
--> $DIR/issue-50582.rs:2:18
|
||||||
|
|
|
|
||||||
|
@ -26,7 +16,6 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
|
||||||
`&f64` implements `Add`
|
`&f64` implements `Add`
|
||||||
and 56 others
|
and 56 others
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0658.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
|y: Vec<[(); for x in 0..2 {}]>| {};
|
|y: Vec<[(); for x in 0..2 {}]>| {};
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR `for` is not allowed in a `const`
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/issue-50585.rs:2:18
|
|
||||||
|
|
|
||||||
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-50585.rs:2:18
|
--> $DIR/issue-50585.rs:2:18
|
||||||
|
|
|
|
||||||
|
@ -20,7 +10,6 @@ help: consider returning a value here
|
||||||
LL | |y: Vec<[(); for x in 0..2 {} /* `usize` value */]>| {};
|
LL | |y: Vec<[(); for x in 0..2 {} /* `usize` value */]>| {};
|
||||||
| +++++++++++++++++++
|
| +++++++++++++++++++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0658.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ fn main() {
|
||||||
//~^ WARN denote infinite loops with
|
//~^ WARN denote infinite loops with
|
||||||
|
|
||||||
[(); { for _ in 0usize.. {}; 0}];
|
[(); { for _ in 0usize.. {}; 0}];
|
||||||
//~^ ERROR `for` is not allowed in a `const`
|
//~^ ERROR cannot use `for`
|
||||||
//~| ERROR cannot convert
|
//~| ERROR cannot use `for`
|
||||||
//~| ERROR cannot call
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,6 @@ LL | [(); {while true {break}; 0}];
|
||||||
|
|
|
|
||||||
= note: `#[warn(while_true)]` on by default
|
= note: `#[warn(while_true)]` on by default
|
||||||
|
|
||||||
error[E0658]: `for` is not allowed in a `const`
|
|
||||||
--> $DIR/issue-52443.rs:9:12
|
|
||||||
|
|
|
||||||
LL | [(); { for _ in 0usize.. {}; 0}];
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
|
|
||||||
= help: add `#![feature(const_for)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-52443.rs:2:10
|
--> $DIR/issue-52443.rs:2:10
|
||||||
|
|
|
|
||||||
|
@ -41,17 +31,7 @@ help: give the `break` a value of the expected type
|
||||||
LL | [(); loop { break 42 }];
|
LL | [(); loop { break 42 }];
|
||||||
| ++
|
| ++
|
||||||
|
|
||||||
error[E0015]: cannot convert `RangeFrom<usize>` into an iterator in constants
|
error[E0015]: cannot use `for` loop on `RangeFrom<usize>` in constants
|
||||||
--> $DIR/issue-52443.rs:9:21
|
|
||||||
|
|
|
||||||
LL | [(); { for _ in 0usize.. {}; 0}];
|
|
||||||
| ^^^^^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants
|
|
||||||
--> $DIR/issue-52443.rs:9:21
|
--> $DIR/issue-52443.rs:9:21
|
||||||
|
|
|
|
||||||
LL | [(); { for _ in 0usize.. {}; 0}];
|
LL | [(); { for _ in 0usize.. {}; 0}];
|
||||||
|
@ -59,7 +39,16 @@ LL | [(); { for _ in 0usize.. {}; 0}];
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 5 previous errors; 1 warning emitted
|
error[E0015]: cannot use `for` loop on `RangeFrom<usize>` in constants
|
||||||
|
--> $DIR/issue-52443.rs:9:21
|
||||||
|
|
|
||||||
|
LL | [(); { for _ in 0usize.. {}; 0}];
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0308, E0658.
|
error: aborting due to 4 previous errors; 1 warning emitted
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0015, E0308.
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
For more information about an error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -11,9 +11,9 @@ pub trait MyTrait {
|
||||||
|
|
||||||
impl const MyTrait for () {
|
impl const MyTrait for () {
|
||||||
fn method(&self) -> Option<()> {
|
fn method(&self) -> Option<()> {
|
||||||
Some(())?; //~ ERROR `?` is not allowed in a `const fn`
|
Some(())?;
|
||||||
//~^ ERROR `?` cannot determine the branch of `Option<()>` in constant functions
|
//~^ ERROR `?` is not allowed on
|
||||||
//~| ERROR `?` cannot convert from residual of `Option<()>` in constant functions
|
//~| ERROR `?` is not allowed on
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,19 @@
|
||||||
error[E0658]: `?` is not allowed in a `const fn`
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/hir-const-check.rs:14:9
|
--> $DIR/hir-const-check.rs:14:9
|
||||||
|
|
|
|
||||||
LL | Some(())?;
|
LL | Some(())?;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #74935 <https://github.com/rust-lang/rust/issues/74935> for more information
|
|
||||||
= help: add `#![feature(const_try)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `Option<()>` in constant functions
|
|
||||||
--> $DIR/hir-const-check.rs:14:9
|
|
||||||
|
|
|
||||||
LL | Some(())?;
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `Option<()>` in constant functions
|
error[E0015]: `?` is not allowed on `Option<()>` in constant functions
|
||||||
--> $DIR/hir-const-check.rs:14:9
|
--> $DIR/hir-const-check.rs:14:9
|
||||||
|
|
|
|
||||||
LL | Some(())?;
|
LL | Some(())?;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: impl defined here, but it is not `const`
|
|
||||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0658.
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ impl const Try for TryMe {
|
||||||
|
|
||||||
const fn t() -> TryMe {
|
const fn t() -> TryMe {
|
||||||
TryMe?;
|
TryMe?;
|
||||||
//~^ ERROR `?` cannot determine the branch of `TryMe` in constant functions
|
//~^ ERROR `?` is not allowed on
|
||||||
//~| ERROR `?` cannot convert from residual of `TryMe` in constant functions
|
//~| ERROR `?` is not allowed on
|
||||||
TryMe
|
TryMe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ LL | impl const Try for TryMe {
|
||||||
= help: implement the missing item: `fn from_output(_: <Self as Try>::Output) -> Self { todo!() }`
|
= help: implement the missing item: `fn from_output(_: <Self as Try>::Output) -> Self { todo!() }`
|
||||||
= help: implement the missing item: `fn branch(self) -> ControlFlow<<Self as Try>::Residual, <Self as Try>::Output> { todo!() }`
|
= help: implement the missing item: `fn branch(self) -> ControlFlow<<Self as Try>::Residual, <Self as Try>::Output> { todo!() }`
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `TryMe` in constant functions
|
error[E0015]: `?` is not allowed on `TryMe` in constant functions
|
||||||
--> $DIR/ice-126148-failed-to-normalize.rs:20:5
|
--> $DIR/ice-126148-failed-to-normalize.rs:20:5
|
||||||
|
|
|
|
||||||
LL | TryMe?;
|
LL | TryMe?;
|
||||||
|
@ -41,7 +41,7 @@ LL | TryMe?;
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions
|
error[E0015]: `?` is not allowed on `TryMe` in constant functions
|
||||||
--> $DIR/ice-126148-failed-to-normalize.rs:20:5
|
--> $DIR/ice-126148-failed-to-normalize.rs:20:5
|
||||||
|
|
|
|
||||||
LL | TryMe?;
|
LL | TryMe?;
|
||||||
|
|
|
@ -16,7 +16,7 @@ LL | impl const FromResidual for T {
|
||||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||||
= note: adding a non-const method body in the future would be a breaking change
|
= note: adding a non-const method body in the future would be a breaking change
|
||||||
|
|
||||||
error[E0015]: `?` cannot determine the branch of `T` in constant functions
|
error[E0015]: `?` is not allowed on `T` in constant functions
|
||||||
--> $DIR/trait-default-body-stability.rs:45:9
|
--> $DIR/trait-default-body-stability.rs:45:9
|
||||||
|
|
|
|
||||||
LL | T?
|
LL | T?
|
||||||
|
@ -24,7 +24,7 @@ LL | T?
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error[E0015]: `?` cannot convert from residual of `T` in constant functions
|
error[E0015]: `?` is not allowed on `T` in constant functions
|
||||||
--> $DIR/trait-default-body-stability.rs:45:9
|
--> $DIR/trait-default-body-stability.rs:45:9
|
||||||
|
|
|
|
||||||
LL | T?
|
LL | T?
|
||||||
|
|
|
@ -22,18 +22,6 @@ LL |
|
||||||
LL | struct Struct {}
|
LL | struct Struct {}
|
||||||
| ---------------- not a trait
|
| ---------------- not a trait
|
||||||
|
|
||||||
error: function not found in this trait
|
|
||||||
--> $DIR/rustc_must_implement_one_of_misuse.rs:8:34
|
|
||||||
|
|
|
||||||
LL | #[rustc_must_implement_one_of(a, b)]
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args
|
|
||||||
--> $DIR/rustc_must_implement_one_of_misuse.rs:14:1
|
|
||||||
|
|
|
||||||
LL | #[rustc_must_implement_one_of(a)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: function not found in this trait
|
error: function not found in this trait
|
||||||
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:31
|
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:31
|
||||||
|
|
|
|
||||||
|
@ -46,6 +34,18 @@ error: function not found in this trait
|
||||||
LL | #[rustc_must_implement_one_of(a, b)]
|
LL | #[rustc_must_implement_one_of(a, b)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
|
error: function not found in this trait
|
||||||
|
--> $DIR/rustc_must_implement_one_of_misuse.rs:8:34
|
||||||
|
|
|
||||||
|
LL | #[rustc_must_implement_one_of(a, b)]
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args
|
||||||
|
--> $DIR/rustc_must_implement_one_of_misuse.rs:14:1
|
||||||
|
|
|
||||||
|
LL | #[rustc_must_implement_one_of(a)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: not a function
|
error: not a function
|
||||||
--> $DIR/rustc_must_implement_one_of_misuse.rs:26:5
|
--> $DIR/rustc_must_implement_one_of_misuse.rs:26:5
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue