Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis

Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
This commit is contained in:
bors 2021-03-22 19:48:27 +00:00
commit 5d04957a4b
128 changed files with 420 additions and 843 deletions

View file

@ -34,7 +34,7 @@
#![no_std]
#![forbid(unsafe_code)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#[macro_use]
extern crate alloc;

View file

@ -16,7 +16,7 @@
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -31,7 +31,7 @@
//! in the HIR, especially for multiple identifiers.
#![feature(crate_visibility_modifier)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(box_patterns)]
#![recursion_limit = "256"]

View file

@ -686,7 +686,6 @@ macro_rules! gate_all {
"to use an async block, remove the `||`: `async {`"
);
gate_all!(generators, "yield syntax is experimental");
gate_all!(or_patterns, "or-patterns syntax is experimental");
gate_all!(raw_ref_op, "raw address of syntax is experimental");
gate_all!(const_trait_bound_opt_out, "`?const` on trait bounds is experimental");
gate_all!(const_trait_impl, "const trait impls are experimental");

View file

@ -1,6 +1,6 @@
#![feature(bool_to_option)]
#![feature(crate_visibility_modifier)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(box_patterns)]
#![recursion_limit = "256"]

View file

@ -4,7 +4,7 @@
//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax`
//! to this crate.
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#[macro_use]
extern crate rustc_macros;

View file

@ -8,7 +8,7 @@
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![recursion_limit = "256"]

View file

@ -12,7 +12,7 @@
#![feature(extern_types)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
use back::write::{create_informational_target_machine, create_target_machine};

View file

@ -6,7 +6,7 @@
#![feature(try_blocks)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(associated_type_bounds)]
#![recursion_limit = "256"]
#![feature(box_syntax)]

View file

@ -22,7 +22,7 @@
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, PResult};
use rustc_feature::Features;
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, GateOr, Parser, RecoverComma};
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser, RecoverComma};
use rustc_parse::validate_attr;
use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
use rustc_session::lint::BuiltinLintDiagnostics;
@ -917,7 +917,7 @@ pub fn parse_ast_fragment<'a>(
}
AstFragmentKind::Ty => AstFragment::Ty(this.parse_ty()?),
AstFragmentKind::Pat => {
AstFragment::Pat(this.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)?)
AstFragment::Pat(this.parse_pat_allow_top_alt(None, RecoverComma::No)?)
}
AstFragmentKind::Arms
| AstFragmentKind::Fields

View file

@ -2,7 +2,7 @@
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(destructuring_assignment)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_span)]

View file

@ -277,6 +277,8 @@ macro_rules! declare_features {
(accepted, min_const_generics, "1.51.0", Some(74878), None),
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
(accepted, unsafe_block_in_unsafe_fn, "1.51.0", Some(71668), None),
/// Allows the use of or-patterns (e.g., `0 | 1`).
(accepted, or_patterns, "1.53.0", Some(54883), None),
// -------------------------------------------------------------------------
// feature-group-end: accepted features

View file

@ -488,9 +488,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows `impl Trait` to be used inside type aliases (RFC 2515).
(active, type_alias_impl_trait, "1.38.0", Some(63063), None),
/// Allows the use of or-patterns (e.g., `0 | 1`).
(active, or_patterns, "1.38.0", Some(54883), None),
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
(active, const_extern_fn, "1.40.0", Some(64926), None),

View file

@ -8,7 +8,7 @@
#![feature(extended_key_value_attributes)]
#![feature(in_band_lifetimes)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -1,4 +1,4 @@
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
use rustc_ast as ast;

View file

@ -20,7 +20,7 @@
#![feature(const_panic)]
#![feature(extend_one)]
#![feature(never_type)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(in_band_lifetimes)]
#![feature(control_flow_enum)]
#![recursion_limit = "512"] // For rustdoc

View file

@ -35,7 +35,7 @@
#![feature(iter_order_by)]
#![feature(never_type)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(half_open_range_patterns)]
#![feature(exclusive_range_pattern)]
#![feature(control_flow_enum)]

View file

@ -5,7 +5,7 @@
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(proc_macro_internals)]
#![feature(min_specialization)]
#![feature(stmt_expr_attributes)]

View file

@ -38,7 +38,7 @@
#![feature(extern_types)]
#![feature(nll)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(min_specialization)]
#![feature(trusted_len)]
#![feature(test)]

View file

@ -27,7 +27,7 @@
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(option_get_or_insert_default)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(once_cell)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]

View file

@ -10,7 +10,7 @@
#![feature(crate_visibility_modifier)]
#![feature(bool_to_option)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -3,7 +3,7 @@
#![feature(crate_visibility_modifier)]
#![feature(bindings_after_at)]
#![feature(iter_order_by)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![recursion_limit = "256"]

View file

@ -1,4 +1,4 @@
use super::pat::{GateOr, RecoverComma, PARAM_EXPECTED};
use super::pat::{RecoverComma, PARAM_EXPECTED};
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
use super::{AttrWrapper, BlockMode, ForceCollect, Parser, PathStyle, Restrictions, TokenType};
use super::{SemiColonMode, SeqSep, TokenExpectType, TrailingToken};
@ -1803,7 +1803,7 @@ fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> {
/// The `let` token has already been eaten.
fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
let lo = self.prev_token.span;
let pat = self.parse_pat_allow_top_alt(None, GateOr::No, RecoverComma::Yes)?;
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
self.expect(&token::Eq)?;
let expr = self.with_res(self.restrictions | Restrictions::NO_STRUCT_LITERAL, |this| {
this.parse_assoc_expr_with(1 + prec_let_scrutinee_needs_par(), None.into())
@ -1866,7 +1866,7 @@ fn parse_for_expr(
_ => None,
};
let pat = self.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::Yes)?;
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
if !self.eat_keyword(kw::In) {
self.error_missing_in_for_loop();
}
@ -2073,7 +2073,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
let attrs = self.parse_outer_attributes()?;
self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| {
let lo = this.token.span;
let pat = this.parse_pat_allow_top_alt(None, GateOr::No, RecoverComma::Yes)?;
let pat = this.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
let guard = if this.eat_keyword(kw::If) {
let if_span = this.prev_token.span;
let cond = this.parse_expr()?;

View file

@ -14,7 +14,7 @@
pub use attr_wrapper::AttrWrapper;
pub use diagnostics::AttemptLocalParseRecovery;
use diagnostics::Error;
pub use pat::{GateOr, RecoverComma};
pub use pat::RecoverComma;
pub use path::PathStyle;
use rustc_ast::ptr::P;

View file

@ -4,7 +4,7 @@
use rustc_errors::PResult;
use rustc_span::symbol::{kw, Ident};
use crate::parser::pat::{GateOr, RecoverComma};
use crate::parser::pat::RecoverComma;
use crate::parser::{FollowedByType, ForceCollect, Parser, PathStyle};
impl<'a> Parser<'a> {
@ -122,7 +122,7 @@ pub fn parse_nonterminal(&mut self, kind: NonterminalKind) -> PResult<'a, Nonter
token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
NonterminalKind::Pat2018 { .. } => this.parse_pat_no_top_alt(None),
NonterminalKind::Pat2021 { .. } => {
this.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)
this.parse_pat_allow_top_alt(None, RecoverComma::No)
}
_ => unreachable!(),
})?)

View file

@ -17,13 +17,6 @@
const WHILE_PARSING_OR_MSG: &str = "while parsing this or-pattern starting here";
/// Whether or not an or-pattern should be gated when occurring in the current context.
#[derive(PartialEq, Clone, Copy)]
pub enum GateOr {
Yes,
No,
}
/// Whether or not to recover a `,` when parsing or-patterns.
#[derive(PartialEq, Copy, Clone)]
pub enum RecoverComma {
@ -64,10 +57,9 @@ pub fn parse_pat_no_top_alt(&mut self, expected: Expected) -> PResult<'a, P<Pat>
pub fn parse_pat_allow_top_alt(
&mut self,
expected: Expected,
gate_or: GateOr,
rc: RecoverComma,
) -> PResult<'a, P<Pat>> {
self.parse_pat_allow_top_alt_inner(expected, gate_or, rc).map(|(pat, _)| pat)
self.parse_pat_allow_top_alt_inner(expected, rc).map(|(pat, _)| pat)
}
/// Returns the pattern and a bool indicating whether we recovered from a trailing vert (true =
@ -75,7 +67,6 @@ pub fn parse_pat_allow_top_alt(
fn parse_pat_allow_top_alt_inner(
&mut self,
expected: Expected,
gate_or: GateOr,
rc: RecoverComma,
) -> PResult<'a, (P<Pat>, bool)> {
// Keep track of whether we recovered from a trailing vert so that we can avoid duplicated
@ -90,7 +81,7 @@ fn parse_pat_allow_top_alt_inner(
// Parse the first pattern (`p_0`).
let first_pat = self.parse_pat_no_top_alt(expected)?;
self.maybe_recover_unexpected_comma(first_pat.span, rc, gate_or)?;
self.maybe_recover_unexpected_comma(first_pat.span, rc)?;
// If the next token is not a `|`,
// this is not an or-pattern and we should exit here.
@ -99,10 +90,6 @@ fn parse_pat_allow_top_alt_inner(
// then we should really gate the leading `|`.
// This complicated procedure is done purely for diagnostics UX.
if let Some(leading_vert_span) = leading_vert_span {
if gate_or == GateOr::Yes && self.sess.gated_spans.is_ungated(sym::or_patterns) {
self.sess.gated_spans.gate(sym::or_patterns, leading_vert_span);
}
// If there was a leading vert, treat this as an or-pattern. This improves
// diagnostics.
let span = leading_vert_span.to(self.prev_token.span);
@ -128,16 +115,11 @@ fn parse_pat_allow_top_alt_inner(
err.span_label(lo, WHILE_PARSING_OR_MSG);
err
})?;
self.maybe_recover_unexpected_comma(pat.span, rc, gate_or)?;
self.maybe_recover_unexpected_comma(pat.span, rc)?;
pats.push(pat);
}
let or_pattern_span = lo.to(self.prev_token.span);
// Feature gate the or-pattern if instructed:
if gate_or == GateOr::Yes {
self.sess.gated_spans.gate(sym::or_patterns, or_pattern_span);
}
Ok((self.mk_pat(or_pattern_span, PatKind::Or(pats)), trailing_vert))
}
@ -152,14 +134,13 @@ fn parse_pat_allow_top_alt_inner(
pub(super) fn parse_pat_before_ty(
&mut self,
expected: Expected,
gate_or: GateOr,
rc: RecoverComma,
syntax_loc: &str,
) -> PResult<'a, (P<Pat>, bool)> {
// We use `parse_pat_allow_top_alt` regardless of whether we actually want top-level
// or-patterns so that we can detect when a user tries to use it. This allows us to print a
// better error message.
let (pat, trailing_vert) = self.parse_pat_allow_top_alt_inner(expected, gate_or, rc)?;
let (pat, trailing_vert) = self.parse_pat_allow_top_alt_inner(expected, rc)?;
let colon = self.eat(&token::Colon);
if let PatKind::Or(pats) = &pat.kind {
@ -213,12 +194,7 @@ pub(super) fn parse_fn_param_pat_colon(&mut self) -> PResult<'a, (P<Pat>, bool)>
self.bump();
}
self.parse_pat_before_ty(
PARAM_EXPECTED,
GateOr::No,
RecoverComma::No,
"function parameters",
)
self.parse_pat_before_ty(PARAM_EXPECTED, RecoverComma::No, "function parameters")
}
/// Eat the or-pattern `|` separator.
@ -287,12 +263,7 @@ fn ban_unexpected_or_or(&mut self, lo: Option<Span>) {
/// Some special error handling for the "top-level" patterns in a match arm,
/// `for` loop, `let`, &c. (in contrast to subpatterns within such).
fn maybe_recover_unexpected_comma(
&mut self,
lo: Span,
rc: RecoverComma,
gate_or: GateOr,
) -> PResult<'a, ()> {
fn maybe_recover_unexpected_comma(&mut self, lo: Span, rc: RecoverComma) -> PResult<'a, ()> {
if rc == RecoverComma::No || self.token != token::Comma {
return Ok(());
}
@ -313,22 +284,18 @@ fn maybe_recover_unexpected_comma(
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
const MSG: &str = "try adding parentheses to match on a tuple...";
let or_suggestion =
gate_or == GateOr::No || !self.sess.gated_spans.is_ungated(sym::or_patterns);
err.span_suggestion(
seq_span,
if or_suggestion { MSG } else { MSG.trim_end_matches('.') },
MSG,
format!("({})", seq_snippet),
Applicability::MachineApplicable,
);
if or_suggestion {
err.span_suggestion(
seq_span,
"...or a vertical bar to match on multiple alternatives",
seq_snippet.replace(",", " |"),
Applicability::MachineApplicable,
);
}
err.span_suggestion(
seq_span,
"...or a vertical bar to match on multiple alternatives",
seq_snippet.replace(",", " |"),
Applicability::MachineApplicable,
);
}
Err(err)
}
@ -383,7 +350,7 @@ fn parse_pat_with_range_pat(
} else if self.check(&token::OpenDelim(token::Bracket)) {
// Parse `[pat, pat,...]` as a slice pattern.
let (pats, _) = self.parse_delim_comma_seq(token::Bracket, |p| {
p.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)
p.parse_pat_allow_top_alt(None, RecoverComma::No)
})?;
PatKind::Slice(pats)
} else if self.check(&token::DotDot) && !self.is_pat_range_end_start(1) {
@ -596,9 +563,8 @@ fn recover_lifetime_in_deref_pat(&mut self) {
/// Parse a tuple or parenthesis pattern.
fn parse_pat_tuple_or_parens(&mut self) -> PResult<'a, PatKind> {
let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| {
p.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)
})?;
let (fields, trailing_comma) =
self.parse_paren_comma_seq(|p| p.parse_pat_allow_top_alt(None, RecoverComma::No))?;
// Here, `(pat,)` is a tuple pattern.
// For backward compatibility, `(..)` is a tuple pattern as well.
@ -911,9 +877,8 @@ fn parse_pat_tuple_struct(&mut self, qself: Option<QSelf>, path: Path) -> PResul
if qself.is_some() {
return self.error_qpath_before_pat(&path, "(");
}
let (fields, _) = self.parse_paren_comma_seq(|p| {
p.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)
})?;
let (fields, _) =
self.parse_paren_comma_seq(|p| p.parse_pat_allow_top_alt(None, RecoverComma::No))?;
Ok(PatKind::TupleStruct(path, fields))
}
@ -1079,7 +1044,7 @@ fn parse_pat_field(&mut self, lo: Span, attrs: Vec<Attribute>) -> PResult<'a, Pa
// Parsing a pattern of the form `fieldname: pat`.
let fieldname = self.parse_field_name()?;
self.bump();
let pat = self.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)?;
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::No)?;
hi = pat.span;
(pat, fieldname, false)
} else {

View file

@ -1,7 +1,7 @@
use super::attr::DEFAULT_INNER_ATTR_FORBIDDEN;
use super::diagnostics::{AttemptLocalParseRecovery, Error};
use super::expr::LhsExpr;
use super::pat::{GateOr, RecoverComma};
use super::pat::RecoverComma;
use super::path::PathStyle;
use super::TrailingToken;
use super::{AttrWrapper, BlockMode, ForceCollect, Parser, Restrictions, SemiColonMode};
@ -221,8 +221,7 @@ fn recover_local_after_let(&mut self, lo: Span, attrs: AttrVec) -> PResult<'a, S
/// Parses a local variable declaration.
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
let lo = self.prev_token.span;
let (pat, colon) =
self.parse_pat_before_ty(None, GateOr::Yes, RecoverComma::Yes, "`let` bindings")?;
let (pat, colon) = self.parse_pat_before_ty(None, RecoverComma::Yes, "`let` bindings")?;
let (err, ty) = if colon {
// Save the state of the parser before parsing type normally, in case there is a `:`

View file

@ -10,7 +10,7 @@
test(attr(deny(warnings)))
)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(bool_to_option)]
pub use Alignment::*;

View file

@ -10,7 +10,7 @@
#![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -1,7 +1,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(control_flow_enum)]
#![feature(try_blocks)]
#![feature(associated_type_defaults)]

View file

@ -15,7 +15,7 @@
#![feature(crate_visibility_modifier)]
#![feature(format_args_capture)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
pub use rustc_hir::def::{Namespace, PerNS};

View file

@ -1,6 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
mod dump_visitor;

View file

@ -1,6 +1,6 @@
#![feature(crate_visibility_modifier)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -90,7 +90,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(never_type)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(in_band_lifetimes)]
#![recursion_limit = "256"]

View file

@ -17,7 +17,7 @@
#![feature(in_band_lifetimes)]
#![feature(never_type)]
#![feature(crate_visibility_modifier)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(control_flow_enum)]
#![recursion_limit = "512"] // For rustdoc

View file

@ -64,7 +64,7 @@
#![feature(in_band_lifetimes)]
#![feature(is_sorted)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(try_blocks)]
#![feature(never_type)]
#![feature(slice_partition_dedup)]

View file

@ -118,7 +118,7 @@
#![feature(nonnull_slice_from_raw_parts)]
#![feature(auto_traits)]
#![feature(option_result_unwrap_unchecked)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(pattern)]
#![feature(ptr_internals)]
#![feature(rustc_attrs)]

View file

@ -126,7 +126,7 @@
#![feature(exhaustive_patterns)]
#![feature(no_core)]
#![feature(auto_traits)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(prelude_import)]
#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
#![feature(repr_simd, platform_intrinsics)]

View file

@ -297,7 +297,7 @@
#![feature(nonnull_slice_from_raw_parts)]
#![feature(once_cell)]
#![feature(auto_traits)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(panic_info_message)]
#![feature(panic_internals)]
#![feature(panic_unwind)]

View file

@ -1,36 +0,0 @@
# `or_patterns`
The tracking issue for this feature is: [#54883]
[#54883]: https://github.com/rust-lang/rust/issues/54883
------------------------
The `or_pattern` language feature allows `|` to be arbitrarily nested within
a pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern.
## Examples
```rust,no_run
#![feature(or_patterns)]
pub enum Foo {
Bar,
Baz,
Quux,
}
pub fn example(maybe_foo: Option<Foo>) {
match maybe_foo {
Some(Foo::Bar | Foo::Baz) => {
println!("The value contained `Bar` or `Baz`");
}
Some(_) => {
println!("The value did not contain `Bar` or `Baz`");
}
None => {
println!("The value was `None`");
}
}
}
```

View file

@ -8,7 +8,7 @@
#![feature(box_syntax)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(or_patterns)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(test)]
#![feature(crate_visibility_modifier)]
#![feature(never_type)]

View file

@ -1,7 +1,5 @@
// Test that simple or-patterns don't get expanded to exponentially large CFGs
#![feature(or_patterns)]
// EMIT_MIR exponential_or.match_tuple.SimplifyCfg-initial.after.mir
fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 {
match x {

View file

@ -1,83 +1,83 @@
// MIR for `match_tuple` after SimplifyCfg-initial
fn match_tuple(_1: (u32, bool, Option<i32>, u32)) -> u32 {
debug x => _1; // in scope 0 at $DIR/exponential-or.rs:6:16: 6:17
let mut _0: u32; // return place in scope 0 at $DIR/exponential-or.rs:6:53: 6:56
let mut _2: isize; // in scope 0 at $DIR/exponential-or.rs:8:37: 8:48
let mut _3: bool; // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77
let mut _4: bool; // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77
let mut _5: bool; // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67
let mut _6: bool; // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67
let _7: u32; // in scope 0 at $DIR/exponential-or.rs:8:10: 8:21
let _8: u32; // in scope 0 at $DIR/exponential-or.rs:8:57: 8:78
let mut _9: u32; // in scope 0 at $DIR/exponential-or.rs:8:83: 8:84
let mut _10: u32; // in scope 0 at $DIR/exponential-or.rs:8:87: 8:88
debug x => _1; // in scope 0 at $DIR/exponential-or.rs:4:16: 4:17
let mut _0: u32; // return place in scope 0 at $DIR/exponential-or.rs:4:53: 4:56
let mut _2: isize; // in scope 0 at $DIR/exponential-or.rs:6:37: 6:48
let mut _3: bool; // in scope 0 at $DIR/exponential-or.rs:6:70: 6:77
let mut _4: bool; // in scope 0 at $DIR/exponential-or.rs:6:70: 6:77
let mut _5: bool; // in scope 0 at $DIR/exponential-or.rs:6:62: 6:67
let mut _6: bool; // in scope 0 at $DIR/exponential-or.rs:6:62: 6:67
let _7: u32; // in scope 0 at $DIR/exponential-or.rs:6:10: 6:21
let _8: u32; // in scope 0 at $DIR/exponential-or.rs:6:57: 6:78
let mut _9: u32; // in scope 0 at $DIR/exponential-or.rs:6:83: 6:84
let mut _10: u32; // in scope 0 at $DIR/exponential-or.rs:6:87: 6:88
scope 1 {
debug y => _7; // in scope 1 at $DIR/exponential-or.rs:8:10: 8:21
debug z => _8; // in scope 1 at $DIR/exponential-or.rs:8:57: 8:78
debug y => _7; // in scope 1 at $DIR/exponential-or.rs:6:10: 6:21
debug z => _8; // in scope 1 at $DIR/exponential-or.rs:6:57: 6:78
}
bb0: {
FakeRead(ForMatchedPlace, _1); // scope 0 at $DIR/exponential-or.rs:7:11: 7:12
switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:8:15: 8:16
FakeRead(ForMatchedPlace, _1); // scope 0 at $DIR/exponential-or.rs:5:11: 5:12
switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:6:15: 6:16
}
bb1: {
_0 = const 0_u32; // scope 0 at $DIR/exponential-or.rs:9:14: 9:15
goto -> bb10; // scope 0 at $DIR/exponential-or.rs:7:5: 10:6
_0 = const 0_u32; // scope 0 at $DIR/exponential-or.rs:7:14: 7:15
goto -> bb10; // scope 0 at $DIR/exponential-or.rs:5:5: 8:6
}
bb2: {
_2 = discriminant((_1.2: std::option::Option<i32>)); // scope 0 at $DIR/exponential-or.rs:8:37: 8:48
switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:8:37: 8:48
_2 = discriminant((_1.2: std::option::Option<i32>)); // scope 0 at $DIR/exponential-or.rs:6:37: 6:48
switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:6:37: 6:48
}
bb3: {
switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:8:42: 8:43
switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:6:42: 6:43
}
bb4: {
_5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:8:62: 8:67
switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential-or.rs:8:62: 8:67
_5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:6:62: 6:67
switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential-or.rs:6:62: 6:67
}
bb5: {
_6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential-or.rs:8:62: 8:67
switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:8:62: 8:67
_6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential-or.rs:6:62: 6:67
switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:6:62: 6:67
}
bb6: {
_3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:8:70: 8:77
switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential-or.rs:8:70: 8:77
_3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:6:70: 6:77
switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential-or.rs:6:70: 6:77
}
bb7: {
_4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential-or.rs:8:70: 8:77
switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:8:70: 8:77
_4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential-or.rs:6:70: 6:77
switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:6:70: 6:77
}
bb8: {
falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential-or.rs:8:9: 8:79
falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential-or.rs:6:9: 6:79
}
bb9: {
StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21
_7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21
StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78
_8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78
StorageLive(_9); // scope 1 at $DIR/exponential-or.rs:8:83: 8:84
_9 = _7; // scope 1 at $DIR/exponential-or.rs:8:83: 8:84
StorageLive(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88
_10 = _8; // scope 1 at $DIR/exponential-or.rs:8:87: 8:88
_0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:8:83: 8:88
StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88
StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88
StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88
StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88
goto -> bb10; // scope 0 at $DIR/exponential-or.rs:7:5: 10:6
StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:6:10: 6:21
_7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:6:10: 6:21
StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:6:57: 6:78
_8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:6:57: 6:78
StorageLive(_9); // scope 1 at $DIR/exponential-or.rs:6:83: 6:84
_9 = _7; // scope 1 at $DIR/exponential-or.rs:6:83: 6:84
StorageLive(_10); // scope 1 at $DIR/exponential-or.rs:6:87: 6:88
_10 = _8; // scope 1 at $DIR/exponential-or.rs:6:87: 6:88
_0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:6:83: 6:88
StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:6:87: 6:88
StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:6:87: 6:88
StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:6:87: 6:88
StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:6:87: 6:88
goto -> bb10; // scope 0 at $DIR/exponential-or.rs:5:5: 8:6
}
bb10: {
return; // scope 0 at $DIR/exponential-or.rs:11:2: 11:2
return; // scope 0 at $DIR/exponential-or.rs:9:2: 9:2
}
}

View file

@ -1,7 +1,6 @@
// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff
#![feature(const_fn_transmute)]
#![feature(or_patterns)]
use std::mem::transmute;

View file

@ -2,17 +2,17 @@
+ // MIR for `foo` after MatchBranchSimplification
fn foo(_1: [u8; 16]) -> Option<[u8; 4]> {
debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:8:12: 8:17
let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:8:32: 8:47
let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:10:9: 10:15
let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:10:47: 10:52
let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:13:14: 13:38
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:13:33: 13:35
debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:7:12: 7:17
let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:7:32: 7:47
let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:9:9: 9:15
let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:9:47: 9:52
let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:12:14: 12:38
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:12:33: 12:35
scope 1 {
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:10:9: 10:15
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:12:27: 12:29
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:9:9: 9:15
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:11:27: 11:29
scope 3 {
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:12:27: 12:29
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:11:27: 11:29
scope 4 {
}
}
@ -21,67 +21,67 @@
}
bb0: {
StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:10:9: 10:15
StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:10:47: 10:52
_3 = _1; // scope 2 at $DIR/issue-75439.rs:10:47: 10:52
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:10:37: 10:53
StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:9:9: 9:15
StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:9:47: 9:52
_3 = _1; // scope 2 at $DIR/issue-75439.rs:9:47: 9:52
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:9:37: 9:53
// mir::Constant
// + span: $DIR/issue-75439.rs:10:37: 10:46
// + span: $DIR/issue-75439.rs:9:37: 9:46
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {std::intrinsics::transmute::<[u8; 16], [u32; 4]>}, val: Value(Scalar(<ZST>)) }
}
bb1: {
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:10:52: 10:53
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:12:13: 12:14
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:9:52: 9:53
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:13: 11:14
}
bb2: {
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:12:16: 12:17
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:16: 11:17
}
bb3: {
switchInt(_2[2 of 4]) -> [0_u32: bb6, 4294901760_u32: bb7, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:12:19: 12:20
switchInt(_2[2 of 4]) -> [0_u32: bb6, 4294901760_u32: bb7, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:19: 11:20
}
bb4: {
discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:15:9: 15:13
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:12:5: 16:6
discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:14:9: 14:13
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
}
bb5: {
StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:13:14: 13:38
StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:13:33: 13:35
_6 = _4; // scope 4 at $DIR/issue-75439.rs:13:33: 13:35
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb8; // scope 4 at $DIR/issue-75439.rs:13:23: 13:36
StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:12:14: 12:38
StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:12:33: 12:35
_6 = _4; // scope 4 at $DIR/issue-75439.rs:12:33: 12:35
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb8; // scope 4 at $DIR/issue-75439.rs:12:23: 12:36
// mir::Constant
// + span: $DIR/issue-75439.rs:13:23: 13:32
// + span: $DIR/issue-75439.rs:12:23: 12:32
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {std::intrinsics::transmute::<u32, [u8; 4]>}, val: Value(Scalar(<ZST>)) }
}
bb6: {
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:12:27: 12:29
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:12:27: 12:29
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:12:5: 16:6
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
}
bb7: {
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:12:27: 12:29
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:12:27: 12:29
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:12:5: 16:6
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
}
bb8: {
StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:13:35: 13:36
((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:13:9: 13:39
discriminant(_0) = 1; // scope 3 at $DIR/issue-75439.rs:13:9: 13:39
StorageDead(_5); // scope 3 at $DIR/issue-75439.rs:13:38: 13:39
StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:14:5: 14:6
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:12:5: 16:6
StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:12:35: 12:36
((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:12:9: 12:39
discriminant(_0) = 1; // scope 3 at $DIR/issue-75439.rs:12:9: 12:39
StorageDead(_5); // scope 3 at $DIR/issue-75439.rs:12:38: 12:39
StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:13:5: 13:6
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
}
bb9: {
StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:17:1: 17:2
return; // scope 0 at $DIR/issue-75439.rs:17:2: 17:2
StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:16:1: 16:2
return; // scope 0 at $DIR/issue-75439.rs:16:2: 16:2
}
}

View file

@ -1,6 +1,5 @@
// Tests using a combination of pattern features has the expected borrow checking behavior
#![feature(bindings_after_at)]
#![feature(or_patterns)]
#![feature(box_patterns)]
enum Test {

View file

@ -1,5 +1,5 @@
error: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:38:9
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:37:9
|
LL | ref foo @ [.., ref mut bar] => (),
| -------^^^^^^^^-----------^
@ -8,7 +8,7 @@ LL | ref foo @ [.., ref mut bar] => (),
| immutable borrow, by `foo`, occurs here
error: cannot borrow value as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:122:9
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:121:9
|
LL | ref foo @ Some(box ref mut s) => (),
| -------^^^^^^^^^^^^---------^
@ -17,7 +17,7 @@ LL | ref foo @ Some(box ref mut s) => (),
| immutable borrow, by `foo`, occurs here
error[E0382]: borrow of moved value: `x`
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:20:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:19:5
|
LL | fn bindings_after_at_slice_patterns_move_binding(x: [String; 4]) {
| - move occurs because `x` has type `[String; 4]`, which does not implement the `Copy` trait
@ -29,7 +29,7 @@ LL | &x;
| ^^ value borrowed here after move
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:30:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:29:5
|
LL | ref mut foo @ [.., _] => Some(foo),
| --------------------- mutable borrow occurs here
@ -41,7 +41,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:52:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:51:5
|
LL | [ref foo @ .., ref bar] => Some(foo),
| ------------ immutable borrow occurs here
@ -53,7 +53,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:64:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:63:5
|
LL | ref foo @ [.., ref bar] => Some(foo),
| ----------------------- immutable borrow occurs here
@ -65,7 +65,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0382]: borrow of moved value: `x`
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:78:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:77:5
|
LL | fn bindings_after_at_or_patterns_move(x: Option<Test>) {
| - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait
@ -80,7 +80,7 @@ LL | &x;
| ^^ value borrowed here after move
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:88:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:87:5
|
LL | ref foo @ Some(Test::Foo | Test::Bar) => Some(foo),
| ------------------------------------- immutable borrow occurs here
@ -92,7 +92,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:100:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:99:5
|
LL | ref mut foo @ Some(Test::Foo | Test::Bar) => Some(foo),
| ----------------------------------------- mutable borrow occurs here
@ -104,7 +104,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:114:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:113:5
|
LL | ref foo @ Some(box ref s) => Some(foo),
| ------------------------- immutable borrow occurs here
@ -116,7 +116,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0382]: borrow of moved value: `x`
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:136:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:135:5
|
LL | fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4]) {
| - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait
@ -131,7 +131,7 @@ LL | &x;
| ^^ value borrowed here after move
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:146:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:145:5
|
LL | ref a @ [ref b @ .., Some(Test::Foo | Test::Bar)] => Some(a),
| ------------------------------------------------- immutable borrow occurs here
@ -143,7 +143,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:158:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:157:5
|
LL | ref a @ [ref b @ .., Some(Test::Foo | Test::Bar)] => Some(b),
| ---------- immutable borrow occurs here
@ -155,7 +155,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:172:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:171:5
|
LL | [_, ref a @ Some(box ref b), ..] => Some(a),
| ----------------------- immutable borrow occurs here
@ -167,7 +167,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:188:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:187:5
|
LL | [_, ref a @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
| ------------------------------------------- immutable borrow occurs here
@ -179,7 +179,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:202:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:201:5
|
LL | [_, ref mut a @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
| ----------------------------------------------- mutable borrow occurs here
@ -191,7 +191,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:216:5
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:215:5
|
LL | ref a @ [_, ref b @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
| ------------------------------------------------------------ immutable borrow occurs here

View file

@ -1,8 +1,6 @@
// Test that borrow check considers all choices in an or pattern, even the
// unreachable ones.
#![feature(or_patterns)]
fn or_pattern_moves_all(x: ((String, String),)) {
match x {
((y, _) | (_, y),) => (),

View file

@ -1,5 +1,5 @@
error[E0382]: borrow of moved value: `x.0.0`
--> $DIR/or-patterns.rs:10:5
--> $DIR/or-patterns.rs:8:5
|
LL | ((y, _) | (_, y),) => (),
| - value moved here
@ -10,7 +10,7 @@ LL | &x.0 .0;
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:12:5
--> $DIR/or-patterns.rs:10:5
|
LL | ((y, _) | (_, y),) => (),
| - value moved here
@ -21,7 +21,7 @@ LL | &x.0 .1;
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:20:5
--> $DIR/or-patterns.rs:18:5
|
LL | ((ref y, _) | (_, ref y),) => y,
| ----- immutable borrow occurs here
@ -33,7 +33,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x.0.1` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:22:5
--> $DIR/or-patterns.rs:20:5
|
LL | ((ref y, _) | (_, ref y),) => y,
| ----- immutable borrow occurs here
@ -45,7 +45,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x.0.0` as immutable because it is also borrowed as mutable
--> $DIR/or-patterns.rs:31:5
--> $DIR/or-patterns.rs:29:5
|
LL | ((ref mut y, _) | (_, ref mut y),) => y,
| --------- mutable borrow occurs here
@ -57,7 +57,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0502]: cannot borrow `x.0.1` as immutable because it is also borrowed as mutable
--> $DIR/or-patterns.rs:33:5
--> $DIR/or-patterns.rs:31:5
|
LL | ((ref mut y, _) | (_, ref mut y),) => y,
| --------- mutable borrow occurs here
@ -69,7 +69,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0382]: borrow of moved value: `x.0.0`
--> $DIR/or-patterns.rs:40:5
--> $DIR/or-patterns.rs:38:5
|
LL | let ((y, _) | (_, y),) = x;
| - value moved here
@ -79,7 +79,7 @@ LL | &x.0 .0;
= note: move occurs because `x.0.0` has type `String`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `x.0.1`
--> $DIR/or-patterns.rs:42:5
--> $DIR/or-patterns.rs:40:5
|
LL | let ((y, _) | (_, y),) = x;
| - value moved here
@ -90,7 +90,7 @@ LL | &x.0 .1;
= note: move occurs because `x.0.1` has type `String`, which does not implement the `Copy` trait
error[E0502]: cannot borrow `x.0.0` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:48:5
--> $DIR/or-patterns.rs:46:5
|
LL | let ((ref r, _) | (_, ref r),) = x;
| ----- immutable borrow occurs here
@ -101,7 +101,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x.0.1` as mutable because it is also borrowed as immutable
--> $DIR/or-patterns.rs:50:5
--> $DIR/or-patterns.rs:48:5
|
LL | let ((ref r, _) | (_, ref r),) = x;
| ----- immutable borrow occurs here
@ -113,7 +113,7 @@ LL | drop(r);
| - immutable borrow later used here
error[E0502]: cannot borrow `x.0.0` as immutable because it is also borrowed as mutable
--> $DIR/or-patterns.rs:57:5
--> $DIR/or-patterns.rs:55:5
|
LL | let ((ref mut r, _) | (_, ref mut r),) = x;
| --------- mutable borrow occurs here
@ -124,7 +124,7 @@ LL | drop(r);
| - mutable borrow later used here
error[E0502]: cannot borrow `x.0.1` as immutable because it is also borrowed as mutable
--> $DIR/or-patterns.rs:59:5
--> $DIR/or-patterns.rs:57:5
|
LL | let ((ref mut r, _) | (_, ref mut r),) = x;
| --------- mutable borrow occurs here

View file

@ -47,19 +47,46 @@ error: unexpected `,` in pattern
--> $DIR/issue-48492-tuple-destructure-missing-parens.rs:67:10
|
LL | for x, _barr_body in women.iter().map(|woman| woman.allosomes.clone()) {
| -^----------- help: try adding parentheses to match on a tuple: `(x, _barr_body)`
| ^
|
help: try adding parentheses to match on a tuple...
|
LL | for (x, _barr_body) in women.iter().map(|woman| woman.allosomes.clone()) {
| ^^^^^^^^^^^^^^^
help: ...or a vertical bar to match on multiple alternatives
|
LL | for x | _barr_body in women.iter().map(|woman| woman.allosomes.clone()) {
| ^^^^^^^^^^^^^^
error: unexpected `,` in pattern
--> $DIR/issue-48492-tuple-destructure-missing-parens.rs:75:10
|
LL | for x, y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) {
| -^------------------- help: try adding parentheses to match on a tuple: `(x, y @ Allosome::Y(_))`
| ^
|
help: try adding parentheses to match on a tuple...
|
LL | for (x, y @ Allosome::Y(_)) in men.iter().map(|man| man.allosomes.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^
help: ...or a vertical bar to match on multiple alternatives
|
LL | for x | y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^
error: unexpected `,` in pattern
--> $DIR/issue-48492-tuple-destructure-missing-parens.rs:84:14
|
LL | let women, men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
| -----^---- help: try adding parentheses to match on a tuple: `(women, men)`
| ^
|
help: try adding parentheses to match on a tuple...
|
LL | let (women, men): (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
| ^^^^^^^^^^^^
help: ...or a vertical bar to match on multiple alternatives
|
LL | let women | men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
| ^^^^^^^^^^^
error: aborting due to 6 previous errors

View file

@ -1,7 +1,6 @@
// run-rustfix
#![feature(box_patterns, stmt_expr_attributes)]
#![feature(or_patterns)]
#![allow(
dead_code,

View file

@ -1,7 +1,6 @@
// run-rustfix
#![feature(box_patterns, stmt_expr_attributes)]
#![feature(or_patterns)]
#![allow(
dead_code,

View file

@ -1,149 +1,149 @@
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:17:9
--> $DIR/issue-54538-unused-parens-lint.rs:16:9
|
LL | let (a) = 0;
| ^^^ help: remove these parentheses
|
note: the lint level is defined here
--> $DIR/issue-54538-unused-parens-lint.rs:14:9
--> $DIR/issue-54538-unused-parens-lint.rs:13:9
|
LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:18:9
--> $DIR/issue-54538-unused-parens-lint.rs:17:9
|
LL | for (a) in 0..1 {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:19:12
--> $DIR/issue-54538-unused-parens-lint.rs:18:12
|
LL | if let (a) = 0 {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:20:15
--> $DIR/issue-54538-unused-parens-lint.rs:19:15
|
LL | while let (a) = 0 {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:21:12
--> $DIR/issue-54538-unused-parens-lint.rs:20:12
|
LL | fn foo((a): u8) {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:22:14
--> $DIR/issue-54538-unused-parens-lint.rs:21:14
|
LL | let _ = |(a): u8| 0;
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:50:12
--> $DIR/issue-54538-unused-parens-lint.rs:49:12
|
LL | if let (0 | 1) = 0 {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:51:13
--> $DIR/issue-54538-unused-parens-lint.rs:50:13
|
LL | if let ((0 | 1),) = (0,) {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:52:13
--> $DIR/issue-54538-unused-parens-lint.rs:51:13
|
LL | if let [(0 | 1)] = [0] {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:53:16
--> $DIR/issue-54538-unused-parens-lint.rs:52:16
|
LL | if let 0 | (1 | 2) = 0 {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:55:15
--> $DIR/issue-54538-unused-parens-lint.rs:54:15
|
LL | if let TS((0 | 1)) = TS(0) {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:57:20
--> $DIR/issue-54538-unused-parens-lint.rs:56:20
|
LL | if let NS { f: (0 | 1) } = (NS { f: 0 }) {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:67:9
--> $DIR/issue-54538-unused-parens-lint.rs:66:9
|
LL | (_) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:67:9
|
LL | (y) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:68:9
|
LL | (y) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:69:9
|
LL | (ref r) => {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:70:9
--> $DIR/issue-54538-unused-parens-lint.rs:69:9
|
LL | (e @ 1...2) => {}
| ^^^^^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:76:9
--> $DIR/issue-54538-unused-parens-lint.rs:75:9
|
LL | (e @ &(1...2)) => {}
| ^^^^^^^^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:77:10
--> $DIR/issue-54538-unused-parens-lint.rs:76:10
|
LL | &(_) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:88:9
--> $DIR/issue-54538-unused-parens-lint.rs:87:9
|
LL | (_) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:89:9
--> $DIR/issue-54538-unused-parens-lint.rs:88:9
|
LL | (y) => {}
| ^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:90:9
--> $DIR/issue-54538-unused-parens-lint.rs:89:9
|
LL | (ref r) => {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:91:9
--> $DIR/issue-54538-unused-parens-lint.rs:90:9
|
LL | (e @ 1..=2) => {}
| ^^^^^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:97:9
--> $DIR/issue-54538-unused-parens-lint.rs:96:9
|
LL | (e @ &(1..=2)) => {}
| ^^^^^^^^^^^^^^ help: remove these parentheses
error: unnecessary parentheses around pattern
--> $DIR/issue-54538-unused-parens-lint.rs:98:10
--> $DIR/issue-54538-unused-parens-lint.rs:97:10
|
LL | &(_) => {}
| ^^^ help: remove these parentheses

View file

@ -1,7 +1,6 @@
// FIXME: should be run-rustfix, but rustfix doesn't currently support multipart suggestions, see
// #53934
#![feature(or_patterns)]
#![deny(unused)]
pub enum MyEnum {

View file

@ -1,11 +1,11 @@
error: unused variable: `j`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:21:16
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:20:16
|
LL | A { i, j } | B { i, j } => {
| ^ ^
|
note: the lint level is defined here
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:5:9
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:4:9
|
LL | #![deny(unused)]
| ^^^^^^
@ -16,7 +16,7 @@ LL | A { i, j: _ } | B { i, j: _ } => {
| ^^^^ ^^^^
error: unused variable: `j`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:31:16
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:30:16
|
LL | A { i, ref j } | B { i, ref j } => {
| ^^^^^ ^^^^^
@ -27,7 +27,7 @@ LL | A { i, j: _ } | B { i, j: _ } => {
| ^^^^ ^^^^
error: unused variable: `j`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:41:21
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:40:21
|
LL | Some(A { i, j } | B { i, j }) => {
| ^ ^
@ -38,7 +38,7 @@ LL | Some(A { i, j: _ } | B { i, j: _ }) => {
| ^^^^ ^^^^
error: unused variable: `j`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:53:21
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:52:21
|
LL | Some(A { i, ref j } | B { i, ref j }) => {
| ^^^^^ ^^^^^
@ -49,7 +49,7 @@ LL | Some(A { i, j: _ } | B { i, j: _ }) => {
| ^^^^ ^^^^
error: unused variable: `i`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:63:24
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:62:24
|
LL | MixedEnum::A { i } | MixedEnum::B(i) => {
| ^ ^
@ -60,7 +60,7 @@ LL | MixedEnum::A { i: _ } | MixedEnum::B(_) => {
| ^^^^ ^
error: unused variable: `i`
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:71:24
--> $DIR/issue-67691-unused-field-in-or-pattern.rs:70:24
|
LL | MixedEnum::A { ref i } | MixedEnum::B(ref i) => {
| ^^^^^ ^^^^^

View file

@ -1,6 +1,5 @@
// run-pass
#![feature(or_patterns)]
#![feature(edition_macro_pats)]
macro_rules! foo {

View file

@ -1,7 +1,5 @@
// run-pass
#![feature(or_patterns)]
fn main() {
assert!(f("", 0));
assert!(f("a", 1));

View file

@ -1,8 +1,6 @@
// This test ensures that the "already bound identifier in a product pattern"
// correctly accounts for or-patterns.
#![feature(or_patterns)]
enum E<T> { A(T, T), B(T) }
use E::*;

View file

@ -1,89 +1,89 @@
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:11:13
--> $DIR/already-bound-name.rs:9:13
|
LL | let (a, a) = (0, 1); // Standard duplication without an or-pattern.
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:14:15
--> $DIR/already-bound-name.rs:12:15
|
LL | let (a, A(a, _) | B(a)) = (0, A(1, 2));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:14:25
--> $DIR/already-bound-name.rs:12:25
|
LL | let (a, A(a, _) | B(a)) = (0, A(1, 2));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:18:26
--> $DIR/already-bound-name.rs:16:26
|
LL | let (A(a, _) | B(a), a) = (A(0, 1), 2);
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:21:15
--> $DIR/already-bound-name.rs:19:15
|
LL | let (A(a, a) | B(a)) = A(0, 1);
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:24:22
--> $DIR/already-bound-name.rs:22:22
|
LL | let (B(a) | A(a, a)) = A(0, 1);
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:28:21
--> $DIR/already-bound-name.rs:26:21
|
LL | B(a) | A(a, a) => {} // Let's ensure `match` has no funny business.
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:32:37
--> $DIR/already-bound-name.rs:30:37
|
LL | let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:32:47
--> $DIR/already-bound-name.rs:30:47
|
LL | let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:37:37
--> $DIR/already-bound-name.rs:35:37
|
LL | let (B(_) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:37:47
--> $DIR/already-bound-name.rs:35:47
|
LL | let (B(_) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/already-bound-name.rs:37:10
--> $DIR/already-bound-name.rs:35:10
|
LL | let (B(_) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
| ^^^^ pattern doesn't bind `a` - variable not in all patterns
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:42:50
--> $DIR/already-bound-name.rs:40:50
|
LL | let (B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:42:60
--> $DIR/already-bound-name.rs:40:60
|
LL | let (B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
| ^ used in a pattern more than once
error[E0308]: mismatched types
--> $DIR/already-bound-name.rs:32:32
--> $DIR/already-bound-name.rs:30:32
|
LL | let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
| - ^ ------- this expression has type `E<E<{integer}>>`

View file

@ -3,8 +3,6 @@
// run-pass
#![feature(or_patterns)]
#[derive(Debug)]
enum Test {
Foo,

View file

@ -3,8 +3,6 @@
// run-pass
#![feature(or_patterns)]
#[derive(Debug, PartialEq)]
enum MatchArm {
Arm(usize),

View file

@ -1,7 +1,5 @@
// run-pass
#![feature(or_patterns)]
fn two_bindings(x: &((bool, bool), u8)) -> u8 {
match x {
&((true, y) | (y, true), z @ (0 | 4)) => (y as u8) + z,

View file

@ -1,7 +1,5 @@
// run-pass
#![feature(or_patterns)]
fn or_at(x: Result<u32, u32>) -> u32 {
match x {
Ok(x @ 4) | Err(x @ (6 | 8)) => x,

View file

@ -2,7 +2,6 @@
// run-pass
#![feature(or_patterns)]
#![feature(box_patterns)]
#[derive(Debug, PartialEq)]

View file

@ -4,8 +4,6 @@
// check-pass
#![feature(or_patterns)]
fn main() {
// One level:
let (Ok(a) | Err(a)) = Ok(0);

View file

@ -1,5 +1,4 @@
// check-pass
#![feature(or_patterns)]
const fn foo((Ok(a) | Err(a)): Result<i32, i32>) {
let x = Ok(3);

View file

@ -1,4 +1,3 @@
#![feature(or_patterns)]
#![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns were special-cased.

View file

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `(2_u8..=u8::MAX, _)` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:6:11
--> $DIR/exhaustiveness-non-exhaustive.rs:5:11
|
LL | match (0u8, 0u8) {
| ^^^^^^^^^^ pattern `(2_u8..=u8::MAX, _)` not covered
@ -8,7 +8,7 @@ LL | match (0u8, 0u8) {
= note: the matched value is of type `(u8, u8)`
error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:10:11
--> $DIR/exhaustiveness-non-exhaustive.rs:9:11
|
LL | match ((0u8,),) {
| ^^^^^^^^^ pattern `((4_u8..=u8::MAX))` not covered
@ -17,7 +17,7 @@ LL | match ((0u8,),) {
= note: the matched value is of type `((u8,),)`
error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:14:11
--> $DIR/exhaustiveness-non-exhaustive.rs:13:11
|
LL | match (Some(0u8),) {
| ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX))` not covered

View file

@ -1,4 +1,3 @@
#![feature(or_patterns)]
#![deny(unreachable_patterns)]
// check-pass

View file

@ -1,4 +1,3 @@
#![feature(or_patterns)]
#![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns were special-cased.

View file

@ -1,138 +1,138 @@
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:8:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:7:9
|
LL | (1,) => {}
| ^^^^
|
note: the lint level is defined here
--> $DIR/exhaustiveness-unreachable-pattern.rs:2:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:1:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:13:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:12:9
|
LL | (2,) => {}
| ^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:19:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:18:9
|
LL | (1 | 2,) => {}
| ^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:23:9
|
LL | (1, 3) => {}
| ^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
|
LL | (1, 4) => {}
| ^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
|
LL | (2, 4) => {}
| ^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:27:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
|
LL | (2 | 1, 4) => {}
| ^^^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:29:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:28:9
|
LL | (1, 4 | 5) => {}
| ^^^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:36:9
|
LL | (Some(1),) => {}
| ^^^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:38:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
|
LL | (None,) => {}
| ^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:43:9
--> $DIR/exhaustiveness-unreachable-pattern.rs:42:9
|
LL | ((1..=4,),) => {}
| ^^^^^^^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:48:14
--> $DIR/exhaustiveness-unreachable-pattern.rs:47:14
|
LL | (1 | 1,) => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:52:19
--> $DIR/exhaustiveness-unreachable-pattern.rs:51:19
|
LL | (0 | 1) | 1 => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:58:14
--> $DIR/exhaustiveness-unreachable-pattern.rs:57:14
|
LL | 0 | (0 | 0) => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:58:18
--> $DIR/exhaustiveness-unreachable-pattern.rs:57:18
|
LL | 0 | (0 | 0) => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:66:13
--> $DIR/exhaustiveness-unreachable-pattern.rs:65:13
|
LL | / Some(
LL | | 0 | 0) => {}
| |______________________^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:72:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:71:15
|
LL | | 0
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:74:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:73:15
|
LL | | 0] => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:82:10
--> $DIR/exhaustiveness-unreachable-pattern.rs:81:10
|
LL | [1
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:94:10
--> $DIR/exhaustiveness-unreachable-pattern.rs:93:10
|
LL | [true
| ^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:101:36
--> $DIR/exhaustiveness-unreachable-pattern.rs:100:36
|
LL | (true | false, None | Some(true
| ^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:106:14
--> $DIR/exhaustiveness-unreachable-pattern.rs:105:14
|
LL | (true
| ^^^^
@ -143,25 +143,25 @@ LL | (true | false, None | Some(t_or_f!())) => {}
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:117:14
--> $DIR/exhaustiveness-unreachable-pattern.rs:116:14
|
LL | Some(0
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:136:19
--> $DIR/exhaustiveness-unreachable-pattern.rs:135:19
|
LL | | false) => {}
| ^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:144:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:143:15
|
LL | | true) => {}
| ^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:150:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:149:15
|
LL | | true,
| ^^^^

View file

@ -1,8 +0,0 @@
// Test feature gating for a sole leading `|` in `let`.
fn main() {}
#[cfg(FALSE)]
fn gated_leading_vert_in_let() {
for | A in 0 {} //~ ERROR or-patterns syntax is experimental
}

View file

@ -1,12 +0,0 @@
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns-leading-for.rs:7:9
|
LL | for | A in 0 {}
| ^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,9 +0,0 @@
// Test feature gating for a sole leading `|` in `let`.
fn main() {}
#[cfg(FALSE)]
fn gated_leading_vert_in_let() {
let | A; //~ ERROR or-patterns syntax is experimental
//~^ ERROR top-level or-patterns are not allowed
}

View file

@ -1,18 +0,0 @@
error: top-level or-patterns are not allowed in `let` bindings
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:9
|
LL | let | A;
| ^^^ help: remove the `|`: `A`
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:9
|
LL | let | A;
| ^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,54 +0,0 @@
fn main() {}
pub fn example(x: Option<usize>) {
match x {
Some(0 | 1 | 2) => {}
//~^ ERROR: or-patterns syntax is experimental
_ => {}
}
}
// Test the `pat` macro fragment parser:
macro_rules! accept_pat {
($p:pat) => {}
}
accept_pat!((p | q)); //~ ERROR or-patterns syntax is experimental
accept_pat!((p | q,)); //~ ERROR or-patterns syntax is experimental
accept_pat!(TS(p | q)); //~ ERROR or-patterns syntax is experimental
accept_pat!(NS { f: p | q }); //~ ERROR or-patterns syntax is experimental
accept_pat!([p | q]); //~ ERROR or-patterns syntax is experimental
// Non-macro tests:
#[cfg(FALSE)]
fn or_patterns() {
// Gated:
let | A | B; //~ ERROR or-patterns syntax is experimental
//~^ ERROR top-level or-patterns are not allowed
let A | B; //~ ERROR or-patterns syntax is experimental
//~^ ERROR top-level or-patterns are not allowed
for | A | B in 0 {} //~ ERROR or-patterns syntax is experimental
for A | B in 0 {} //~ ERROR or-patterns syntax is experimental
fn fun((A | B): _) {} //~ ERROR or-patterns syntax is experimental
let _ = |(A | B): u8| (); //~ ERROR or-patterns syntax is experimental
let (A | B); //~ ERROR or-patterns syntax is experimental
let (A | B,); //~ ERROR or-patterns syntax is experimental
let A(B | C); //~ ERROR or-patterns syntax is experimental
let E::V(B | C); //~ ERROR or-patterns syntax is experimental
let S { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
let E::V { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
let [A | B]; //~ ERROR or-patterns syntax is experimental
// Top level of `while`, `if`, and `match` arms are allowed:
while let | A = 0 {}
while let A | B = 0 {}
if let | A = 0 {}
if let A | B = 0 {}
match 0 {
| A => {},
A | B => {},
}
}

View file

@ -1,186 +0,0 @@
error: top-level or-patterns are not allowed in `let` bindings
--> $DIR/feature-gate-or_patterns.rs:28:9
|
LL | let | A | B;
| ^^^^^^^ help: wrap the pattern in parentheses: `(A | B)`
error: top-level or-patterns are not allowed in `let` bindings
--> $DIR/feature-gate-or_patterns.rs:30:9
|
LL | let A | B;
| ^^^^^ help: wrap the pattern in parentheses: `(A | B)`
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:5:14
|
LL | Some(0 | 1 | 2) => {}
| ^^^^^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:28:9
|
LL | let | A | B;
| ^^^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:30:9
|
LL | let A | B;
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:32:9
|
LL | for | A | B in 0 {}
| ^^^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:33:9
|
LL | for A | B in 0 {}
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:34:13
|
LL | fn fun((A | B): _) {}
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:35:15
|
LL | let _ = |(A | B): u8| ();
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:36:10
|
LL | let (A | B);
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:37:10
|
LL | let (A | B,);
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:38:11
|
LL | let A(B | C);
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:39:14
|
LL | let E::V(B | C);
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:40:17
|
LL | let S { f1: B | C, f2 };
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:41:20
|
LL | let E::V { f1: B | C, f2 };
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:42:10
|
LL | let [A | B];
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:16:14
|
LL | accept_pat!((p | q));
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:17:14
|
LL | accept_pat!((p | q,));
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:18:16
|
LL | accept_pat!(TS(p | q));
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:19:21
|
LL | accept_pat!(NS { f: p | q });
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error[E0658]: or-patterns syntax is experimental
--> $DIR/feature-gate-or_patterns.rs:20:14
|
LL | accept_pat!([p | q]);
| ^^^^^
|
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
error: aborting due to 21 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -2,7 +2,6 @@
// run-rustfix
#![feature(or_patterns)]
#![allow(warnings)]
fn main() {}

View file

@ -2,7 +2,6 @@
// run-rustfix
#![feature(or_patterns)]
#![allow(warnings)]
fn main() {}

View file

@ -1,5 +1,5 @@
error: top-level or-patterns are not allowed in function parameters
--> $DIR/fn-param-wrap-parens.rs:14:9
--> $DIR/fn-param-wrap-parens.rs:13:9
|
LL | fn fun1(A | B: E) {}
| ^^^^^ help: wrap the pattern in parentheses: `(A | B)`

View file

@ -1,8 +1,6 @@
// Check that or patterns are lowered correctly in `for` loops.
// run-pass
#![feature(or_patterns)]
fn main() {
let v = vec![Ok(2), Err(3), Ok(5)];
let mut w = Vec::new();

View file

@ -1,8 +1,6 @@
// Check that or patterns are lowered correctly in `if let` and `while let` expressions.
// run-pass
#![feature(or_patterns)]
fn main() {
let mut opt = Some(3);
let mut w = Vec::new();

View file

@ -1,6 +1,5 @@
// This test ensures that or patterns require binding mode consistency across arms.
#![feature(or_patterns)]
#![allow(non_camel_case_types)]
fn main() {
// One level:

View file

@ -1,5 +1,5 @@
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:7:26
--> $DIR/inconsistent-modes.rs:6:26
|
LL | let (Ok(a) | Err(ref a)): Result<&u8, u8> = Ok(&0);
| - ^ bound in different ways
@ -7,7 +7,7 @@ LL | let (Ok(a) | Err(ref a)): Result<&u8, u8> = Ok(&0);
| first binding
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:9:30
--> $DIR/inconsistent-modes.rs:8:30
|
LL | let (Ok(ref mut a) | Err(a)): Result<u8, &mut u8> = Ok(0);
| - ^ bound in different ways
@ -15,25 +15,25 @@ LL | let (Ok(ref mut a) | Err(a)): Result<u8, &mut u8> = Ok(0);
| first binding
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:11:34
--> $DIR/inconsistent-modes.rs:10:34
|
LL | let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
| - first binding ^ bound in different ways
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:14:40
--> $DIR/inconsistent-modes.rs:13:40
|
LL | let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
| - first binding ^ bound in different ways
error[E0409]: variable `b` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:14:47
--> $DIR/inconsistent-modes.rs:13:47
|
LL | let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
| - first binding ^ bound in different ways
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:20:39
--> $DIR/inconsistent-modes.rs:19:39
|
LL | let (Ok(Ok(a) | Err(a)) | Err(ref a)) = Err(0);
| - ^ bound in different ways
@ -41,7 +41,7 @@ LL | let (Ok(Ok(a) | Err(a)) | Err(ref a)) = Err(0);
| first binding
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:24:34
--> $DIR/inconsistent-modes.rs:23:34
|
LL | let (Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a)) = Err(&1);
| - ^ bound in different ways
@ -49,7 +49,7 @@ LL | let (Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a)) = Err(&1);
| first binding
error[E0308]: mismatched types
--> $DIR/inconsistent-modes.rs:11:26
--> $DIR/inconsistent-modes.rs:10:26
|
LL | let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
| ----- ^^^^^^^^^ -------------------- expected due to this
@ -62,7 +62,7 @@ LL | let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/inconsistent-modes.rs:14:32
--> $DIR/inconsistent-modes.rs:13:32
|
LL | let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
| ----- ^^^^^^^^^ ----------- this expression has type `Result<({integer}, &{integer}), (_, _)>`

View file

@ -2,8 +2,6 @@
// check-pass
#![feature(or_patterns)]
fn foo((Some(_) | None): Option<u32>) {}
fn main() {

View file

@ -1,7 +1,5 @@
// check-pass
#![feature(or_patterns)]
enum MyEnum {
FirstCase(u8),
OtherCase(u16),

View file

@ -1,5 +1,3 @@
#![feature(or_patterns)]
fn main() {
let (0 | (1 | 2)) = 0; //~ ERROR refutable pattern in local binding
match 0 {

View file

@ -1,5 +1,5 @@
error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered
--> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:4:10
--> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:2:10
|
LL | let (0 | (1 | 2)) = 0;
| ^^^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered
@ -13,7 +13,7 @@ LL | if let (0 | (1 | 2)) = 0 { /* */ }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered
--> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:5:11
--> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:3:11
|
LL | match 0 {
| ^ patterns `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered

View file

@ -1,7 +1,5 @@
// check-pass
#![feature(or_patterns)]
fn main() {
let (0 | (1 | _)) = 0;
if let 0 | (1 | 2) = 0 {}

View file

@ -2,7 +2,6 @@
#![deny(unreachable_patterns)]
#![feature(or_patterns)]
fn main() {
match (3,42) {
(a,_) | (_,a) if a > 10 => {println!("{}", a)}

View file

@ -1,5 +1,3 @@
#![feature(or_patterns)]
// run-pass
fn or_pat_let(x: Result<u32, u32>) -> u32 {

View file

@ -3,8 +3,6 @@
// ignore-test
// FIXME(mark-i-m): enable this test again when 2021 machinery is available
#![feature(or_patterns)]
use Foo::*;
#[derive(Eq, PartialEq, Debug)]

View file

@ -1,8 +1,6 @@
// Regression test for #71297
// edition:2018
#![feature(or_patterns)]
async fn a((x | s): String) {}
//~^ ERROR variable `x` is not bound in all patterns
//~| ERROR variable `s` is not bound in all patterns

View file

@ -1,5 +1,5 @@
error[E0408]: variable `s` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:6:13
--> $DIR/mismatched-bindings-async-fn.rs:4:13
|
LL | async fn a((x | s): String) {}
| ^ - variable not in all patterns
@ -7,7 +7,7 @@ LL | async fn a((x | s): String) {}
| pattern doesn't bind `s`
error[E0408]: variable `x` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:6:17
--> $DIR/mismatched-bindings-async-fn.rs:4:17
|
LL | async fn a((x | s): String) {}
| - ^ pattern doesn't bind `x`
@ -15,7 +15,7 @@ LL | async fn a((x | s): String) {}
| variable not in all patterns
error[E0408]: variable `s` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:11:10
--> $DIR/mismatched-bindings-async-fn.rs:9:10
|
LL | let (x | s) = String::new();
| ^ - variable not in all patterns
@ -23,7 +23,7 @@ LL | let (x | s) = String::new();
| pattern doesn't bind `s`
error[E0408]: variable `x` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:11:14
--> $DIR/mismatched-bindings-async-fn.rs:9:14
|
LL | let (x | s) = String::new();
| - ^ pattern doesn't bind `x`

View file

@ -2,7 +2,6 @@
// edition:2018
#![feature(or_patterns)]
#![allow(non_camel_case_types)]
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0408]: variable `beta` is not bound in all patterns
--> $DIR/missing-bindings.rs:20:10
--> $DIR/missing-bindings.rs:19:10
|
LL | let (alpha | beta | charlie) = alpha;
| ^^^^^ ---- ^^^^^^^ pattern doesn't bind `beta`
@ -8,7 +8,7 @@ LL | let (alpha | beta | charlie) = alpha;
| pattern doesn't bind `beta`
error[E0408]: variable `beta` is not bound in all patterns
--> $DIR/missing-bindings.rs:22:14
--> $DIR/missing-bindings.rs:21:14
|
LL | Some(alpha | beta) => {}
| ^^^^^ ---- variable not in all patterns
@ -16,7 +16,7 @@ LL | Some(alpha | beta) => {}
| pattern doesn't bind `beta`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:34:20
--> $DIR/missing-bindings.rs:33:20
|
LL | let (A(a, _) | _) = X;
| - ^ pattern doesn't bind `a`
@ -24,7 +24,7 @@ LL | let (A(a, _) | _) = X;
| variable not in all patterns
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:35:10
--> $DIR/missing-bindings.rs:34:10
|
LL | let (_ | B(a)) = X;
| ^ - variable not in all patterns
@ -32,7 +32,7 @@ LL | let (_ | B(a)) = X;
| pattern doesn't bind `a`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:36:10
--> $DIR/missing-bindings.rs:35:10
|
LL | let (A(..) | B(a)) = X;
| ^^^^^ - variable not in all patterns
@ -40,7 +40,7 @@ LL | let (A(..) | B(a)) = X;
| pattern doesn't bind `a`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:37:20
--> $DIR/missing-bindings.rs:36:20
|
LL | let (A(a, _) | B(_)) = X;
| - ^^^^ pattern doesn't bind `a`
@ -48,7 +48,7 @@ LL | let (A(a, _) | B(_)) = X;
| variable not in all patterns
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:38:20
--> $DIR/missing-bindings.rs:37:20
|
LL | let (A(_, a) | B(_)) = X;
| - ^^^^ pattern doesn't bind `a`
@ -56,7 +56,7 @@ LL | let (A(_, a) | B(_)) = X;
| variable not in all patterns
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:39:20
--> $DIR/missing-bindings.rs:38:20
|
LL | let (A(a, b) | B(a)) = X;
| - ^^^^ pattern doesn't bind `b`
@ -64,7 +64,7 @@ LL | let (A(a, b) | B(a)) = X;
| variable not in all patterns
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:43:10
--> $DIR/missing-bindings.rs:42:10
|
LL | let (A(A(..) | B(_), _) | B(a)) = Y;
| ^^^^^^^^^^^^^^^^^^ - variable not in all patterns
@ -72,7 +72,7 @@ LL | let (A(A(..) | B(_), _) | B(a)) = Y;
| pattern doesn't bind `a`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:44:12
--> $DIR/missing-bindings.rs:43:12
|
LL | let (A(A(..) | B(a), _) | B(A(a, _) | B(a))) = Y;
| ^^^^^ - variable not in all patterns
@ -80,7 +80,7 @@ LL | let (A(A(..) | B(a), _) | B(A(a, _) | B(a))) = Y;
| pattern doesn't bind `a`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:22
--> $DIR/missing-bindings.rs:45:22
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `a`
@ -88,7 +88,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:22
--> $DIR/missing-bindings.rs:45:22
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `b`
@ -96,7 +96,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `c` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:12
--> $DIR/missing-bindings.rs:45:12
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| ^^^^^^^ - variable not in all patterns
@ -104,7 +104,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| pattern doesn't bind `c`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:33
--> $DIR/missing-bindings.rs:45:33
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `a`
@ -112,7 +112,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:33
--> $DIR/missing-bindings.rs:45:33
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `b`
@ -120,7 +120,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `c` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:33
--> $DIR/missing-bindings.rs:45:33
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `c`
@ -128,7 +128,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `d` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:33
--> $DIR/missing-bindings.rs:45:33
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| - ^^^^ pattern doesn't bind `d`
@ -136,7 +136,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| variable not in all patterns
error[E0408]: variable `e` is not bound in all patterns
--> $DIR/missing-bindings.rs:46:10
--> $DIR/missing-bindings.rs:45:10
|
LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns
@ -144,7 +144,7 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y;
| pattern doesn't bind `e`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:62:29
--> $DIR/missing-bindings.rs:61:29
|
LL | Ok(a) | Err(_),
| - ^^^^^^ pattern doesn't bind `a`
@ -152,7 +152,7 @@ LL | Ok(a) | Err(_),
| variable not in all patterns
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:70:21
--> $DIR/missing-bindings.rs:69:21
|
LL | A(_, a) |
| - variable not in all patterns
@ -160,7 +160,7 @@ LL | B(b),
| ^^^^ pattern doesn't bind `a`
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:69:21
--> $DIR/missing-bindings.rs:68:21
|
LL | A(_, a) |
| ^^^^^^^ pattern doesn't bind `b`
@ -168,7 +168,7 @@ LL | B(b),
| - variable not in all patterns
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:73:17
--> $DIR/missing-bindings.rs:72:17
|
LL | A(_, a) |
| - variable not in all patterns
@ -177,7 +177,7 @@ LL | B(_)
| ^^^^ pattern doesn't bind `a`
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:73:17
--> $DIR/missing-bindings.rs:72:17
|
LL | B(b),
| - variable not in all patterns
@ -186,7 +186,7 @@ LL | B(_)
| ^^^^ pattern doesn't bind `b`
error[E0408]: variable `a` is not bound in all patterns
--> $DIR/missing-bindings.rs:77:13
--> $DIR/missing-bindings.rs:76:13
|
LL | B(Ok(a) | Err(a))
| - variable not in all patterns
@ -198,7 +198,7 @@ LL | V3(c),
| ^^^^^ pattern doesn't bind `a`
error[E0408]: variable `b` is not bound in all patterns
--> $DIR/missing-bindings.rs:58:13
--> $DIR/missing-bindings.rs:57:13
|
LL | / V1(
LL | |
@ -216,7 +216,7 @@ LL | V3(c),
| ^^^^^ pattern doesn't bind `b`
error[E0408]: variable `c` is not bound in all patterns
--> $DIR/missing-bindings.rs:58:13
--> $DIR/missing-bindings.rs:57:13
|
LL | / V1(
LL | |

View file

@ -4,7 +4,6 @@
// 2) or-patterns should work with simplifyable patterns.
// run-pass
#![feature(or_patterns)]
pub fn test(x: Option<usize>) -> bool {
match x {

View file

@ -1,4 +1,4 @@
#![feature(or_patterns)]
//! Test for `||` in or-patterns
fn main() {
let x = 3;

View file

@ -1,8 +1,6 @@
// Here we test type checking of bindings when combined with or-patterns.
// Specifically, we ensure that introducing bindings of different types result in type errors.
#![feature(or_patterns)]
fn main() {
enum Blah {
A(isize, isize, usize),

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:13:39
--> $DIR/or-patterns-binding-type-mismatch.rs:11:39
|
LL | match Blah::A(1, 1, 2) {
| ---------------- this expression has type `Blah`
@ -11,7 +11,7 @@ LL | Blah::A(_, x, y) | Blah::B(x, y) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:17:44
--> $DIR/or-patterns-binding-type-mismatch.rs:15:44
|
LL | match Some(Blah::A(1, 1, 2)) {
| ---------------------- this expression has type `Option<Blah>`
@ -23,7 +23,7 @@ LL | Some(Blah::A(_, x, y) | Blah::B(x, y)) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:21:19
--> $DIR/or-patterns-binding-type-mismatch.rs:19:19
|
LL | match (0u8, 1u16) {
| ----------- this expression has type `(u8, u16)`
@ -35,7 +35,7 @@ LL | (x, y) | (y, x) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:21:22
--> $DIR/or-patterns-binding-type-mismatch.rs:19:22
|
LL | match (0u8, 1u16) {
| ----------- this expression has type `(u8, u16)`
@ -47,7 +47,7 @@ LL | (x, y) | (y, x) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:26:41
--> $DIR/or-patterns-binding-type-mismatch.rs:24:41
|
LL | match Some((0u8, Some((1u16, 2u32)))) {
| ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>`
@ -59,7 +59,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:26:50
--> $DIR/or-patterns-binding-type-mismatch.rs:24:50
|
LL | match Some((0u8, Some((1u16, 2u32)))) {
| ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>`
@ -71,7 +71,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:26:59
--> $DIR/or-patterns-binding-type-mismatch.rs:24:59
|
LL | match Some((0u8, Some((1u16, 2u32)))) {
| ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>`
@ -83,7 +83,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:26:62
--> $DIR/or-patterns-binding-type-mismatch.rs:24:62
|
LL | match Some((0u8, Some((1u16, 2u32)))) {
| ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>`
@ -93,7 +93,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
= note: in the same arm, a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:34:42
--> $DIR/or-patterns-binding-type-mismatch.rs:32:42
|
LL | if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) {
| - ^ ---------------- this expression has type `Blah`
@ -104,7 +104,7 @@ LL | if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) {
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:38:47
--> $DIR/or-patterns-binding-type-mismatch.rs:36:47
|
LL | if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) {
| - ^ ---------------------- this expression has type `Option<Blah>`
@ -115,7 +115,7 @@ LL | if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2))
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:42:22
--> $DIR/or-patterns-binding-type-mismatch.rs:40:22
|
LL | if let (x, y) | (y, x) = (0u8, 1u16) {
| - ^ ----------- this expression has type `(u8, u16)`
@ -126,7 +126,7 @@ LL | if let (x, y) | (y, x) = (0u8, 1u16) {
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:42:25
--> $DIR/or-patterns-binding-type-mismatch.rs:40:25
|
LL | if let (x, y) | (y, x) = (0u8, 1u16) {
| - ^ ----------- this expression has type `(u8, u16)`
@ -137,7 +137,7 @@ LL | if let (x, y) | (y, x) = (0u8, 1u16) {
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:47:44
--> $DIR/or-patterns-binding-type-mismatch.rs:45:44
|
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
| - ^ expected `u16`, found `u8`
@ -150,7 +150,7 @@ LL | = Some((0u8, Some((1u16, 2u32))))
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:47:53
--> $DIR/or-patterns-binding-type-mismatch.rs:45:53
|
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
| - ^ expected `u8`, found `u16`
@ -163,7 +163,7 @@ LL | = Some((0u8, Some((1u16, 2u32))))
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:47:62
--> $DIR/or-patterns-binding-type-mismatch.rs:45:62
|
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
| - ^ expected `u32`, found `u16`
@ -176,7 +176,7 @@ LL | = Some((0u8, Some((1u16, 2u32))))
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:47:65
--> $DIR/or-patterns-binding-type-mismatch.rs:45:65
|
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
| - first introduced with type `u8` here ^ expected `u8`, found `u32`
@ -187,7 +187,7 @@ LL | = Some((0u8, Some((1u16, 2u32))))
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:55:40
--> $DIR/or-patterns-binding-type-mismatch.rs:53:40
|
LL | let (Blah::A(_, x, y) | Blah::B(x, y)) = Blah::A(1, 1, 2);
| - ^ ---------------- this expression has type `Blah`
@ -198,7 +198,7 @@ LL | let (Blah::A(_, x, y) | Blah::B(x, y)) = Blah::A(1, 1, 2);
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:58:20
--> $DIR/or-patterns-binding-type-mismatch.rs:56:20
|
LL | let ((x, y) | (y, x)) = (0u8, 1u16);
| - ^ ----------- this expression has type `(u8, u16)`
@ -209,7 +209,7 @@ LL | let ((x, y) | (y, x)) = (0u8, 1u16);
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:58:23
--> $DIR/or-patterns-binding-type-mismatch.rs:56:23
|
LL | let ((x, y) | (y, x)) = (0u8, 1u16);
| - ^ ----------- this expression has type `(u8, u16)`
@ -220,7 +220,7 @@ LL | let ((x, y) | (y, x)) = (0u8, 1u16);
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:62:42
--> $DIR/or-patterns-binding-type-mismatch.rs:60:42
|
LL | fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {}
| - ^ ---- expected due to this
@ -231,7 +231,7 @@ LL | fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {}
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:65:22
--> $DIR/or-patterns-binding-type-mismatch.rs:63:22
|
LL | fn f2(((x, y) | (y, x)): (u8, u16)) {}
| - ^ --------- expected due to this
@ -242,7 +242,7 @@ LL | fn f2(((x, y) | (y, x)): (u8, u16)) {}
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
--> $DIR/or-patterns-binding-type-mismatch.rs:65:25
--> $DIR/or-patterns-binding-type-mismatch.rs:63:25
|
LL | fn f2(((x, y) | (y, x)): (u8, u16)) {}
| - ^ --------- expected due to this

Some files were not shown because too many files have changed in this diff Show more