On const
pattern errors, point at the const
item definition
Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition: ``` error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { | ------------- LL | const X: EFoo; | ------------- constant defined here ... LL | A::X => println!("A::X"), | ^^^^ ```
This commit is contained in:
parent
490b2cc098
commit
c6205055e0
46 changed files with 365 additions and 43 deletions
|
@ -84,6 +84,8 @@ mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
|
|||
|
||||
mir_build_confused = missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable
|
||||
|
||||
mir_build_const_defined_here = constant defined here
|
||||
|
||||
mir_build_const_param_in_pattern = const parameters cannot be referenced in patterns
|
||||
|
||||
mir_build_const_pattern_depends_on_generic_parameter =
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use rustc_abi::{FieldIdx, VariantIdx};
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_errors::{Diag, PResult};
|
||||
use rustc_hir as hir;
|
||||
use rustc_index::Idx;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
|
@ -35,11 +36,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
id: hir::HirId,
|
||||
span: Span,
|
||||
) -> Box<Pat<'tcx>> {
|
||||
let mut convert = ConstToPat::new(self, id, span);
|
||||
let mut convert = ConstToPat::new(self, id, span, c);
|
||||
|
||||
match c.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => convert.unevaluated_to_pat(uv, ty),
|
||||
ty::ConstKind::Value(_, val) => convert.valtree_to_pat(val, ty),
|
||||
ty::ConstKind::Value(_, val) => match convert.valtree_to_pat(val, ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => convert.mk_err(err, ty),
|
||||
},
|
||||
_ => span_bug!(span, "Invalid `ConstKind` for `const_to_pat`: {:?}", c),
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +55,12 @@ struct ConstToPat<'tcx> {
|
|||
span: Span,
|
||||
|
||||
treat_byte_string_as_slice: bool,
|
||||
|
||||
c: ty::Const<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> ConstToPat<'tcx> {
|
||||
fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span) -> Self {
|
||||
fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span, c: ty::Const<'tcx>) -> Self {
|
||||
trace!(?pat_ctxt.typeck_results.hir_owner);
|
||||
ConstToPat {
|
||||
tcx: pat_ctxt.tcx,
|
||||
|
@ -64,6 +70,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
.typeck_results
|
||||
.treat_byte_string_as_slice
|
||||
.contains(&id.local_id),
|
||||
c,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,13 +78,32 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
ty.is_structural_eq_shallow(self.tcx)
|
||||
}
|
||||
|
||||
/// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
||||
fn mk_err(&self, mut err: Diag<'_>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
|
||||
if let ty::ConstKind::Unevaluated(uv) = self.c.kind() {
|
||||
let def_kind = self.tcx.def_kind(uv.def);
|
||||
if let hir::def::DefKind::AssocConst = def_kind
|
||||
&& let Some(def_id) = uv.def.as_local()
|
||||
{
|
||||
// Include the container item in the output.
|
||||
err.span_label(self.tcx.def_span(self.tcx.local_parent(def_id)), "");
|
||||
}
|
||||
if let hir::def::DefKind::Const | hir::def::DefKind::AssocConst = def_kind {
|
||||
err.span_label(
|
||||
self.tcx.def_span(uv.def),
|
||||
crate::fluent_generated::mir_build_const_defined_here,
|
||||
);
|
||||
}
|
||||
}
|
||||
Box::new(Pat { span: self.span, ty, kind: PatKind::Error(err.emit()) })
|
||||
}
|
||||
|
||||
fn unevaluated_to_pat(
|
||||
&mut self,
|
||||
uv: ty::UnevaluatedConst<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Box<Pat<'tcx>> {
|
||||
trace!(self.treat_byte_string_as_slice);
|
||||
let pat_from_kind = |kind| Box::new(Pat { span: self.span, ty, kind });
|
||||
|
||||
// It's not *technically* correct to be revealing opaque types here as borrowcheck has
|
||||
// not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even
|
||||
|
@ -96,44 +122,46 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
Ok(Ok(c)) => c,
|
||||
Err(ErrorHandled::Reported(_, _)) => {
|
||||
// Let's tell the use where this failing const occurs.
|
||||
let e = self.tcx.dcx().emit_err(CouldNotEvalConstPattern { span: self.span });
|
||||
return pat_from_kind(PatKind::Error(e));
|
||||
let err = self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span });
|
||||
return self.mk_err(err, ty);
|
||||
}
|
||||
Err(ErrorHandled::TooGeneric(_)) => {
|
||||
let e = self
|
||||
.tcx
|
||||
.dcx()
|
||||
.emit_err(ConstPatternDependsOnGenericParameter { span: self.span });
|
||||
return pat_from_kind(PatKind::Error(e));
|
||||
.create_err(ConstPatternDependsOnGenericParameter { span: self.span });
|
||||
return self.mk_err(e, ty);
|
||||
}
|
||||
Ok(Err(bad_ty)) => {
|
||||
// The pattern cannot be turned into a valtree.
|
||||
let e = match bad_ty.kind() {
|
||||
ty::Adt(def, ..) => {
|
||||
assert!(def.is_union());
|
||||
self.tcx.dcx().emit_err(UnionPattern { span: self.span })
|
||||
self.tcx.dcx().create_err(UnionPattern { span: self.span })
|
||||
}
|
||||
ty::FnPtr(..) | ty::RawPtr(..) => {
|
||||
self.tcx.dcx().emit_err(PointerPattern { span: self.span })
|
||||
self.tcx.dcx().create_err(PointerPattern { span: self.span })
|
||||
}
|
||||
_ => self
|
||||
.tcx
|
||||
.dcx()
|
||||
.emit_err(InvalidPattern { span: self.span, non_sm_ty: bad_ty }),
|
||||
.create_err(InvalidPattern { span: self.span, non_sm_ty: bad_ty }),
|
||||
};
|
||||
return pat_from_kind(PatKind::Error(e));
|
||||
return self.mk_err(e, ty);
|
||||
}
|
||||
};
|
||||
|
||||
// Convert the valtree to a const.
|
||||
let inlined_const_as_pat = self.valtree_to_pat(valtree, ty);
|
||||
let inlined_const_as_pat = match self.valtree_to_pat(valtree, ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => self.mk_err(err, ty),
|
||||
};
|
||||
|
||||
if !inlined_const_as_pat.references_error() {
|
||||
// Always check for `PartialEq` if we had no other errors yet.
|
||||
if !self.type_has_partial_eq_impl(ty) {
|
||||
let err = TypeNotPartialEq { span: self.span, non_peq_ty: ty };
|
||||
let e = self.tcx.dcx().emit_err(err);
|
||||
return pat_from_kind(PatKind::Error(e));
|
||||
return self.mk_err(self.tcx.dcx().create_err(err), ty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,14 +203,20 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
let field = FieldIdx::new(idx);
|
||||
// Patterns can only use monomorphic types.
|
||||
let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty);
|
||||
FieldPat { field, pattern: self.valtree_to_pat(val, ty) }
|
||||
FieldPat {
|
||||
field,
|
||||
pattern: match self.valtree_to_pat(val, ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => self.mk_err(err, ty),
|
||||
},
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
// Recursive helper for `to_pat`; invoke that (instead of calling this directly).
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
|
||||
fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> PResult<'_, Box<Pat<'tcx>>> {
|
||||
let span = self.span;
|
||||
let tcx = self.tcx;
|
||||
let kind = match ty.kind() {
|
||||
|
@ -191,9 +225,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
// patterns.
|
||||
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty);
|
||||
let err = TypeNotStructural { span, non_sm_ty: ty };
|
||||
let e = tcx.dcx().emit_err(err);
|
||||
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
||||
PatKind::Error(e)
|
||||
return Err(tcx.dcx().create_err(err));
|
||||
}
|
||||
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
||||
let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap();
|
||||
|
@ -227,7 +259,10 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
prefix: cv
|
||||
.unwrap_branch()
|
||||
.iter()
|
||||
.map(|val| self.valtree_to_pat(*val, *elem_ty))
|
||||
.map(|val| match self.valtree_to_pat(*val, *elem_ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => self.mk_err(err, ty),
|
||||
})
|
||||
.collect(),
|
||||
slice: None,
|
||||
suffix: Box::new([]),
|
||||
|
@ -236,7 +271,10 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
prefix: cv
|
||||
.unwrap_branch()
|
||||
.iter()
|
||||
.map(|val| self.valtree_to_pat(*val, *elem_ty))
|
||||
.map(|val| match self.valtree_to_pat(*val, *elem_ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => self.mk_err(err, ty),
|
||||
})
|
||||
.collect(),
|
||||
slice: None,
|
||||
suffix: Box::new([]),
|
||||
|
@ -252,10 +290,9 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
// deref pattern.
|
||||
_ => {
|
||||
if !pointee_ty.is_sized(tcx, self.typing_env) && !pointee_ty.is_slice() {
|
||||
let err = UnsizedPattern { span, non_sm_ty: *pointee_ty };
|
||||
let e = tcx.dcx().emit_err(err);
|
||||
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
||||
PatKind::Error(e)
|
||||
return Err(tcx
|
||||
.dcx()
|
||||
.create_err(UnsizedPattern { span, non_sm_ty: *pointee_ty }));
|
||||
} else {
|
||||
// `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when
|
||||
// matching against references, you can only use byte string literals.
|
||||
|
@ -270,7 +307,10 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
_ => *pointee_ty,
|
||||
};
|
||||
// References have the same valtree representation as their pointee.
|
||||
let subpattern = self.valtree_to_pat(cv, pointee_ty);
|
||||
let subpattern = match self.valtree_to_pat(cv, pointee_ty) {
|
||||
Ok(pat) => pat,
|
||||
Err(err) => self.mk_err(err, ty),
|
||||
};
|
||||
PatKind::Deref { subpattern }
|
||||
}
|
||||
}
|
||||
|
@ -286,8 +326,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
if is_nan {
|
||||
// NaNs are not ever equal to anything so they make no sense as patterns.
|
||||
// Also see <https://github.com/rust-lang/rfcs/pull/3535>.
|
||||
let e = tcx.dcx().emit_err(NaNPattern { span });
|
||||
PatKind::Error(e)
|
||||
return Err(tcx.dcx().create_err(NaNPattern { span }));
|
||||
} else {
|
||||
PatKind::Constant {
|
||||
value: mir::Const::Ty(ty, ty::Const::new_value(tcx, cv, ty)),
|
||||
|
@ -306,12 +345,10 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
}
|
||||
_ => {
|
||||
let err = InvalidPattern { span, non_sm_ty: ty };
|
||||
let e = tcx.dcx().emit_err(err);
|
||||
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
||||
PatKind::Error(e)
|
||||
return Err(tcx.dcx().create_err(err));
|
||||
}
|
||||
};
|
||||
|
||||
Box::new(Pat { span, ty, kind })
|
||||
Ok(Box::new(Pat { span, ty, kind }))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,44 @@
|
|||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/associated-const-type-parameter-pattern.rs:20:9
|
||||
|
|
||||
LL | pub trait Foo {
|
||||
| -------------
|
||||
LL | const X: EFoo;
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | A::X => println!("A::X"),
|
||||
| ^^^^
|
||||
|
||||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/associated-const-type-parameter-pattern.rs:22:9
|
||||
|
|
||||
LL | pub trait Foo {
|
||||
| -------------
|
||||
LL | const X: EFoo;
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | B::X => println!("B::X"),
|
||||
| ^^^^
|
||||
|
||||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/associated-const-type-parameter-pattern.rs:30:9
|
||||
|
|
||||
LL | pub trait Foo {
|
||||
| -------------
|
||||
LL | const X: EFoo;
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | let A::X = arg;
|
||||
| ^^^^
|
||||
|
||||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/associated-const-type-parameter-pattern.rs:28:48
|
||||
|
|
||||
LL | pub trait Foo {
|
||||
| -------------
|
||||
LL | const X: EFoo;
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
|
||||
| ^^^^
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ LL | pub struct Opcode2<S>(&'a S);
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9
|
||||
|
|
||||
LL | impl Opcode2 {
|
||||
| ------------
|
||||
LL | pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
|
||||
| ---------------------- constant defined here
|
||||
...
|
||||
LL | Opcode2::OP2 => unimplemented!(),
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ LL | const NEG_NEG_128: i8 = -NEG_128;
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/const-eval-overflow-2.rs:15:9
|
||||
|
|
||||
LL | const NEG_NEG_128: i8 = -NEG_128;
|
||||
| --------------------- constant defined here
|
||||
...
|
||||
LL | NEG_NEG_128 => println!("A"),
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ error: could not evaluate constant pattern
|
|||
|
|
||||
LL | 10..=BAR => {},
|
||||
| ^^^
|
||||
...
|
||||
LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
|
||||
| -------------- constant defined here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann
|
|||
LL | consts::SOME => panic!(),
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
::: $DIR/auxiliary/consts.rs:11:1
|
||||
|
|
||||
LL | pub const SOME: Option<CustomEq> = Some(CustomEq);
|
||||
| -------------------------------- constant defined here
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
|
@ -13,6 +18,11 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann
|
|||
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
::: $DIR/auxiliary/consts.rs:15:5
|
||||
|
|
||||
LL | const SOME: Option<CustomEq> = Some(CustomEq);
|
||||
| ---------------------------- constant defined here
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
|
|
|
@ -1,24 +1,36 @@
|
|||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:9:9
|
||||
|
|
||||
LL | const C: *const u8 = &0;
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:16:9
|
||||
|
|
||||
LL | const C_INNER: (*const u8, u8) = (C, 0);
|
||||
| ------------------------------ constant defined here
|
||||
...
|
||||
LL | C_INNER => {}
|
||||
| ^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:27:9
|
||||
|
|
||||
LL | const D: *const [u8; 4] = b"abcd";
|
||||
| ----------------------- constant defined here
|
||||
...
|
||||
LL | D => {}
|
||||
| ^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:32:9
|
||||
|
|
||||
LL | const STR: *const str = "abcd";
|
||||
| --------------------- constant defined here
|
||||
...
|
||||
LL | STR => {}
|
||||
| ^^^
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-44333.rs:15:9
|
||||
|
|
||||
LL | const FOO: Func = foo;
|
||||
| --------------- constant defined here
|
||||
...
|
||||
LL | FOO => println!("foo"),
|
||||
| ^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-44333.rs:16:9
|
||||
|
|
||||
LL | const BAR: Func = bar;
|
||||
| --------------- constant defined here
|
||||
...
|
||||
LL | BAR => println!("bar"),
|
||||
| ^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq`
|
||||
--> $DIR/issue-65466.rs:14:9
|
||||
|
|
||||
LL | const C: &[O<B>] = &[O::None];
|
||||
| ---------------- constant defined here
|
||||
...
|
||||
LL | C => (),
|
||||
| ^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/no-eq-branch-fail.rs:19:9
|
||||
|
|
||||
LL | const BAR_BAZ: Foo = if 42 == 42 {
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | BAR_BAZ => panic!(),
|
||||
| ^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `Option<NoPartialEq>` in a pattern, the type must implement `PartialEq`
|
||||
--> $DIR/reject_non_partial_eq.rs:28:9
|
||||
|
|
||||
LL | const NO_PARTIAL_EQ_NONE: Option<NoPartialEq> = None;
|
||||
| --------------------------------------------- constant defined here
|
||||
...
|
||||
LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -36,63 +36,63 @@ fn main() {
|
|||
#[derive(PartialEq, Eq, Debug)]
|
||||
enum Derive<X> { Some(X), None, }
|
||||
|
||||
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
|
||||
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive); //~ NOTE constant defined here
|
||||
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const FIELD: OND = TrivialEq(Some(NoDerive)).0;
|
||||
const FIELD: OND = TrivialEq(Some(NoDerive)).0; //~ NOTE constant defined here
|
||||
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const NO_DERIVE_SOME: OND = Some(NoDerive);
|
||||
const INDIRECT: OND = NO_DERIVE_SOME;
|
||||
const INDIRECT: OND = NO_DERIVE_SOME; //~ NOTE constant defined here
|
||||
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const TUPLE: (OND, OND) = (None, Some(NoDerive));
|
||||
const TUPLE: (OND, OND) = (None, Some(NoDerive)); //~ NOTE constant defined here
|
||||
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
|
||||
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); //~ NOTE constant defined here
|
||||
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const ARRAY: [OND; 2] = [None, Some(NoDerive)];
|
||||
const ARRAY: [OND; 2] = [None, Some(NoDerive)]; //~ NOTE constant defined here
|
||||
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const REPEAT: [OND; 2] = [Some(NoDerive); 2];
|
||||
const REPEAT: [OND; 2] = [Some(NoDerive); 2]; //~ NOTE constant defined here
|
||||
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
trait Trait: Sized { const ASSOC: Option<Self>; }
|
||||
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
|
||||
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const BLOCK: OND = { NoDerive; Some(NoDerive) };
|
||||
const BLOCK: OND = { NoDerive; Some(NoDerive) }; //~ NOTE constant defined here
|
||||
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const ADDR_OF: &OND = &Some(NoDerive);
|
||||
const ADDR_OF: &OND = &Some(NoDerive); //~ NOTE constant defined here
|
||||
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:40:36
|
||||
|
|
||||
LL | const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
|
||||
| ---------------------------- constant defined here
|
||||
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||
| ^^^^
|
||||
|
|
||||
|
@ -10,6 +12,8 @@ LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:46:28
|
||||
|
|
||||
LL | const FIELD: OND = TrivialEq(Some(NoDerive)).0;
|
||||
| ---------------- constant defined here
|
||||
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
|
@ -19,6 +23,8 @@ LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:53:27
|
||||
|
|
||||
LL | const INDIRECT: OND = NO_DERIVE_SOME;
|
||||
| ------------------- constant defined here
|
||||
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^
|
||||
|
|
||||
|
@ -28,6 +34,8 @@ LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops")
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:59:36
|
||||
|
|
||||
LL | const TUPLE: (OND, OND) = (None, Some(NoDerive));
|
||||
| ----------------------- constant defined here
|
||||
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
|
@ -37,6 +45,8 @@ LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoop
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:65:28
|
||||
|
|
||||
LL | const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
|
||||
| -------------------------- constant defined here
|
||||
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -46,6 +56,8 @@ LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => p
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:71:36
|
||||
|
|
||||
LL | const ARRAY: [OND; 2] = [None, Some(NoDerive)];
|
||||
| --------------------- constant defined here
|
||||
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
|
@ -55,6 +67,8 @@ LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoop
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:77:33
|
||||
|
|
||||
LL | const REPEAT: [OND; 2] = [Some(NoDerive); 2];
|
||||
| ---------------------- constant defined here
|
||||
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||
| ^^^^^^
|
||||
|
|
||||
|
@ -64,6 +78,9 @@ LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:84:28
|
||||
|
|
||||
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
|
||||
| ------------------ ------------------------- constant defined here
|
||||
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -73,6 +90,8 @@ LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => p
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:90:28
|
||||
|
|
||||
LL | const BLOCK: OND = { NoDerive; Some(NoDerive) };
|
||||
| ---------------- constant defined here
|
||||
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
|
@ -82,6 +101,8 @@ LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:96:29
|
||||
|
|
||||
LL | const ADDR_OF: &OND = &Some(NoDerive);
|
||||
| ------------------- constant defined here
|
||||
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||
| ^^^^^^^
|
||||
|
|
||||
|
|
|
@ -34,18 +34,27 @@ LL | const C: &i32 = unsafe { &S_MUT };
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refs_to_static_fail_invalid.rs:14:9
|
||||
|
|
||||
LL | const C: &bool = unsafe { std::mem::transmute(&S) };
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refs_to_static_fail_invalid.rs:30:9
|
||||
|
|
||||
LL | const C: &i8 = unsafe { &S };
|
||||
| ------------ constant defined here
|
||||
...
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refs_to_static_fail_invalid.rs:45:9
|
||||
|
|
||||
LL | const C: &i32 = unsafe { &S_MUT };
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ LL | const NUM: u8 = xyz();
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/issue-43105.rs:8:9
|
||||
|
|
||||
LL | const NUM: u8 = xyz();
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | NUM => unimplemented!(),
|
||||
| ^^^
|
||||
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/issue-73976-polymorphic.rs:20:37
|
||||
|
|
||||
LL | impl<T: 'static> GetTypeId<T> {
|
||||
| -----------------------------
|
||||
LL | pub const VALUE: TypeId = TypeId::of::<T>();
|
||||
| ----------------------- constant defined here
|
||||
...
|
||||
LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/issue-73976-polymorphic.rs:31:42
|
||||
|
|
||||
LL | impl<T: 'static> GetTypeNameLen<T> {
|
||||
| ----------------------------------
|
||||
LL | pub const VALUE: usize = any::type_name::<T>().len();
|
||||
| ---------------------- constant defined here
|
||||
...
|
||||
LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ LL | let x = 42;
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/issue-78655.rs:7:9
|
||||
|
|
||||
LL | const FOO: *const u32 = {
|
||||
| --------------------- constant defined here
|
||||
...
|
||||
LL | let FOO = FOO;
|
||||
| ^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
error[E0158]: constant pattern depends on a generic parameter
|
||||
--> $DIR/issue-79137-toogeneric.rs:12:43
|
||||
|
|
||||
LL | impl<T> GetVariantCount<T> {
|
||||
| --------------------------
|
||||
LL | pub const VALUE: usize = std::mem::variant_count::<T>();
|
||||
| ---------------------- constant defined here
|
||||
...
|
||||
LL | matches!(GetVariantCount::<T>::VALUE, GetVariantCount::<T>::VALUE)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: cannot use unsized non-slice type `Username` in constant patterns
|
||||
--> $DIR/issue-87046.rs:28:13
|
||||
|
|
||||
LL | pub const ROOT_USER: &Username = Username::from_str("root");
|
||||
| ------------------------------ constant defined here
|
||||
...
|
||||
LL | ROOT_USER => true,
|
||||
| ^^^^^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-89088.rs:16:9
|
||||
|
|
||||
LL | const FOO: &A = &A::Field(Cow::Borrowed("foo"));
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | FOO => todo!(),
|
||||
| ^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/match_ice.rs:11:9
|
||||
|
|
||||
LL | const C: &S = &S;
|
||||
| ----------- constant defined here
|
||||
LL | match C {
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
|
||||
|
|
|
@ -40,24 +40,36 @@ LL | match static_cross_crate::OPT_ZERO {
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refers_to_static_cross_crate.rs:40:9
|
||||
|
|
||||
LL | const SLICE_MUT: &[u8; 1] = {
|
||||
| ------------------------- constant defined here
|
||||
...
|
||||
LL | SLICE_MUT => true,
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refers_to_static_cross_crate.rs:48:9
|
||||
|
|
||||
LL | const U8_MUT: &u8 = {
|
||||
| ----------------- constant defined here
|
||||
...
|
||||
LL | U8_MUT => true,
|
||||
| ^^^^^^
|
||||
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refers_to_static_cross_crate.rs:58:9
|
||||
|
|
||||
LL | const U8_MUT2: &u8 = {
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | U8_MUT2 => true,
|
||||
| ^^^^^^^
|
||||
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const_refers_to_static_cross_crate.rs:65:9
|
||||
|
|
||||
LL | const U8_MUT3: &u8 = {
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | U8_MUT3 => true,
|
||||
| ^^^^^^^
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@ LL | const FIRST: = 10;
|
|||
error: could not evaluate constant pattern
|
||||
--> $DIR/missing_assoc_const_type.rs:19:9
|
||||
|
|
||||
LL | trait Range {
|
||||
| -----------
|
||||
LL | const FIRST: u8;
|
||||
| --------------- constant defined here
|
||||
...
|
||||
LL | TwoDigits::FIRST..=TwoDigits::LAST => 0,
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ error: could not evaluate constant pattern
|
|||
|
|
||||
LL | ZST => {}
|
||||
| ^^^
|
||||
...
|
||||
LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) };
|
||||
| ---------------- constant defined here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: `dyn Send` cannot be used in patterns
|
||||
--> $DIR/issue-70972-dyn-trait.rs:6:9
|
||||
|
|
||||
LL | const F: &'static dyn Send = &7u32;
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | F => panic!(),
|
||||
| ^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq`
|
||||
--> $DIR/issue-72896-non-partial-eq-const.rs:19:9
|
||||
|
|
||||
LL | const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };
|
||||
| ------------------------------- constant defined here
|
||||
...
|
||||
LL | CONST_SET => { /* ok */ }
|
||||
| ^^^^^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-115599.rs:5:12
|
||||
|
|
||||
LL | const CONST_STRING: String = String::new();
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | if let CONST_STRING = empty_str {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: `dyn PartialEq<u32>` cannot be used in patterns
|
||||
--> $DIR/issue-72565.rs:6:9
|
||||
|
|
||||
LL | const F: &'static dyn PartialEq<u32> = &7u32;
|
||||
| ------------------------------------ constant defined here
|
||||
...
|
||||
LL | F => panic!(),
|
||||
| ^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/const-partial_eq-fallback-ice.rs:14:12
|
||||
|
|
||||
LL | const CONSTANT: &&MyType = &&MyType;
|
||||
| ------------------------ constant defined here
|
||||
...
|
||||
LL | if let CONSTANT = &&MyType {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,48 +1,72 @@
|
|||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:96:9
|
||||
|
|
||||
LL | const QUUX: Quux = quux;
|
||||
| ---------------- constant defined here
|
||||
...
|
||||
LL | QUUX => {}
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:97:9
|
||||
|
|
||||
LL | const QUUX: Quux = quux;
|
||||
| ---------------- constant defined here
|
||||
...
|
||||
LL | QUUX => {}
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:106:9
|
||||
|
|
||||
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:107:9
|
||||
|
|
||||
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:113:9
|
||||
|
|
||||
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:121:9
|
||||
|
|
||||
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
|
||||
| -------------------------- constant defined here
|
||||
...
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:132:9
|
||||
|
|
||||
LL | const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
|
||||
| ---------------------------------- constant defined here
|
||||
...
|
||||
LL | WHOKNOWSQUUX => {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:134:9
|
||||
|
|
||||
LL | const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
|
||||
| ---------------------------------- constant defined here
|
||||
...
|
||||
LL | WHOKNOWSQUUX => {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
|
||||
|
|
||||
LL | const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
|
||||
| ------------------------------------ constant defined here
|
||||
...
|
||||
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-direct-struct-param.rs:21:9
|
||||
|
|
||||
LL | const WRAP_DIRECT_PARAM: WrapParam<NoDerive> = WrapParam(NoDerive(0));
|
||||
| -------------------------------------------- constant defined here
|
||||
...
|
||||
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9
|
||||
|
|
||||
LL | const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0));
|
||||
| ------------------------------------------------ constant defined here
|
||||
...
|
||||
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9
|
||||
|
|
||||
LL | const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDerive(0));
|
||||
| -------------------------------------------------------- constant defined here
|
||||
...
|
||||
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9
|
||||
|
|
||||
LL | const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
||||
| ----------------------------------------- constant defined here
|
||||
...
|
||||
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9
|
||||
|
|
||||
LL | const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
||||
| ------------------------------------------------- constant defined here
|
||||
...
|
||||
LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
|
|
@ -1,60 +1,90 @@
|
|||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:41:14
|
||||
|
|
||||
LL | const CFN1: Wrap<fn()> = Wrap(trivial);
|
||||
| ---------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN1) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:49:14
|
||||
|
|
||||
LL | const CFN2: Wrap<fn(SM)> = Wrap(sm_to);
|
||||
| ------------------------ constant defined here
|
||||
...
|
||||
LL | Wrap(CFN2) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:57:14
|
||||
|
|
||||
LL | const CFN3: Wrap<fn() -> SM> = Wrap(to_sm);
|
||||
| ---------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN3) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:65:14
|
||||
|
|
||||
LL | const CFN4: Wrap<fn(NotSM)> = Wrap(not_sm_to);
|
||||
| --------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN4) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:73:14
|
||||
|
|
||||
LL | const CFN5: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
|
||||
| ------------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN5) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:81:14
|
||||
|
|
||||
LL | const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to);
|
||||
| ------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN6) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:89:14
|
||||
|
|
||||
LL | const CFN7: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
|
||||
| -------------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN7) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:97:14
|
||||
|
|
||||
LL | const CFN8: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
|
||||
| ---------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN8) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:105:14
|
||||
|
|
||||
LL | const CFN9: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
|
||||
| ----------------------------------- constant defined here
|
||||
...
|
||||
LL | Wrap(CFN9) => count += 1,
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:127:9
|
||||
|
|
||||
LL | const CFOO: Foo = Foo {
|
||||
| --------------- constant defined here
|
||||
...
|
||||
LL | CFOO => count += 1,
|
||||
| ^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `&[B]` in a pattern, the type must implement `PartialEq`
|
||||
--> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9
|
||||
|
|
||||
LL | const A: &[B] = &[];
|
||||
| ------------- constant defined here
|
||||
...
|
||||
LL | A => (),
|
||||
| ^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:29:9
|
||||
|
|
||||
LL | const RR_B1: & & B = & & B(1);
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||
| ^^^^^
|
||||
|
|
||||
|
@ -10,6 +13,9 @@ LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0);
|
|||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9
|
||||
|
|
||||
LL | const RR_B1: & & B = & & B(1);
|
||||
| ------------------ constant defined here
|
||||
...
|
||||
LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||
| ^^^^^
|
||||
|
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-63479-match-fnptr.rs:32:7
|
||||
|
|
||||
LL | const TEST: Fn = my_fn;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | B(TEST) => println!("matched"),
|
||||
| ^^^^
|
||||
|
||||
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/issue-63479-match-fnptr.rs:37:5
|
||||
|
|
||||
LL | const TEST2: (Fn, u8) = (TEST, 0);
|
||||
| --------------------- constant defined here
|
||||
...
|
||||
LL | TEST2 => println!("matched"),
|
||||
| ^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:14:9
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | NAN => {},
|
||||
| ^^^
|
||||
|
|
||||
|
@ -10,6 +13,9 @@ LL | NAN => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:19:10
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | [NAN, _] => {},
|
||||
| ^^^
|
||||
|
|
||||
|
@ -19,6 +25,9 @@ LL | [NAN, _] => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:24:9
|
||||
|
|
||||
LL | const C: MyType<f32> = MyType(f32::NAN);
|
||||
| -------------------- constant defined here
|
||||
...
|
||||
LL | C => {},
|
||||
| ^
|
||||
|
|
||||
|
@ -28,6 +37,9 @@ LL | C => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:30:9
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | NAN..=1.0 => {},
|
||||
| ^^^
|
||||
|
|
||||
|
@ -37,6 +49,9 @@ LL | NAN..=1.0 => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:31:16
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | -1.0..=NAN => {},
|
||||
| ^^^
|
||||
|
|
||||
|
@ -46,6 +61,9 @@ LL | -1.0..=NAN => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:32:9
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | NAN.. => {},
|
||||
| ^^^
|
||||
|
|
||||
|
@ -55,6 +73,9 @@ LL | NAN.. => {},
|
|||
error: cannot use NaN in patterns
|
||||
--> $DIR/issue-6804-nan-match.rs:33:11
|
||||
|
|
||||
LL | const NAN: f64 = f64::NAN;
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | ..NAN => {},
|
||||
| ^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
|
||||
|
|
||||
LL | const FOO: Foo = Foo { x: 0 };
|
||||
| -------------- constant defined here
|
||||
...
|
||||
LL | FOO => { }
|
||||
| ^^^
|
||||
|
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: `Bar` cannot be used in patterns
|
||||
--> $DIR/structural-match-no-leak.rs:16:9
|
||||
|
|
||||
LL | const LEAK_FREE: bar::Bar = bar::leak_free();
|
||||
| ------------------------- constant defined here
|
||||
...
|
||||
LL | LEAK_FREE => (),
|
||||
| ^^^^^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: `foo::Foo` cannot be used in patterns
|
||||
--> $DIR/structural-match.rs:18:9
|
||||
|
|
||||
LL | const VALUE: Foo = value();
|
||||
| ---------------- constant defined here
|
||||
...
|
||||
LL | VALUE => (),
|
||||
| ^^^^^
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
error: cannot use unions in constant patterns
|
||||
--> $DIR/union-const-pat.rs:10:9
|
||||
|
|
||||
LL | const C: U = U { a: 10 };
|
||||
| ---------- constant defined here
|
||||
...
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue