From 1a9e1762e264e14f90cb5b60c439fd2b8dbae9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 4 Nov 2026 23:05:20 +0100 Subject: [PATCH 1/3] Don't blindly say that a macro call doesn't expand to a certain fragment Just because the parser of a specific syntax fragment kind returns an `Err(_)` doesn't automatically mean that the problematic token sequence isn't "of" that fragment's kind. The token sequence might "almost" be of that kind (i.e., share a non-empty prefix) but simply contain a syntax error in it. On a side note, it's rather odd that the now removed `annotate_err_with_kind` only added the note "this macro call doesn't expand to a $fragkind" if the target fragment kind was *type* or *pat*, there are 20 kinds at the of writing. --- compiler/rustc_expand/src/expand.rs | 2 -- compiler/rustc_expand/src/mbe/diagnostics.rs | 16 ++-------------- .../early/macro_rules-braces.stderr | 4 ++-- .../min_const_generics/macro-fail-const.stderr | 10 ++-------- .../min_const_generics/macro-fail.stderr | 15 +++------------ .../derives/debug/nonsense-input-to-debug.stderr | 1 - .../field_representing_types/invalid.next.stderr | 15 +++------------ .../field_representing_types/invalid.old.stderr | 15 +++------------ tests/ui/macros/macro-interpolation.stderr | 5 +---- tests/ui/proc-macro/lifetimes.stderr | 5 +---- 10 files changed, 17 insertions(+), 71 deletions(-) diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index b9c1bb9545d2f..933d702150285 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -41,7 +41,6 @@ use crate::diagnostics::{ GlobDelegationTraitlessQpath, IncompleteParse, RecursionLimitReached, RemoveExprNotSupported, UnsupportedKeyValue, WrongFragmentKind, }; -use crate::mbe::diagnostics::annotate_err_with_kind; use crate::module::{ DirOwnership, ParsedExternalMod, mod_dir_path, mod_file_path_from_attr, parse_external_mod, }; @@ -1067,7 +1066,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { if err.span.is_dummy() { err.span(span); } - annotate_err_with_kind(&mut err, kind, span); let guar = err.emit_err(); self.cx.macro_error_and_trace_macros_diag(); kind.dummy(span, guar) diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index c724857d572ec..281f55f8ec090 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -434,8 +434,8 @@ pub(super) fn emit_frag_parse_err( } } }, - _ => annotate_err_with_kind(&mut e, kind, site_span), - }; + _ => {} + } if parser.token.kind == token::Dollar { let dollar_span = parser.token.span; @@ -504,18 +504,6 @@ pub(super) fn emit_frag_parse_err( e.emit_err() } -pub(crate) fn annotate_err_with_kind(err: &mut Diag<'_>, kind: AstFragmentKind, span: Span) { - match kind { - AstFragmentKind::Ty => { - err.span_label(span, "this macro call doesn't expand to a type"); - } - AstFragmentKind::Pat => { - err.span_label(span, "this macro call doesn't expand to a pattern"); - } - _ => {} - }; -} - #[derive(Subdiagnostic)] enum ExplainDocComment { #[label( diff --git a/tests/ui/const-generics/early/macro_rules-braces.stderr b/tests/ui/const-generics/early/macro_rules-braces.stderr index 6cc9a67f194b7..98e905d71c04b 100644 --- a/tests/ui/const-generics/early/macro_rules-braces.stderr +++ b/tests/ui/const-generics/early/macro_rules-braces.stderr @@ -2,7 +2,7 @@ error: expressions must be enclosed in braces to be used as const generic argume --> $DIR/macro_rules-braces.rs:44:17 | LL | let _: baz!(m::P); - | -----^^^^- this macro call doesn't expand to a type + | ^^^^ | help: enclose the `const` expression in braces | @@ -13,7 +13,7 @@ error: expressions must be enclosed in braces to be used as const generic argume --> $DIR/macro_rules-braces.rs:64:17 | LL | let _: baz!(10 + 7); - | -----^^^^^^- this macro call doesn't expand to a type + | ^^^^^^ | help: enclose the `const` expression in braces | diff --git a/tests/ui/const-generics/min_const_generics/macro-fail-const.stderr b/tests/ui/const-generics/min_const_generics/macro-fail-const.stderr index 2fa529c750d10..2688675f3aa43 100644 --- a/tests/ui/const-generics/min_const_generics/macro-fail-const.stderr +++ b/tests/ui/const-generics/min_const_generics/macro-fail-const.stderr @@ -2,10 +2,7 @@ error: expected type, found `{` --> $DIR/macro-fail-const.rs:16:27 | LL | fn make_marker() -> impl Marker { - | ---------------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ---------------------- in this macro invocation ... LL | macro_rules! gimme_a_const { LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} @@ -15,10 +12,7 @@ error: expected type, found `{` --> $DIR/macro-fail-const.rs:16:27 | LL | Example:: - | ---------------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ---------------------- in this macro invocation ... LL | macro_rules! gimme_a_const { LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} diff --git a/tests/ui/const-generics/min_const_generics/macro-fail.stderr b/tests/ui/const-generics/min_const_generics/macro-fail.stderr index 23eeec7f6daa0..c190ceb40a82d 100644 --- a/tests/ui/const-generics/min_const_generics/macro-fail.stderr +++ b/tests/ui/const-generics/min_const_generics/macro-fail.stderr @@ -2,10 +2,7 @@ error: expected type, found `{` --> $DIR/macro-fail.rs:27:27 | LL | fn make_marker() -> impl Marker { - | ---------------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ---------------------- in this macro invocation ... LL | macro_rules! gimme_a_const { LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} @@ -15,10 +12,7 @@ error: expected type, found `{` --> $DIR/macro-fail.rs:27:27 | LL | Example:: - | ---------------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ---------------------- in this macro invocation ... LL | macro_rules! gimme_a_const { LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} @@ -32,10 +26,7 @@ LL | () => {{ | ^ expected type ... LL | let _fail = Example::; - | ----------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ----------------- in this macro invocation error: unexpected end of macro invocation --> $DIR/macro-fail.rs:36:25 diff --git a/tests/ui/derives/debug/nonsense-input-to-debug.stderr b/tests/ui/derives/debug/nonsense-input-to-debug.stderr index 207d7b1969de5..ee35d5e624856 100644 --- a/tests/ui/derives/debug/nonsense-input-to-debug.stderr +++ b/tests/ui/derives/debug/nonsense-input-to-debug.stderr @@ -12,7 +12,6 @@ LL | should_be_vec_t: vec![T], | | | expected type | in this macro invocation - | this macro call doesn't expand to a type error[E0392]: type parameter `T` is never used --> $DIR/nonsense-input-to-debug.rs:5:17 diff --git a/tests/ui/field_representing_types/invalid.next.stderr b/tests/ui/field_representing_types/invalid.next.stderr index 82b2aa81451ab..3d6775fe8b376 100644 --- a/tests/ui/field_representing_types/invalid.next.stderr +++ b/tests/ui/field_representing_types/invalid.next.stderr @@ -37,10 +37,7 @@ error: `field_of` expects dot-separated field and variant names --> $DIR/invalid.rs:28:12 | LL | let _: field_of!(Enum, Variant..field); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation error: offset_of expects dot-separated field and variant names --> $DIR/invalid.rs:30:30 @@ -52,19 +49,13 @@ error: `field_of` expects dot-separated field and variant names --> $DIR/invalid.rs:30:12 | LL | let _: field_of!(Struct, [42]); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation error: `field_of` only supports a single field or a variant with a field --> $DIR/invalid.rs:32:30 | LL | let _: field_of!(Struct, field1.field2.field3); - | ------------------^^^^^^-^^^^^^-^^^^^^- - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ------------------^^^^^^-^^^^^^-^^^^^^- in this macro invocation error: aborting due to 8 previous errors diff --git a/tests/ui/field_representing_types/invalid.old.stderr b/tests/ui/field_representing_types/invalid.old.stderr index 82b2aa81451ab..3d6775fe8b376 100644 --- a/tests/ui/field_representing_types/invalid.old.stderr +++ b/tests/ui/field_representing_types/invalid.old.stderr @@ -37,10 +37,7 @@ error: `field_of` expects dot-separated field and variant names --> $DIR/invalid.rs:28:12 | LL | let _: field_of!(Enum, Variant..field); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation error: offset_of expects dot-separated field and variant names --> $DIR/invalid.rs:30:30 @@ -52,19 +49,13 @@ error: `field_of` expects dot-separated field and variant names --> $DIR/invalid.rs:30:12 | LL | let _: field_of!(Struct, [42]); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation error: `field_of` only supports a single field or a variant with a field --> $DIR/invalid.rs:32:30 | LL | let _: field_of!(Struct, field1.field2.field3); - | ------------------^^^^^^-^^^^^^-^^^^^^- - | | - | in this macro invocation - | this macro call doesn't expand to a type + | ------------------^^^^^^-^^^^^^-^^^^^^- in this macro invocation error: aborting due to 8 previous errors diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr index 3dc6ef6132d2a..304e7311e2d4e 100644 --- a/tests/ui/macros/macro-interpolation.stderr +++ b/tests/ui/macros/macro-interpolation.stderr @@ -7,10 +7,7 @@ LL | <$type as $trait>::$name | ^^^^^^ expected identifier, found metavariable ... LL | let _: qpath!(ty, ::Owned); - | ----------------------------- - | | - | this macro call doesn't expand to a type - | in this macro invocation + | ----------------------------- in this macro invocation error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/lifetimes.stderr b/tests/ui/proc-macro/lifetimes.stderr index 315b4c5917243..aa5ef8559ced3 100644 --- a/tests/ui/proc-macro/lifetimes.stderr +++ b/tests/ui/proc-macro/lifetimes.stderr @@ -2,10 +2,7 @@ error: expected type, found `'` --> $DIR/lifetimes.rs:7:10 | LL | type A = single_quote_alone!(); - | ^^^^^^^^^^^^^^^^^^^^^ - | | - | expected type - | this macro call doesn't expand to a type + | ^^^^^^^^^^^^^^^^^^^^^ expected type | = note: this error originates in the macro `single_quote_alone` (in Nightly builds, run with -Z macro-backtrace for more info) From a7c41c15cf36bd3303727272b649404a6476be4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Thu, 3 Sep 2026 18:00:16 +0200 Subject: [PATCH 2/3] Turn `pattern_type` into a macro 2.0 that expands to `k#pattern_type(..)` This also means that it's now available under `core::pat` instead of `core` directly. This makes it consistent with the `std` re-export which is only available under `std::pat` and not under `std` directly. Moreover, drop library feature `pattern_type_macro` and demote language feature `pattern_types` to a library feature. This is nice because it means `std::pat::pattern_type` is no longer unnecessarily gated behind two (!) feature gates. --- compiler/rustc_ast_passes/src/feature_gate.rs | 3 - compiler/rustc_builtin_macros/src/lib.rs | 2 - .../rustc_builtin_macros/src/pattern_type.rs | 75 ------------------- .../example/mini_core.rs | 12 ++- .../example/mini_core_hello_world.rs | 10 +-- .../build_system/src/test.rs | 2 + .../rustc_codegen_gcc/example/mini_core.rs | 28 ++++--- compiler/rustc_data_structures/src/lib.rs | 2 +- compiler/rustc_feature/src/unstable.rs | 2 - compiler/rustc_index_macros/src/lib.rs | 2 +- compiler/rustc_parse/src/parser/ty.rs | 56 +++++++++++++- compiler/rustc_span/src/symbol.rs | 2 +- library/core/src/lib.rs | 5 +- library/core/src/num/niche_types.rs | 3 +- library/core/src/pat.rs | 12 ++- library/core/src/prelude/v1.rs | 4 +- library/core/src/ptr/non_null.rs | 2 +- library/std/src/lib.rs | 2 +- library/std/src/pat.rs | 2 +- .../clippy/tests/ui/eager_transmute.fixed | 2 +- src/tools/clippy/tests/ui/eager_transmute.rs | 2 +- src/tools/miri/tests/fail/validity/nonzero.rs | 2 +- src/tools/miri/tests/pass/pattern-types.rs | 2 +- tests/auxiliary/minicore.rs | 12 ++- tests/codegen-llvm/enum/enum-aggregate.rs | 2 +- tests/codegen-llvm/pattern_type_symbols.rs | 3 +- tests/debuginfo/msvc-pretty-enums.rs | 6 +- tests/mir-opt/dataflow-const-prop/enum.rs | 2 +- tests/mir-opt/gvn.rs | 2 +- tests/mir-opt/jump_threading.rs | 2 +- tests/mir-opt/pattern_types.rs | 1 - .../pattern-types-implementors.rs | 2 +- tests/ui/consts/const-eval/raw-bytes.rs | 2 +- tests/ui/consts/const-eval/ub-ref-ptr.rs | 2 +- tests/ui/enum-discriminant/ptr_niche.rs | 2 +- tests/ui/lint/clashing-extern-fn.rs | 2 +- tests/ui/lint/invalid_value.rs | 2 +- tests/ui/mir/ssa-analysis-regression-50041.rs | 2 +- tests/ui/pattern/overflowing-literals.rs | 1 - tests/ui/pattern/overflowing-literals.stderr | 8 +- tests/ui/print_type_sizes/niche-filling.rs | 2 +- .../pattern_types/assoc_const.default.stderr | 8 +- tests/ui/type/pattern_types/assoc_const.rs | 2 - tests/ui/type/pattern_types/bad_pat.rs | 3 +- tests/ui/type/pattern_types/bad_pat.stderr | 16 ++-- tests/ui/type/pattern_types/chars.rs | 1 - tests/ui/type/pattern_types/const_generics.rs | 2 +- tests/ui/type/pattern_types/derives.rs | 3 +- tests/ui/type/pattern_types/derives.stderr | 2 +- tests/ui/type/pattern_types/derives_fail.rs | 3 +- .../ui/type/pattern_types/derives_fail.stderr | 12 +-- ...eature-gate-pattern_types.disabled.stderr} | 32 ++++---- ...feature-gate-pattern_types.enabled.stderr} | 2 +- .../feature-gate-pattern_types.rs | 14 ++-- .../feature-gate-pattern_types2.rs | 12 --- tests/ui/type/pattern_types/free_const.rs | 1 - tests/ui/type/pattern_types/literals.rs | 1 - tests/ui/type/pattern_types/literals.stderr | 40 +++++----- tests/ui/type/pattern_types/matching.rs | 2 +- tests/ui/type/pattern_types/matching_fail.rs | 2 +- tests/ui/type/pattern_types/missing-is.rs | 2 +- tests/ui/type/pattern_types/nested.rs | 1 - tests/ui/type/pattern_types/nested.stderr | 26 +++---- tests/ui/type/pattern_types/non_null.rs | 2 +- tests/ui/type/pattern_types/or_patterns.rs | 8 +- .../ui/type/pattern_types/or_patterns.stderr | 16 ++-- .../type/pattern_types/or_patterns_invalid.rs | 10 +-- .../pattern_types/or_patterns_invalid.stderr | 8 +- .../pattern_types/pattern_type_mismatch.rs | 1 - .../pattern_type_mismatch.stderr | 8 +- tests/ui/type/pattern_types/range_patterns.rs | 2 - .../type/pattern_types/range_patterns.stderr | 24 +++--- .../range_patterns_inherent_impls.rs | 2 - .../range_patterns_inherent_impls.stderr | 4 +- .../range_patterns_trait_impls.rs | 2 - .../range_patterns_trait_impls2.rs | 2 - .../range_patterns_trait_impls2.stderr | 2 +- .../pattern_types/range_patterns_unusable.rs | 2 - .../range_patterns_unusable.stderr | 2 +- .../range_patterns_unusable_math.rs | 2 - .../range_patterns_unusable_math.stderr | 2 +- .../pattern_types/range_patterns_usage.rs | 2 - tests/ui/type/pattern_types/reverse_range.rs | 1 - .../type/pattern_types/reverse_range.stderr | 2 +- tests/ui/type/pattern_types/signed_ranges.rs | 1 - .../type/pattern_types/signed_ranges.stderr | 8 +- tests/ui/type/pattern_types/transmute.rs | 2 +- .../type/pattern_types/unimplemented_pat.rs | 2 +- tests/ui/type/pattern_types/unsize.rs | 2 +- tests/ui/type/pattern_types/validity.rs | 1 - tests/ui/type/pattern_types/validity.stderr | 16 ++-- tests/ui/unpretty/exhaustive.expanded.stdout | 3 +- tests/ui/unpretty/exhaustive.hir.stderr | 40 +++++----- tests/ui/unpretty/exhaustive.hir.stdout | 5 +- tests/ui/unpretty/exhaustive.rs | 3 +- 95 files changed, 281 insertions(+), 382 deletions(-) delete mode 100644 compiler/rustc_builtin_macros/src/pattern_type.rs rename tests/ui/type/pattern_types/{feature-gate-pattern_types.stderr => feature-gate-pattern_types.disabled.stderr} (64%) rename tests/ui/type/pattern_types/{feature-gate-pattern_types2.stderr => feature-gate-pattern_types.enabled.stderr} (81%) delete mode 100644 tests/ui/type/pattern_types/feature-gate-pattern_types2.rs diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 862d4736ca33c..02adcc2296610 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -241,9 +241,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Function pointers cannot be `const` self.check_late_bound_lifetime_defs(&fn_ptr_ty.generic_params); } - ast::TyKind::Pat(..) => { - gate!(self, pattern_types, ty.span, "pattern types are unstable"); - } ast::TyKind::View(..) => { gate!(self, view_types, ty.span, "view types are unstable"); } diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index aaaf67e34af4e..f801dc5917d8a 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -45,7 +45,6 @@ mod global_allocator; mod iter; mod log_syntax; mod offload; -mod pattern_type; mod rustdoc_skip_body; mod source_util; mod test; @@ -100,7 +99,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { module_path: source_util::expand_mod, naked_asm: asm::expand_naked_asm, option_env: env::expand_option_env, - pattern_type: pattern_type::expand, std_panic: edition_panic::expand_panic, stringify: source_util::expand_stringify, test_binder_constraints: test_binder_constraints::expand, diff --git a/compiler/rustc_builtin_macros/src/pattern_type.rs b/compiler/rustc_builtin_macros/src/pattern_type.rs deleted file mode 100644 index 4d34ba963e4e8..0000000000000 --- a/compiler/rustc_builtin_macros/src/pattern_type.rs +++ /dev/null @@ -1,75 +0,0 @@ -use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast, token}; -use rustc_errors::PResult; -use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; -use rustc_parse::exp; -use rustc_parse::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; -use rustc_span::Span; - -pub(crate) fn expand<'cx>( - cx: &'cx mut ExtCtxt<'_>, - sp: Span, - tts: TokenStream, -) -> MacroExpanderResult<'cx> { - let (ty, pat) = match parse_pat_ty(cx, tts) { - Ok(parsed) => parsed, - Err(err) => { - return ExpandResult::Ready(DummyResult::any(sp, err.emit_err())); - } - }; - - ExpandResult::Ready(base::MacEager::ty(cx.ty(sp, ast::TyKind::Pat(ty, pat)))) -} - -fn parse_pat_ty<'a>( - cx: &mut ExtCtxt<'a>, - stream: TokenStream, -) -> PResult<'a, (Box, Box)> { - let mut parser = cx.new_parser_from_tts(stream); - - let ty = parser.parse_ty()?; - parser.expect_keyword(exp!(Is))?; - - let start = parser.token.span; - let pat = if parser.eat(exp!(Bang)) { - parser.expect_keyword(exp!(Null))?; - ty_pat(TyPatKind::NotNull, start.to(parser.token.span)) - } else { - pat_to_ty_pat( - cx, - parser.parse_pat_no_top_guard( - None, - RecoverComma::No, - RecoverColon::No, - CommaRecoveryMode::EitherTupleOrPipe, - )?, - ) - }; - - if parser.token != token::Eof { - parser.unexpected()?; - } - - Ok((ty, Box::new(pat))) -} - -fn ty_pat(kind: TyPatKind, span: Span) -> TyPat { - TyPat { id: DUMMY_NODE_ID, kind, span } -} - -fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> TyPat { - let kind = match pat.kind { - ast::PatKind::Range(start, end, include_end) => TyPatKind::Range( - start.map(|value| Box::new(AnonConst { id: DUMMY_NODE_ID, value })), - end.map(|value| Box::new(AnonConst { id: DUMMY_NODE_ID, value })), - include_end, - ), - ast::PatKind::Or(variants) => { - TyPatKind::Or(variants.into_iter().map(|pat| pat_to_ty_pat(cx, pat)).collect()) - } - ast::PatKind::Err(guar) => TyPatKind::Err(guar), - ast::PatKind::Paren(p) => pat_to_ty_pat(cx, *p).kind, - _ => TyPatKind::Err(cx.dcx().span_err(pat.span, "pattern not supported in pattern types")), - }; - ty_pat(kind, pat.span) -} diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index d6d82a9d2af69..3c9f6bdddc129 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -6,9 +6,10 @@ extern_types, decl_macro, rustc_attrs, + allow_internal_unstable, + forced_keywords, rustc_private, transparent_unions, - pattern_types, auto_traits, freeze_impls )] @@ -591,12 +592,9 @@ pub trait Deref { fn deref(&self) -> &Self::Target; } -#[rustc_builtin_macro(pattern_type)] -#[macro_export] -macro_rules! pattern_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +pub macro pattern_type($($arg:tt)*) { + k#pattern_type($($arg)*) } impl CoerceUnsized for pattern_type!(*const T is !null) where diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index c53ec2ec6710d..2db42f3bd5930 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -1,12 +1,4 @@ -#![feature( - no_core, - lang_items, - extern_types, - thread_local, - repr_simd, - pattern_types, - rustc_private -)] +#![feature(no_core, lang_items, extern_types, thread_local, repr_simd, rustc_private)] #![cfg_attr(not(any(jit, target_vendor = "apple", windows)), feature(linkage))] #![no_core] #![allow(dead_code, non_camel_case_types, internal_features)] diff --git a/compiler/rustc_codegen_gcc/build_system/src/test.rs b/compiler/rustc_codegen_gcc/build_system/src/test.rs index 79eae8afa1468..ed4cfca14f250 100644 --- a/compiler/rustc_codegen_gcc/build_system/src/test.rs +++ b/compiler/rustc_codegen_gcc/build_system/src/test.rs @@ -255,6 +255,8 @@ fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> { &"mini_core", &"--crate-type", &crate_types, + &"--edition", + &"2024", &"--target", &args.config_info.target_triple, ]); diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 383fbfc678922..e5e8f6042e4a2 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -6,10 +6,11 @@ extern_types, decl_macro, rustc_attrs, + allow_internal_unstable, + forced_keywords, transparent_unions, auto_traits, freeze_impls, - pattern_types, thread_local, rustc_private )] @@ -40,9 +41,9 @@ unsafe extern "C" { type VTable; } -#[no_mangle] +#[unsafe(no_mangle)] unsafe extern "C" fn _Unwind_Resume() { - intrinsics::unreachable(); + unsafe { intrinsics::unreachable(); } } #[lang = "pointee_sized"] @@ -607,12 +608,9 @@ impl Allocator for Global {} #[rustc_nonnull_optimization_guaranteed] pub struct NonNull(pub pattern_type!(*const T is !null)); -#[rustc_builtin_macro(pattern_type)] -#[macro_export] -macro_rules! pattern_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +pub macro pattern_type($($arg:tt)*) { + k#pattern_type($($arg)*) } impl CoerceUnsized for pattern_type!(*const T is !null) where @@ -703,11 +701,11 @@ pub mod intrinsics { #[rustc_intrinsic] pub const fn size_of() -> usize; #[rustc_intrinsic] - pub unsafe fn size_of_val(val: *const T) -> usize; + pub unsafe fn size_of_val(val: *const T) -> usize; #[rustc_intrinsic] pub const fn align_of() -> usize; #[rustc_intrinsic] - pub unsafe fn align_of_val(val: *const T) -> usize; + pub unsafe fn align_of_val(val: *const T) -> usize; #[rustc_intrinsic] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize); #[rustc_intrinsic] @@ -715,7 +713,7 @@ pub mod intrinsics { #[rustc_intrinsic] pub unsafe fn ctlz_nonzero(x: T) -> u32; #[rustc_intrinsic] - pub const fn needs_drop() -> bool; + pub const fn needs_drop() -> bool; #[rustc_intrinsic] pub fn bitreverse(x: T) -> T; #[rustc_intrinsic] @@ -728,7 +726,7 @@ pub mod intrinsics { pub mod libc { #[link(name = "c")] - extern "C" { + unsafe extern "C" { pub fn puts(s: *const u8) -> i32; pub fn printf(format: *const i8, ...) -> i32; pub fn malloc(size: usize) -> *mut u8; @@ -783,7 +781,7 @@ impl Index for [T] { } } -extern "C" { +unsafe extern "C" { type VaListImpl; } @@ -824,7 +822,7 @@ struct PanicLocation { column: u32, } -#[no_mangle] +#[unsafe(no_mangle)] pub fn get_tls() -> u8 { #[thread_local] static A: u8 = 42; diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index c20ac042516af..2eccbbc4fb28b 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,6 +10,7 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(pattern_type_macro))] #![cfg_attr(bootstrap, feature(unwrap_infallible))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] @@ -26,7 +27,6 @@ #![feature(min_specialization)] #![feature(negative_impls)] #![feature(nonzero_internals)] -#![feature(pattern_type_macro)] #![feature(pattern_types)] #![feature(ptr_alignment_type)] #![feature(rustc_attrs)] diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index ed2bf64263c67..bd203ccf6e218 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -318,8 +318,6 @@ declare_features! ( (internal, needs_panic_runtime, "1.10.0", Some(32837)), /// Allows using the `#![panic_runtime]` attribute. (internal, panic_runtime, "1.10.0", Some(32837)), - /// Allows using pattern types. - (internal, pattern_types, "1.79.0", Some(123646)), /// Allows `repr(simd)` and importing the various simd intrinsics. (internal, repr_simd, "1.4.0", Some(27731)), /// Allows using compiler's own crates. diff --git a/compiler/rustc_index_macros/src/lib.rs b/compiler/rustc_index_macros/src/lib.rs index b0bc40a9d8b1a..86681332ceb47 100644 --- a/compiler/rustc_index_macros/src/lib.rs +++ b/compiler/rustc_index_macros/src/lib.rs @@ -41,7 +41,7 @@ mod newtype; rustc_attrs, trusted_step, pattern_types, - pattern_type_macro, + pattern_type_macro, // cfg(bootstrap) FIXME: remove on bump structural_match, ) )] diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index b66d7310dbea5..029aab9e0e601 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -4,7 +4,7 @@ use rustc_ast::{ self as ast, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnPtrTy, FnRetTy, GenericBound, GenericBounds, GenericParam, Generics, Lifetime, MacCall, Mutability, Path, Pinnedness, PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, - TyKind, UnsafeBinderTy, + TyKind, TyPatKind, UnsafeBinderTy, }; use rustc_errors::{Applicability, Diag, E0516, PResult}; use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym}; @@ -423,6 +423,8 @@ impl<'a> Parser<'a> { self.parse_unsafe_binder_ty()? } else if self.eat_forced_keyword_noexpect(kw::FieldOf) { self.parse_ty_field_of(lo)? + } else if self.eat_forced_keyword_noexpect(kw::PatternType) { + self.parse_pat_ty(lo)? } else { let msg = format!("expected type, found {}", super::token_descr(&self.token)); let mut err = self.dcx().struct_span_err(lo, msg); @@ -826,7 +828,7 @@ impl<'a> Parser<'a> { Ok(TyKind::Err(guar)) } - pub(crate) fn parse_ty_field_of(&mut self, lo: Span) -> PResult<'a, TyKind> { + fn parse_ty_field_of(&mut self, lo: Span) -> PResult<'a, TyKind> { self.expect(exp!(OpenParen))?; let container = self.parse_ty()?; @@ -871,6 +873,56 @@ impl<'a> Parser<'a> { } } + fn parse_pat_ty(&mut self, lo: Span) -> PResult<'a, TyKind> { + self.expect(exp!(OpenParen))?; + + let ty = self.parse_ty()?; + self.expect_keyword(exp!(Is))?; + + let pat = if self.eat(exp!(Bang)) { + let lo = self.prev_token.span; + self.expect_keyword(exp!(Null))?; + Self::mk_ty_pat(TyPatKind::NotNull, lo.to(self.token.span)) + } else { + let pat = self.parse_pat_no_top_guard( + None, + super::RecoverComma::No, + super::RecoverColon::No, + super::CommaRecoveryMode::EitherTupleOrPipe, + )?; + self.pat_to_ty_pat(pat) + }; + + self.expect(exp!(CloseParen))?; + + self.psess.gated_spans.gate(sym::internal_syntax, lo.to(self.token.span)); + + Ok(TyKind::Pat(ty, Box::new(pat))) + } + + fn pat_to_ty_pat(&self, pat: ast::Pat) -> ast::TyPat { + let kind = match pat.kind { + ast::PatKind::Range(start, end, include_end) => TyPatKind::Range( + start.map(|value| Box::new(ast::AnonConst { id: DUMMY_NODE_ID, value })), + end.map(|value| Box::new(ast::AnonConst { id: DUMMY_NODE_ID, value })), + include_end, + ), + ast::PatKind::Or(variants) => { + TyPatKind::Or(variants.into_iter().map(|pat| self.pat_to_ty_pat(pat)).collect()) + } + ast::PatKind::Err(guar) => TyPatKind::Err(guar), + ast::PatKind::Paren(p) => self.pat_to_ty_pat(*p).kind, + _ => TyPatKind::Err( + self.dcx().span_err(pat.span, "pattern not supported in pattern types"), + ), + }; + Self::mk_ty_pat(kind, pat.span) + } + + fn mk_ty_pat(kind: TyPatKind, span: Span) -> ast::TyPat { + ast::TyPat { id: DUMMY_NODE_ID, kind, span } + } + /// Parses a function pointer type (`TyKind::FnPtr`). /// ```ignore (illustrative) /// [unsafe] [extern "ABI"] fn (S) -> T diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index a7f8e37687b18..6b5299d7eb1be 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -133,6 +133,7 @@ symbols! { FieldOf: "field_of", MacroRules: "macro_rules", OffsetOf: "offset_of", + PatternType: "pattern_type", Pin: "pin", Raw: "raw", Reuse: "reuse", @@ -1606,7 +1607,6 @@ symbols! { path, pattern_complexity_limit, pattern_parentheses, - pattern_type, pattern_type_range_trait, pattern_types, phantom_data, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e6520a0c348c9..00c7c3c824cfa 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -99,7 +99,7 @@ #![feature(io_const_error)] #![feature(offset_of_enum)] #![feature(panic_internals)] -#![feature(pattern_type_macro)] +#![feature(pattern_types)] #![feature(ub_checks)] // tidy-alphabetical-end // @@ -146,7 +146,6 @@ #![feature(must_not_suspend)] #![feature(negative_impls)] #![feature(no_core)] -#![feature(pattern_types)] #![feature(pin_macro_internals)] #![feature(prelude_import)] #![feature(register_tool)] @@ -314,7 +313,7 @@ pub mod option; pub mod os; pub mod panic; pub mod panicking; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] pub mod pat; pub mod pin; #[unstable(feature = "abort_immediate", issue = "154601")] diff --git a/library/core/src/num/niche_types.rs b/library/core/src/num/niche_types.rs index 37037d8145fb0..6d3e59b05a2c3 100644 --- a/library/core/src/num/niche_types.rs +++ b/library/core/src/num/niche_types.rs @@ -5,9 +5,10 @@ )] use crate::cmp::Ordering; +use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::marker::StructuralPartialEq; -use crate::{fmt, pattern_type}; +use crate::pat::pattern_type; macro_rules! define_valid_range_type { ($( diff --git a/library/core/src/pat.rs b/library/core/src/pat.rs index 0cf9f10fc8c28..1315c2a46d128 100644 --- a/library/core/src/pat.rs +++ b/library/core/src/pat.rs @@ -7,13 +7,11 @@ use crate::ops::{CoerceUnsized, DispatchFromDyn}; /// ```ignore (cannot test this from within core yet) /// type Positive = std::pat::pattern_type!(i32 is 1..); /// ``` -#[macro_export] -#[rustc_builtin_macro(pattern_type)] -#[unstable(feature = "pattern_type_macro", issue = "123646")] -macro_rules! pattern_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +#[unstable(feature = "pattern_types", issue = "123646")] +#[diagnostic::opaque] +pub macro pattern_type($( $arg:tt )*) { + k#pattern_type($( $arg )*) } /// A trait implemented for integer types and `char`. diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index f68d3e614c53f..d21fa351f5bce 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -104,9 +104,9 @@ pub use crate::const_format_args; #[doc(no_inline)] pub use crate::log_syntax; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] #[doc(no_inline)] -pub use crate::pattern_type; +pub use crate::pat::pattern_type; #[unstable( feature = "trace_macros", diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 7d444cc8698a5..cf23690992ef1 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -76,7 +76,7 @@ use crate::{fmt, hash, intrinsics, mem, ptr}; #[rustc_nonnull_optimization_guaranteed] #[lang = "non_null"] pub struct NonNull<#[rustc_assert_variance(covariant)] T: PointeeSized> { - pointer: crate::pattern_type!(*const T is !null), + pointer: crate::pat::pattern_type!(*const T is !null), } /// `NonNull` pointers are not `Send` because the data they reference may be aliased. diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 1f684c162496b..0c3d29324c9ae 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -641,7 +641,7 @@ pub mod num; #[allow(unreachable_pub)] pub mod os; pub mod panic; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] pub mod pat; pub mod path; pub mod process; diff --git a/library/std/src/pat.rs b/library/std/src/pat.rs index aeddd84c2cb54..3d227b1903f33 100644 --- a/library/std/src/pat.rs +++ b/library/std/src/pat.rs @@ -1,3 +1,3 @@ //! Helper module for exporting the `pattern_type` macro -pub use core::pattern_type; +pub use core::pat::pattern_type; diff --git a/src/tools/clippy/tests/ui/eager_transmute.fixed b/src/tools/clippy/tests/ui/eager_transmute.fixed index a62b4ff7c75e5..30e741755d9b4 100644 --- a/src/tools/clippy/tests/ui/eager_transmute.fixed +++ b/src/tools/clippy/tests/ui/eager_transmute.fixed @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] #![warn(clippy::eager_transmute)] #![expect(clippy::missing_transmute_annotations, clippy::transmute_int_to_non_zero)] diff --git a/src/tools/clippy/tests/ui/eager_transmute.rs b/src/tools/clippy/tests/ui/eager_transmute.rs index cc6fbc2ebd37d..c9f4c19d8837d 100644 --- a/src/tools/clippy/tests/ui/eager_transmute.rs +++ b/src/tools/clippy/tests/ui/eager_transmute.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] #![warn(clippy::eager_transmute)] #![expect(clippy::missing_transmute_annotations, clippy::transmute_int_to_non_zero)] diff --git a/src/tools/miri/tests/fail/validity/nonzero.rs b/src/tools/miri/tests/fail/validity/nonzero.rs index fba37ee170e3a..1e847c4792442 100644 --- a/src/tools/miri/tests/fail/validity/nonzero.rs +++ b/src/tools/miri/tests/fail/validity/nonzero.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] #![allow(unused_attributes)] #[repr(transparent)] diff --git a/src/tools/miri/tests/pass/pattern-types.rs b/src/tools/miri/tests/pass/pattern-types.rs index 90fe0de546915..2422f79d25d88 100644 --- a/src/tools/miri/tests/pass/pattern-types.rs +++ b/src/tools/miri/tests/pass/pattern-types.rs @@ -1,4 +1,4 @@ -#![feature(pattern_types, pattern_type_macro, sized_hierarchy)] +#![feature(pattern_types, sized_hierarchy)] #![allow(dead_code)] use std::marker::PointeeSized; diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index e7e924f9ebc08..530a6496c39b5 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -23,11 +23,12 @@ intrinsics, lang_items, auto_traits, + forced_keywords, freeze_impls, negative_impls, - pattern_types, rustc_attrs, decl_macro, + allow_internal_unstable, f16, f16b, cfg_target_has_reliable_f16b, @@ -468,12 +469,9 @@ pub enum c_void { __variant2, } -#[rustc_builtin_macro(pattern_type)] -#[macro_export] -macro_rules! pattern_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +pub macro pattern_type($($arg:tt)*) { + k#pattern_type($($arg)*) } #[lang = "Ordering"] diff --git a/tests/codegen-llvm/enum/enum-aggregate.rs b/tests/codegen-llvm/enum/enum-aggregate.rs index 46a1a03e96371..1e359480ad6a6 100644 --- a/tests/codegen-llvm/enum/enum-aggregate.rs +++ b/tests/codegen-llvm/enum/enum-aggregate.rs @@ -2,7 +2,7 @@ //@ only-64bit #![crate_type = "lib"] -#![feature(pattern_types, pattern_type_macro)] +#![feature(pattern_types)] use std::cmp::Ordering; use std::num::NonZero; diff --git a/tests/codegen-llvm/pattern_type_symbols.rs b/tests/codegen-llvm/pattern_type_symbols.rs index a90262ff12d21..f20940780d84d 100644 --- a/tests/codegen-llvm/pattern_type_symbols.rs +++ b/tests/codegen-llvm/pattern_type_symbols.rs @@ -4,11 +4,10 @@ //@ compile-flags: -Csymbol-mangling-version=v0 -Copt-level=0 --crate-type=lib #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; -type NanoU32 = crate::pattern_type!(u32 is 0..=999_999_999); +type NanoU32 = pattern_type!(u32 is 0..=999_999_999); fn foo() {} diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index d418d8f0987e6..2ec127390ca75 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -232,7 +232,7 @@ //@ cdb-command: dx c_style_i128_d //@ cdb-check: c_style_i128_d : D [Type: enum2$] -#![feature(pattern_types, pattern_type_macro)] +#![feature(pattern_types)] use std::num::NonZero; @@ -271,9 +271,7 @@ enum NicheLayoutWithFields3 { } #[repr(transparent)] -struct Wrapping128( - std::pat::pattern_type!(i128 is -2..=1), -); +struct Wrapping128(std::pat::pattern_type!(i128 is -2..=1)); enum Wrapping128Niche { X(Wrapping128), diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 80553a3974881..454e2849597f1 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Zdump-mir-exclude-alloc-bytes // EMIT_MIR_FOR_EACH_BIT_WIDTH -#![feature(custom_mir, core_intrinsics, rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(custom_mir, core_intrinsics, rustc_attrs, pattern_types)] use std::intrinsics::mir::*; diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 2ce475f7401ac..366af8355c031 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -6,7 +6,7 @@ #![feature(rustc_attrs)] #![feature(custom_mir)] #![feature(core_intrinsics)] -#![feature(freeze, pattern_type_range_trait, const_trait_impl, pattern_types, pattern_type_macro)] +#![feature(freeze, pattern_type_range_trait, const_trait_impl, pattern_types)] #![allow(ambiguous_wide_pointer_comparisons)] #![allow(unconditional_panic)] #![allow(unnecessary_transmutes)] diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index ae56921bb1d44..cdf49fb36bef4 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Zmir-enable-passes=+Inline // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -#![feature(try_trait_v2, pattern_type_macro, pattern_types)] +#![feature(try_trait_v2, pattern_types)] #![feature(custom_mir, core_intrinsics, rustc_attrs)] use std::intrinsics::mir::*; diff --git a/tests/mir-opt/pattern_types.rs b/tests/mir-opt/pattern_types.rs index dfa4c40d2dd7b..c714060619c16 100644 --- a/tests/mir-opt/pattern_types.rs +++ b/tests/mir-opt/pattern_types.rs @@ -1,5 +1,4 @@ #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/rustdoc-html/pattern-types-implementors.rs b/tests/rustdoc-html/pattern-types-implementors.rs index 2f49837b27e74..030b8b85f58dc 100644 --- a/tests/rustdoc-html/pattern-types-implementors.rs +++ b/tests/rustdoc-html/pattern-types-implementors.rs @@ -1,4 +1,4 @@ -#![feature(pattern_types, pattern_type_macro)] +#![feature(pattern_types)] #![crate_name = "pattern_types_implementors"] use std::pat::pattern_type; diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index c682a17b8decf..8d13b5513fb9f 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -4,7 +4,7 @@ // ignore-tidy-file-linelength #![allow(invalid_value, unnecessary_transmutes)] -#![feature(pattern_types, pattern_type_macro)] +#![feature(pattern_types)] #![feature(rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] use std::mem; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 9cd47e4b155e3..eadb7ccf1126c 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -6,7 +6,7 @@ //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" -#![feature(pattern_types, pattern_type_macro)] +#![feature(pattern_types)] #![allow(invalid_value)] use std::{mem, pat::pattern_type}; diff --git a/tests/ui/enum-discriminant/ptr_niche.rs b/tests/ui/enum-discriminant/ptr_niche.rs index 45dbe50248217..4390b69de0516 100644 --- a/tests/ui/enum-discriminant/ptr_niche.rs +++ b/tests/ui/enum-discriminant/ptr_niche.rs @@ -2,7 +2,7 @@ //! Check that we can codegen setting and getting discriminants, including non-null niches, //! for enums with a pointer-like ABI. This used to crash llvm. -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] use std::{ptr, mem, pat::pattern_type}; #[derive(Copy, Clone)] diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs index e4477c9620221..195aab24899cf 100644 --- a/tests/ui/lint/clashing-extern-fn.rs +++ b/tests/ui/lint/clashing-extern-fn.rs @@ -1,7 +1,7 @@ //@ check-pass //@ aux-build:external_extern_fn.rs #![crate_type = "lib"] -#![feature(pattern_type_macro, pattern_types)] +#![feature(pattern_types)] mod redeclared_different_signature { mod a { extern "C" { diff --git a/tests/ui/lint/invalid_value.rs b/tests/ui/lint/invalid_value.rs index 301283853eb26..f76d988f44c68 100644 --- a/tests/ui/lint/invalid_value.rs +++ b/tests/ui/lint/invalid_value.rs @@ -2,7 +2,7 @@ // in a lint. #![allow(deprecated)] #![deny(invalid_value)] -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] use std::mem::{self, MaybeUninit}; use std::num::NonZero; diff --git a/tests/ui/mir/ssa-analysis-regression-50041.rs b/tests/ui/mir/ssa-analysis-regression-50041.rs index 28690624f63ec..37d78acc2c452 100644 --- a/tests/ui/mir/ssa-analysis-regression-50041.rs +++ b/tests/ui/mir/ssa-analysis-regression-50041.rs @@ -2,7 +2,7 @@ //@ compile-flags: -Z mir-opt-level=4 #![crate_type = "lib"] -#![feature(lang_items, pattern_type_macro, pattern_types)] +#![feature(lang_items, pattern_types)] #![no_std] struct NonNull(pattern_type!(*const T is !null)); diff --git a/tests/ui/pattern/overflowing-literals.rs b/tests/ui/pattern/overflowing-literals.rs index 13016d3f7d197..9e33d49963ee0 100644 --- a/tests/ui/pattern/overflowing-literals.rs +++ b/tests/ui/pattern/overflowing-literals.rs @@ -1,7 +1,6 @@ //! Check that overflowing literals are in patterns are rejected #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/pattern/overflowing-literals.stderr b/tests/ui/pattern/overflowing-literals.stderr index 8164b97fd4720..54525cf6cd9f8 100644 --- a/tests/ui/pattern/overflowing-literals.stderr +++ b/tests/ui/pattern/overflowing-literals.stderr @@ -1,5 +1,5 @@ error: literal out of range for `u8` - --> $DIR/overflowing-literals.rs:8:35 + --> $DIR/overflowing-literals.rs:7:35 | LL | type TooBig = pattern_type!(u8 is 500..); | ^^^ @@ -8,7 +8,7 @@ LL | type TooBig = pattern_type!(u8 is 500..); = note: `#[deny(overflowing_literals)]` on by default error: literal out of range for `i8` - --> $DIR/overflowing-literals.rs:10:37 + --> $DIR/overflowing-literals.rs:9:37 | LL | type TooSmall = pattern_type!(i8 is -500..); | ^^^^ @@ -17,7 +17,7 @@ LL | type TooSmall = pattern_type!(i8 is -500..); = help: consider using the type `i16` instead error: literal out of range for `i8` - --> $DIR/overflowing-literals.rs:12:41 + --> $DIR/overflowing-literals.rs:11:41 | LL | type TooBigSigned = pattern_type!(i8 is 200..); | ^^^ @@ -26,7 +26,7 @@ LL | type TooBigSigned = pattern_type!(i8 is 200..); = help: consider using the type `u8` instead error: literal out of range for `u8` - --> $DIR/overflowing-literals.rs:17:9 + --> $DIR/overflowing-literals.rs:16:9 | LL | 500 => {} | ^^^ diff --git a/tests/ui/print_type_sizes/niche-filling.rs b/tests/ui/print_type_sizes/niche-filling.rs index 2fcb1dfe3c8c2..ecd243cd01ba8 100644 --- a/tests/ui/print_type_sizes/niche-filling.rs +++ b/tests/ui/print_type_sizes/niche-filling.rs @@ -15,7 +15,7 @@ // ^-- needed because `--pass check` does not emit the output needed. // FIXME: consider using an attribute instead of side-effects. #![allow(dead_code)] -#![feature(rustc_attrs, pattern_types, pattern_type_macro)] +#![feature(rustc_attrs, pattern_types)] use std::num::NonZero; diff --git a/tests/ui/type/pattern_types/assoc_const.default.stderr b/tests/ui/type/pattern_types/assoc_const.default.stderr index 8b1184877af83..db79eaff48753 100644 --- a/tests/ui/type/pattern_types/assoc_const.default.stderr +++ b/tests/ui/type/pattern_types/assoc_const.default.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/assoc_const.rs:17:41 + --> $DIR/assoc_const.rs:15:41 | LL | fn foo(_: pattern_type!(u32 is ::START..=::END)) {} | ^ cannot perform const operation using `T` @@ -9,7 +9,7 @@ LL | fn foo(_: pattern_type!(u32 is ::START..=::END) = help: alternatively, you can use `#![feature(gca_const_items)]` and wrap the expression in the `gca!` macro error: generic parameters may not be used in const operations - --> $DIR/assoc_const.rs:17:61 + --> $DIR/assoc_const.rs:15:61 | LL | fn foo(_: pattern_type!(u32 is ::START..=::END)) {} | ^ cannot perform const operation using `T` @@ -19,7 +19,7 @@ LL | fn foo(_: pattern_type!(u32 is ::START..=::END) = help: alternatively, you can use `#![feature(gca_const_items)]` and wrap the expression in the `gca!` macro error: generic parameters may not be used in const operations - --> $DIR/assoc_const.rs:20:40 + --> $DIR/assoc_const.rs:18:40 | LL | fn bar(_: pattern_type!(u32 is T::START..=T::END)) {} | ^ cannot perform const operation using `T` @@ -29,7 +29,7 @@ LL | fn bar(_: pattern_type!(u32 is T::START..=T::END)) {} = help: alternatively, you can use `#![feature(gca_const_items)]` and wrap the expression in the `gca!` macro error: generic parameters may not be used in const operations - --> $DIR/assoc_const.rs:20:51 + --> $DIR/assoc_const.rs:18:51 | LL | fn bar(_: pattern_type!(u32 is T::START..=T::END)) {} | ^ cannot perform const operation using `T` diff --git a/tests/ui/type/pattern_types/assoc_const.rs b/tests/ui/type/pattern_types/assoc_const.rs index 90508801990e8..6b5de2042f5d0 100644 --- a/tests/ui/type/pattern_types/assoc_const.rs +++ b/tests/ui/type/pattern_types/assoc_const.rs @@ -1,7 +1,5 @@ #![feature(pattern_types)] -#![feature(pattern_type_macro)] #![cfg_attr(const_arg, feature(generic_const_exprs, generic_pattern_types))] -#![expect(incomplete_features)] // gate-test-generic_pattern_types line to the test file. //@ revisions: default const_arg diff --git a/tests/ui/type/pattern_types/bad_pat.rs b/tests/ui/type/pattern_types/bad_pat.rs index 7e2b4cb996f27..75c8169188011 100644 --- a/tests/ui/type/pattern_types/bad_pat.rs +++ b/tests/ui/type/pattern_types/bad_pat.rs @@ -1,5 +1,4 @@ #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; @@ -12,7 +11,7 @@ type Wild = pattern_type!(() is _); // FIXME: confusing diagnostic because `not` can be a binding type NonNull = pattern_type!(*const () is not null); -//~^ ERROR: expected one of `@` or `|`, found `null` +//~^ ERROR: expected one of //~| ERROR: pattern not supported in pattern types type NonNull2 = pattern_type!(*const () is !nil); diff --git a/tests/ui/type/pattern_types/bad_pat.stderr b/tests/ui/type/pattern_types/bad_pat.stderr index e72279542280c..07ced579c6512 100644 --- a/tests/ui/type/pattern_types/bad_pat.stderr +++ b/tests/ui/type/pattern_types/bad_pat.stderr @@ -1,5 +1,5 @@ error[E0586]: inclusive range with no end - --> $DIR/bad_pat.rs:6:43 + --> $DIR/bad_pat.rs:5:43 | LL | type NonNullU32_2 = pattern_type!(u32 is 1..=); | ^^^ @@ -12,7 +12,7 @@ LL + type NonNullU32_2 = pattern_type!(u32 is 1..); | error[E0586]: inclusive range with no end - --> $DIR/bad_pat.rs:8:40 + --> $DIR/bad_pat.rs:7:40 | LL | type Positive2 = pattern_type!(i32 is 0..=); | ^^^ @@ -25,25 +25,25 @@ LL + type Positive2 = pattern_type!(i32 is 0..); | error: pattern not supported in pattern types - --> $DIR/bad_pat.rs:10:33 + --> $DIR/bad_pat.rs:9:33 | LL | type Wild = pattern_type!(() is _); | ^ error: pattern not supported in pattern types - --> $DIR/bad_pat.rs:14:43 + --> $DIR/bad_pat.rs:13:43 | LL | type NonNull = pattern_type!(*const () is not null); | ^^^ -error: expected one of `@` or `|`, found `null` - --> $DIR/bad_pat.rs:14:47 +error: expected one of `)`, `@`, or `|`, found `null` + --> $DIR/bad_pat.rs:13:47 | LL | type NonNull = pattern_type!(*const () is not null); - | ^^^^ expected one of `@` or `|` + | ^^^^ expected one of `)`, `@`, or `|` error: expected `null`, found `nil` - --> $DIR/bad_pat.rs:18:45 + --> $DIR/bad_pat.rs:17:45 | LL | type NonNull2 = pattern_type!(*const () is !nil); | ^^^ expected `null` diff --git a/tests/ui/type/pattern_types/chars.rs b/tests/ui/type/pattern_types/chars.rs index 9073998b387b7..285c4f3abdf75 100644 --- a/tests/ui/type/pattern_types/chars.rs +++ b/tests/ui/type/pattern_types/chars.rs @@ -3,7 +3,6 @@ //@ check-pass #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/const_generics.rs b/tests/ui/type/pattern_types/const_generics.rs index f5eb90e94d4fd..aff5e72f2c9e8 100644 --- a/tests/ui/type/pattern_types/const_generics.rs +++ b/tests/ui/type/pattern_types/const_generics.rs @@ -3,7 +3,7 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(pattern_types, generic_pattern_types, pattern_type_macro)] +#![feature(pattern_types, generic_pattern_types)] #![expect(incomplete_features)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/derives.rs b/tests/ui/type/pattern_types/derives.rs index 12af19e5f7ea6..2a3d1164c9772 100644 --- a/tests/ui/type/pattern_types/derives.rs +++ b/tests/ui/type/pattern_types/derives.rs @@ -2,7 +2,6 @@ //! Exceptions are `Clone` and `Copy`, which have builtin impls for pattern types. #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; @@ -11,7 +10,7 @@ use std::pat::pattern_type; struct Nanoseconds(NanoI32); //~^ ERROR: binary operation `==` cannot be applied to type `pattern_type!(i32 is 0..=999999999)` -type NanoI32 = crate::pattern_type!(i32 is 0..=999_999_999); +type NanoI32 = pattern_type!(i32 is 0..=999_999_999); fn main() { let x = Nanoseconds(unsafe { std::mem::transmute(42) }); diff --git a/tests/ui/type/pattern_types/derives.stderr b/tests/ui/type/pattern_types/derives.stderr index 6fb0c0994082a..f196cec5a1dc5 100644 --- a/tests/ui/type/pattern_types/derives.stderr +++ b/tests/ui/type/pattern_types/derives.stderr @@ -1,5 +1,5 @@ error[E0369]: binary operation `==` cannot be applied to type `pattern_type!(i32 is 0..=999999999)` - --> $DIR/derives.rs:11:20 + --> $DIR/derives.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq)] | --------- in this derive macro expansion diff --git a/tests/ui/type/pattern_types/derives_fail.rs b/tests/ui/type/pattern_types/derives_fail.rs index 8251fa9f38c0b..60b4eb06db901 100644 --- a/tests/ui/type/pattern_types/derives_fail.rs +++ b/tests/ui/type/pattern_types/derives_fail.rs @@ -2,7 +2,6 @@ //! Exceptions are `Clone` and `Copy`, which have bultin impls for pattern types. #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; @@ -16,7 +15,7 @@ struct Nanoseconds(NanoI32); //~| ERROR: the trait bound `pattern_type!(i32 is 0..=999999999): Default` is not satisfied //~| ERROR: `==` cannot be applied -type NanoI32 = crate::pattern_type!(i32 is 0..=999_999_999); +type NanoI32 = pattern_type!(i32 is 0..=999_999_999); fn main() { let x = Nanoseconds(unsafe { std::mem::transmute(42) }); diff --git a/tests/ui/type/pattern_types/derives_fail.stderr b/tests/ui/type/pattern_types/derives_fail.stderr index a6814d8cba2a0..ac194b9be8990 100644 --- a/tests/ui/type/pattern_types/derives_fail.stderr +++ b/tests/ui/type/pattern_types/derives_fail.stderr @@ -1,5 +1,5 @@ error[E0369]: binary operation `==` cannot be applied to type `pattern_type!(i32 is 0..=999999999)` - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | --------- in this derive macro expansion @@ -8,7 +8,7 @@ LL | struct Nanoseconds(NanoI32); | ^^^^^^^ error[E0277]: the trait bound `pattern_type!(i32 is 0..=999999999): Eq` is not satisfied - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | -- in this derive macro expansion @@ -20,7 +20,7 @@ note: required by a bound in `std::cmp::AssertParamIsEq` --> $SRC_DIR/core/src/cmp.rs:LL:COL error[E0277]: `pattern_type!(i32 is 0..=999999999)` doesn't implement `Debug` - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | ----- in this derive macro expansion @@ -29,7 +29,7 @@ LL | struct Nanoseconds(NanoI32); | ^^^^^^^ the trait `Debug` is not implemented for `pattern_type!(i32 is 0..=999999999)` error[E0277]: the trait bound `pattern_type!(i32 is 0..=999999999): Ord` is not satisfied - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | --- in this derive macro expansion @@ -38,7 +38,7 @@ LL | struct Nanoseconds(NanoI32); | ^^^^^^^ the trait `Ord` is not implemented for `pattern_type!(i32 is 0..=999999999)` error[E0277]: the trait bound `pattern_type!(i32 is 0..=999999999): Hash` is not satisfied - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | ---- in this derive macro expansion @@ -47,7 +47,7 @@ LL | struct Nanoseconds(NanoI32); | ^^^^^^^ the trait `Hash` is not implemented for `pattern_type!(i32 is 0..=999999999)` error[E0277]: the trait bound `pattern_type!(i32 is 0..=999999999): Default` is not satisfied - --> $DIR/derives_fail.rs:11:20 + --> $DIR/derives_fail.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)] | ------- in this derive macro expansion diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr b/tests/ui/type/pattern_types/feature-gate-pattern_types.disabled.stderr similarity index 64% rename from tests/ui/type/pattern_types/feature-gate-pattern_types.stderr rename to tests/ui/type/pattern_types/feature-gate-pattern_types.disabled.stderr index 12508bcb54a34..b03af26289efc 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types.disabled.stderr @@ -1,55 +1,55 @@ -error[E0658]: use of unstable library feature `pattern_type_macro` - --> $DIR/feature-gate-pattern_types.rs:5:19 +error[E0658]: use of unstable library feature `pattern_types` + --> $DIR/feature-gate-pattern_types.rs:7:19 | LL | type NonNullU32 = pattern_type!(u32 is 1..); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable + = help: add `#![feature(pattern_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `pattern_type_macro` - --> $DIR/feature-gate-pattern_types.rs:7:16 +error[E0658]: use of unstable library feature `pattern_types` + --> $DIR/feature-gate-pattern_types.rs:9:16 | LL | type Percent = pattern_type!(u32 is 0..=100); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable + = help: add `#![feature(pattern_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `pattern_type_macro` - --> $DIR/feature-gate-pattern_types.rs:9:17 +error[E0658]: use of unstable library feature `pattern_types` + --> $DIR/feature-gate-pattern_types.rs:11:17 | LL | type Negative = pattern_type!(i32 is ..=0); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable + = help: add `#![feature(pattern_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `pattern_type_macro` - --> $DIR/feature-gate-pattern_types.rs:11:17 +error[E0658]: use of unstable library feature `pattern_types` + --> $DIR/feature-gate-pattern_types.rs:13:17 | LL | type Positive = pattern_type!(i32 is 0..); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable + = help: add `#![feature(pattern_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `pattern_type_macro` - --> $DIR/feature-gate-pattern_types.rs:13:15 +error[E0658]: use of unstable library feature `pattern_types` + --> $DIR/feature-gate-pattern_types.rs:15:15 | LL | type Always = pattern_type!(Option is Some(_)); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable + = help: add `#![feature(pattern_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: pattern not supported in pattern types - --> $DIR/feature-gate-pattern_types.rs:13:44 + --> $DIR/feature-gate-pattern_types.rs:15:44 | LL | type Always = pattern_type!(Option is Some(_)); | ^^^^^^^ diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types2.stderr b/tests/ui/type/pattern_types/feature-gate-pattern_types.enabled.stderr similarity index 81% rename from tests/ui/type/pattern_types/feature-gate-pattern_types2.stderr rename to tests/ui/type/pattern_types/feature-gate-pattern_types.enabled.stderr index 81bf9dea0e2fd..c77bbd2756bf0 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types2.stderr +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types.enabled.stderr @@ -1,5 +1,5 @@ error: pattern not supported in pattern types - --> $DIR/feature-gate-pattern_types2.rs:11:44 + --> $DIR/feature-gate-pattern_types.rs:15:44 | LL | type Always = pattern_type!(Option is Some(_)); | ^^^^^^^ diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types.rs b/tests/ui/type/pattern_types/feature-gate-pattern_types.rs index a51741675bbd6..91241c00d56c9 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types.rs +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types.rs @@ -1,15 +1,17 @@ +//@ revisions: disabled enabled //@ compile-flags: -Zno-analysis +#![cfg_attr(enabled, feature(pattern_types))] use std::pat::pattern_type; type NonNullU32 = pattern_type!(u32 is 1..); -//~^ ERROR use of unstable library feature `pattern_type_macro` +//[disabled]~^ ERROR use of unstable library feature `pattern_types` type Percent = pattern_type!(u32 is 0..=100); -//~^ ERROR use of unstable library feature `pattern_type_macro` +//[disabled]~^ ERROR use of unstable library feature `pattern_types` type Negative = pattern_type!(i32 is ..=0); -//~^ ERROR use of unstable library feature `pattern_type_macro` +//[disabled]~^ ERROR use of unstable library feature `pattern_types` type Positive = pattern_type!(i32 is 0..); -//~^ ERROR use of unstable library feature `pattern_type_macro` +//[disabled]~^ ERROR use of unstable library feature `pattern_types` type Always = pattern_type!(Option is Some(_)); -//~^ ERROR use of unstable library feature `pattern_type_macro` -//~| ERROR pattern not supported in pattern types +//[disabled]~^ ERROR use of unstable library feature `pattern_types` +//~^^ ERROR pattern not supported in pattern types diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs b/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs deleted file mode 100644 index c6b4b325fa35a..0000000000000 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ compile-flags: -Zno-analysis - -#![feature(pattern_type_macro)] - -use std::pat::pattern_type; - -type NonNullU32 = pattern_type!(u32 is 1..); -type Percent = pattern_type!(u32 is 0..=100); -type Negative = pattern_type!(i32 is ..=0); -type Positive = pattern_type!(i32 is 0..); -type Always = pattern_type!(Option is Some(_)); -//~^ ERROR: pattern not supported in pattern types diff --git a/tests/ui/type/pattern_types/free_const.rs b/tests/ui/type/pattern_types/free_const.rs index 2e29fce237970..96601622a352f 100644 --- a/tests/ui/type/pattern_types/free_const.rs +++ b/tests/ui/type/pattern_types/free_const.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/literals.rs b/tests/ui/type/pattern_types/literals.rs index 5ec15d1b6bd8e..407123ca8f7ef 100644 --- a/tests/ui/type/pattern_types/literals.rs +++ b/tests/ui/type/pattern_types/literals.rs @@ -1,7 +1,6 @@ //! Check where literals can be used to initialize pattern types and where not. #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/literals.stderr b/tests/ui/type/pattern_types/literals.stderr index caf5667c8f314..f36c477126020 100644 --- a/tests/ui/type/pattern_types/literals.stderr +++ b/tests/ui/type/pattern_types/literals.stderr @@ -1,35 +1,35 @@ error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/literals.rs:86:62 + --> $DIR/literals.rs:85:62 | LL | fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) { | ^ evaluation of `empty_range_at_base_type_min::{constant#1}` failed here error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/literals.rs:91:63 + --> $DIR/literals.rs:90:63 | LL | fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) { | ^ evaluation of `empty_range_at_base_type_min2::{constant#1}` failed here error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/literals.rs:106:65 + --> $DIR/literals.rs:105:65 | LL | fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) { | ^ evaluation of `wraparound_range_at_base_ty_end::{constant#1}` failed here error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/literals.rs:111:66 + --> $DIR/literals.rs:110:66 | LL | fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) { | ^ evaluation of `wraparound_range_at_base_ty_end2::{constant#1}` failed here error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/literals.rs:116:66 + --> $DIR/literals.rs:115:66 | LL | fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) { | ^ evaluation of `wraparound_range_at_base_ty_end3::{constant#1}` failed here error[E0308]: mismatched types - --> $DIR/literals.rs:9:5 + --> $DIR/literals.rs:8:5 | LL | fn out_of_range() -> pattern_type!(u32 is 1..) { | ------------------------- expected `pattern_type!(u32 is 1..)` because of return type @@ -40,19 +40,19 @@ LL | 0 found type `{integer}` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(u32 is 1..)` - --> $DIR/literals.rs:22:5 + --> $DIR/literals.rs:21:5 | LL | -3 | ^^ cannot apply unary operator `-` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is -5..=4)` - --> $DIR/literals.rs:27:5 + --> $DIR/literals.rs:26:5 | LL | -2 | ^^ cannot apply unary operator `-` error[E0308]: mismatched types - --> $DIR/literals.rs:36:5 + --> $DIR/literals.rs:35:5 | LL | fn negative_lit_at_range_start() -> pattern_type!(i8 is -5..5) { | -------------------------- expected `pattern_type!(i8 is -5..=4)` because of return type @@ -63,7 +63,7 @@ LL | -5 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:45:5 + --> $DIR/literals.rs:44:5 | LL | fn lit_one_beyond_range_end() -> pattern_type!(i8 is -5..5) { | -------------------------- expected `pattern_type!(i8 is -5..=4)` because of return type @@ -74,7 +74,7 @@ LL | 5 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:50:5 + --> $DIR/literals.rs:49:5 | LL | fn wrong_lit_kind() -> pattern_type!(u32 is 1..) { | ------------------------- expected `pattern_type!(u32 is 1..)` because of return type @@ -85,7 +85,7 @@ LL | '3' found type `char` error[E0308]: mismatched types - --> $DIR/literals.rs:55:5 + --> $DIR/literals.rs:54:5 | LL | fn char_lit_in_range() -> pattern_type!(char is 'a'..'z') { | ------------------------------- expected `pattern_type!(char is 'a'..='y')` because of return type @@ -96,7 +96,7 @@ LL | 'b' found type `char` error[E0308]: mismatched types - --> $DIR/literals.rs:60:5 + --> $DIR/literals.rs:59:5 | LL | fn char_lit_out_of_range() -> pattern_type!(char is 'a'..'z') { | ------------------------------- expected `pattern_type!(char is 'a'..='y')` because of return type @@ -107,7 +107,7 @@ LL | 'A' found type `char` error[E0308]: mismatched types - --> $DIR/literals.rs:73:5 + --> $DIR/literals.rs:72:5 | LL | fn lit_oob_single_element_range() -> pattern_type!(u32 is 0..=0) { | --------------------------- expected `pattern_type!(u32 is 0..=0)` because of return type @@ -118,7 +118,7 @@ LL | 1 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:78:5 + --> $DIR/literals.rs:77:5 | LL | fn lit_oob_single_element_range_exclusive() -> pattern_type!(u32 is 0..1) { | -------------------------- expected `pattern_type!(u32 is 0..=0)` because of return type @@ -131,7 +131,7 @@ LL | 1 error: pattern type ranges cannot wrap: 1..=0 error[E0308]: mismatched types - --> $DIR/literals.rs:97:5 + --> $DIR/literals.rs:96:5 | LL | fn empty_range() -> pattern_type!(u32 is 1..1) { | -------------------------- expected `pattern_type!(u32 is 1..=0)` because of return type @@ -142,7 +142,7 @@ LL | 0 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:102:5 + --> $DIR/literals.rs:101:5 | LL | fn empty_range2() -> pattern_type!(u32 is 1..1) { | -------------------------- expected `pattern_type!(u32 is 1..=0)` because of return type @@ -155,7 +155,7 @@ LL | 1 error: pattern type ranges cannot wrap: 2..=0 error[E0308]: mismatched types - --> $DIR/literals.rs:122:5 + --> $DIR/literals.rs:121:5 | LL | fn wraparound_range() -> pattern_type!(u32 is 2..1) { | -------------------------- expected `pattern_type!(u32 is 2..=0)` because of return type @@ -166,7 +166,7 @@ LL | 1 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:127:5 + --> $DIR/literals.rs:126:5 | LL | fn lit_in_wraparound_range() -> pattern_type!(u32 is 2..1) { | -------------------------- expected `pattern_type!(u32 is 2..=0)` because of return type @@ -177,7 +177,7 @@ LL | 0 found type `{integer}` error[E0308]: mismatched types - --> $DIR/literals.rs:132:5 + --> $DIR/literals.rs:131:5 | LL | fn lit_at_wraparound_range_start() -> pattern_type!(u32 is 2..1) { | -------------------------- expected `pattern_type!(u32 is 2..=0)` because of return type diff --git a/tests/ui/type/pattern_types/matching.rs b/tests/ui/type/pattern_types/matching.rs index 21f89b3b673be..1086baab876c1 100644 --- a/tests/ui/type/pattern_types/matching.rs +++ b/tests/ui/type/pattern_types/matching.rs @@ -1,4 +1,4 @@ -#![feature(pattern_types, pattern_type_macro, structural_match)] +#![feature(pattern_types, structural_match)] //@ check-pass //@ compile-flags: -Zvalidate-mir diff --git a/tests/ui/type/pattern_types/matching_fail.rs b/tests/ui/type/pattern_types/matching_fail.rs index 8e2c741e3e0ab..2a345635378a6 100644 --- a/tests/ui/type/pattern_types/matching_fail.rs +++ b/tests/ui/type/pattern_types/matching_fail.rs @@ -1,4 +1,4 @@ -#![feature(pattern_types, pattern_type_macro, structural_match)] +#![feature(pattern_types, structural_match)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/missing-is.rs b/tests/ui/type/pattern_types/missing-is.rs index 564b41649d899..619f37eb007e0 100644 --- a/tests/ui/type/pattern_types/missing-is.rs +++ b/tests/ui/type/pattern_types/missing-is.rs @@ -1,4 +1,4 @@ -#![feature(pattern_type_macro)] +#![feature(pattern_types)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/nested.rs b/tests/ui/type/pattern_types/nested.rs index bff83dd43902b..96fbfea9e5e6f 100644 --- a/tests/ui/type/pattern_types/nested.rs +++ b/tests/ui/type/pattern_types/nested.rs @@ -1,7 +1,6 @@ //! Check that pattern types can only have specific base types #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/nested.stderr b/tests/ui/type/pattern_types/nested.stderr index 72f0ccc1bfb9f..f75405241ae9e 100644 --- a/tests/ui/type/pattern_types/nested.stderr +++ b/tests/ui/type/pattern_types/nested.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/nested.rs:10:63 + --> $DIR/nested.rs:9:63 | LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!(); | ------------------------- ^ expected `pattern_type!(u32 is 1..)`, found integer @@ -10,7 +10,7 @@ LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!( found type `{integer}` error[E0277]: `pattern_type!(u32 is 1..)` is not a valid base type for range patterns - --> $DIR/nested.rs:10:34 + --> $DIR/nested.rs:9:34 | LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ only integer types and `char` are supported @@ -28,7 +28,7 @@ LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!( and 5 others error[E0277]: `pattern_type!(i32 is 1..)` is not a valid base type for range patterns - --> $DIR/nested.rs:15:35 + --> $DIR/nested.rs:14:35 | LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ only integer types and `char` are supported @@ -46,13 +46,13 @@ LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = tod and 5 others error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i32 is 1..)` - --> $DIR/nested.rs:15:67 + --> $DIR/nested.rs:14:67 | LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); | ^^ cannot apply unary operator `-` error[E0277]: `pattern_type!(i32 is 1..)` is not a valid base type for range patterns - --> $DIR/nested.rs:19:35 + --> $DIR/nested.rs:18:35 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ only integer types and `char` are supported @@ -70,7 +70,7 @@ LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo! and 5 others error[E0308]: mismatched types - --> $DIR/nested.rs:19:66 + --> $DIR/nested.rs:18:66 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^ @@ -81,7 +81,7 @@ LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo! = note: expected pattern type `pattern_type!(i32 is 1..)` found type `{integer}` help: the return type of this call is `{integer}` due to the type of the argument passed - --> $DIR/nested.rs:19:66 + --> $DIR/nested.rs:18:66 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^ this argument influences the return type of `RangeSub` @@ -89,7 +89,7 @@ note: method defined here --> $SRC_DIR/core/src/pat.rs:LL:COL error[E0277]: `pattern_type!(i32 is 1..)` is not a valid base type for range patterns - --> $DIR/nested.rs:19:66 + --> $DIR/nested.rs:18:66 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^ only integer types and `char` are supported @@ -107,7 +107,7 @@ LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo! and 5 others error[E0277]: `()` is not a valid base type for range patterns - --> $DIR/nested.rs:24:35 + --> $DIR/nested.rs:23:35 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^^ only integer types and `char` are supported @@ -125,7 +125,7 @@ LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); and 5 others error[E0308]: mismatched types - --> $DIR/nested.rs:24:43 + --> $DIR/nested.rs:23:43 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^ @@ -134,7 +134,7 @@ LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | arguments to this function are incorrect | help: the return type of this call is `{integer}` due to the type of the argument passed - --> $DIR/nested.rs:24:43 + --> $DIR/nested.rs:23:43 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^ this argument influences the return type of `RangeSub` @@ -142,7 +142,7 @@ note: method defined here --> $SRC_DIR/core/src/pat.rs:LL:COL error[E0277]: `()` is not a valid base type for range patterns - --> $DIR/nested.rs:24:43 + --> $DIR/nested.rs:23:43 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^ only integer types and `char` are supported @@ -160,7 +160,7 @@ LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); and 5 others error[E0277]: `f32` is not a valid base type for range patterns - --> $DIR/nested.rs:29:49 + --> $DIR/nested.rs:28:49 | LL | const BAD_NESTING5: pattern_type!(f32 is 1.0 .. 2.0) = todo!(); | ^^^ only integer types and `char` are supported diff --git a/tests/ui/type/pattern_types/non_null.rs b/tests/ui/type/pattern_types/non_null.rs index e3c634da48b8e..5ce15eb5da319 100644 --- a/tests/ui/type/pattern_types/non_null.rs +++ b/tests/ui/type/pattern_types/non_null.rs @@ -3,7 +3,7 @@ //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" //@ only-64bit -#![feature(pattern_type_macro, pattern_types, rustc_attrs)] +#![feature(pattern_types, rustc_attrs)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/or_patterns.rs b/tests/ui/type/pattern_types/or_patterns.rs index d90f36983d0a0..e744025ddd673 100644 --- a/tests/ui/type/pattern_types/or_patterns.rs +++ b/tests/ui/type/pattern_types/or_patterns.rs @@ -2,13 +2,7 @@ //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" -#![feature( - pattern_type_macro, - pattern_types, - rustc_attrs, - const_trait_impl, - pattern_type_range_trait -)] +#![feature(pattern_types, rustc_attrs, const_trait_impl, pattern_type_range_trait)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr index ab757f7405eba..bda319b4be19b 100644 --- a/tests/ui/type/pattern_types/or_patterns.stderr +++ b/tests/ui/type/pattern_types/or_patterns.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/or_patterns.rs:26:24 + --> $DIR/or_patterns.rs:20:24 | LL | let _: NonNullI8 = 0; | --------- ^ expected `pattern_type!(i8 is (i8::MIN..=-1 | 1..))`, found integer @@ -10,31 +10,31 @@ LL | let _: NonNullI8 = 0; found type `{integer}` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is (i8::MIN..=-1 | 1..))` - --> $DIR/or_patterns.rs:28:24 + --> $DIR/or_patterns.rs:22:24 | LL | let _: NonNullI8 = -1; | ^^ cannot apply unary operator `-` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is (i8::MIN..=-1 | 1..))` - --> $DIR/or_patterns.rs:30:24 + --> $DIR/or_patterns.rs:24:24 | LL | let _: NonNullI8 = -128; | ^^^^ cannot apply unary operator `-` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is (i8::MIN..=-2 | 0..))` - --> $DIR/or_patterns.rs:37:26 + --> $DIR/or_patterns.rs:31:26 | LL | let _: NonNegOneI8 = -1; | ^^ cannot apply unary operator `-` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is (i8::MIN..=-2 | 0..))` - --> $DIR/or_patterns.rs:39:26 + --> $DIR/or_patterns.rs:33:26 | LL | let _: NonNegOneI8 = -2; | ^^ cannot apply unary operator `-` error[E0600]: cannot apply unary operator `-` to type `pattern_type!(i8 is (i8::MIN..=-2 | 0..))` - --> $DIR/or_patterns.rs:41:26 + --> $DIR/or_patterns.rs:35:26 | LL | let _: NonNegOneI8 = -128; | ^^^^ cannot apply unary operator `-` @@ -69,7 +69,7 @@ error: layout_of(pattern_type!(i8 is (i8::MIN..=-1 | 1..))) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/or_patterns.rs:16:1 + --> $DIR/or_patterns.rs:10:1 | LL | type NonNullI8 = pattern_type!(i8 is ..0 | 1..); | ^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ error: layout_of(pattern_type!(i8 is (i8::MIN..=-2 | 0..))) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/or_patterns.rs:20:1 + --> $DIR/or_patterns.rs:14:1 | LL | type NonNegOneI8 = pattern_type!(i8 is ..-1 | 0..); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/or_patterns_invalid.rs b/tests/ui/type/pattern_types/or_patterns_invalid.rs index a99667c5412ce..e416d5d8ae45d 100644 --- a/tests/ui/type/pattern_types/or_patterns_invalid.rs +++ b/tests/ui/type/pattern_types/or_patterns_invalid.rs @@ -1,12 +1,6 @@ //! Demonstrate some use cases of or patterns -#![feature( - pattern_type_macro, - pattern_types, - rustc_attrs, - const_trait_impl, - pattern_type_range_trait -)] +#![feature(pattern_types, rustc_attrs, const_trait_impl, pattern_type_range_trait)] use std::pat::pattern_type; @@ -26,5 +20,5 @@ fn main() { //~? ERROR: allowed are two range patterns that are directly connected let not_simple_enough_for_mvp: pattern_type!(i8 is ..0 | 1..10 | 10..) = unsafe { std::mem::transmute(0) }; - //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types + //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types } diff --git a/tests/ui/type/pattern_types/or_patterns_invalid.stderr b/tests/ui/type/pattern_types/or_patterns_invalid.stderr index a931b76b0d0be..669721dd0bab7 100644 --- a/tests/ui/type/pattern_types/or_patterns_invalid.stderr +++ b/tests/ui/type/pattern_types/or_patterns_invalid.stderr @@ -1,7 +1,7 @@ error: only non-overlapping pattern type ranges are allowed at present error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/or_patterns_invalid.rs:15:69 + --> $DIR/or_patterns_invalid.rs:9:69 | LL | let not_adjacent: pattern_type!(i8 is -127..0 | 1..) = unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | let not_adjacent: pattern_type!(i8 is -127..0 | 1..) = unsafe { std::me error: one pattern needs to end at `i8::MAX`, but was 29 instead error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/or_patterns_invalid.rs:19:71 + --> $DIR/or_patterns_invalid.rs:13:71 | LL | let not_wrapping: pattern_type!(i8 is 10..20 | 20..30) = unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let not_wrapping: pattern_type!(i8 is 10..20 | 20..30) = unsafe { std:: error: only signed integer base types are allowed for or-pattern pattern types at present error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/or_patterns_invalid.rs:23:65 + --> $DIR/or_patterns_invalid.rs:17:65 | LL | let not_signed: pattern_type!(u8 is 10.. | 0..5) = unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let not_signed: pattern_type!(u8 is 10.. | 0..5) = unsafe { std::mem::t error: the only or-pattern types allowed are two range patterns that are directly connected at their overflow site error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/or_patterns_invalid.rs:28:18 + --> $DIR/or_patterns_invalid.rs:22:18 | LL | unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/pattern_type_mismatch.rs b/tests/ui/type/pattern_types/pattern_type_mismatch.rs index 0c88f27d83686..30c368033b099 100644 --- a/tests/ui/type/pattern_types/pattern_type_mismatch.rs +++ b/tests/ui/type/pattern_types/pattern_type_mismatch.rs @@ -1,7 +1,6 @@ //! Check that pattern types patterns must be of the type of the base type #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/pattern_type_mismatch.stderr b/tests/ui/type/pattern_types/pattern_type_mismatch.stderr index 129e4b5cdc7be..bfbee74897a1b 100644 --- a/tests/ui/type/pattern_types/pattern_type_mismatch.stderr +++ b/tests/ui/type/pattern_types/pattern_type_mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern_type_mismatch.rs:8:41 + --> $DIR/pattern_type_mismatch.rs:7:41 | LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); | -- ^^^ expected `u8`, found `char` @@ -12,7 +12,7 @@ LL | const BAD_NESTING4: pattern_type!(u8 is b'a'..='a') = todo!(); | + error[E0308]: mismatched types - --> $DIR/pattern_type_mismatch.rs:8:47 + --> $DIR/pattern_type_mismatch.rs:7:47 | LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); | -- ^^^ expected `u8`, found `char` @@ -25,7 +25,7 @@ LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..=b'a') = todo!(); | + error[E0308]: mismatched types - --> $DIR/pattern_type_mismatch.rs:12:43 + --> $DIR/pattern_type_mismatch.rs:11:43 | LL | const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); | ---- ^ expected `char`, found `u8` @@ -33,7 +33,7 @@ LL | const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); | the pattern must match the type error[E0308]: mismatched types - --> $DIR/pattern_type_mismatch.rs:12:47 + --> $DIR/pattern_type_mismatch.rs:11:47 | LL | const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); | ---- ^ expected `char`, found `u8` diff --git a/tests/ui/type/pattern_types/range_patterns.rs b/tests/ui/type/pattern_types/range_patterns.rs index 1ad6469967cbc..5edf357299c98 100644 --- a/tests/ui/type/pattern_types/range_patterns.rs +++ b/tests/ui/type/pattern_types/range_patterns.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs, const_trait_impl, pattern_type_range_trait)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index a1e085ffe44ff..5ed826fa66331 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -28,7 +28,7 @@ error: layout_of(NonZero) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:10:1 + --> $DIR/range_patterns.rs:8:1 | LL | type X = std::num::NonZeroU32; | ^^^^^^ @@ -63,7 +63,7 @@ error: layout_of(pattern_type!(u32 is 1..)) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:12:1 + --> $DIR/range_patterns.rs:10:1 | LL | type Y = pattern_type!(u32 is 1..); | ^^^^^^ @@ -130,7 +130,7 @@ error: layout_of(Option) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:14:1 + --> $DIR/range_patterns.rs:12:1 | LL | type Z = Option; | ^^^^^^ @@ -197,7 +197,7 @@ error: layout_of(Option>) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:16:1 + --> $DIR/range_patterns.rs:14:1 | LL | type A = Option; | ^^^^^^ @@ -232,7 +232,7 @@ error: layout_of(NonZeroU32New) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:18:1 + --> $DIR/range_patterns.rs:16:1 | LL | struct NonZeroU32New(pattern_type!(u32 is 1..)); | ^^^^^^^^^^^^^^^^^^^^ @@ -240,19 +240,19 @@ LL | struct NonZeroU32New(pattern_type!(u32 is 1..)); error: pattern type ranges cannot wrap: 1..=0 error: the type has an unknown layout - --> $DIR/range_patterns.rs:21:1 + --> $DIR/range_patterns.rs:19:1 | LL | type EMPTY = pattern_type!(u32 is 1..1); | ^^^^^^^^^^ error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/range_patterns.rs:24:37 + --> $DIR/range_patterns.rs:22:37 | LL | type WRAP = pattern_type!(u32 is 1..0); | ^ evaluation of `WRAP::{constant#1}` failed here error: the type has an unknown layout - --> $DIR/range_patterns.rs:24:1 + --> $DIR/range_patterns.rs:22:1 | LL | type WRAP = pattern_type!(u32 is 1..0); | ^^^^^^^^^ @@ -260,7 +260,7 @@ LL | type WRAP = pattern_type!(u32 is 1..0); error: pattern type ranges cannot wrap: 5..=1 error: the type has an unknown layout - --> $DIR/range_patterns.rs:28:1 + --> $DIR/range_patterns.rs:26:1 | LL | type WRAP2 = pattern_type!(u32 is 5..2); | ^^^^^^^^^^ @@ -295,7 +295,7 @@ error: layout_of(pattern_type!(i8 is -10..=10)) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:31:1 + --> $DIR/range_patterns.rs:29:1 | LL | type SIGN = pattern_type!(i8 is -10..=10); | ^^^^^^^^^ @@ -330,7 +330,7 @@ error: layout_of(pattern_type!(i8 is i8::MIN..=0)) = Layout { repr_c: false, randomization_seed: $SEED, } - --> $DIR/range_patterns.rs:34:1 + --> $DIR/range_patterns.rs:32:1 | LL | type MIN = pattern_type!(i8 is -128..=0); | ^^^^^^^^ @@ -338,7 +338,7 @@ LL | type MIN = pattern_type!(i8 is -128..=0); error: pattern type ranges cannot wrap: 120..=-120 error: the type has an unknown layout - --> $DIR/range_patterns.rs:37:1 + --> $DIR/range_patterns.rs:35:1 | LL | type SignedWrap = pattern_type!(i8 is 120..=-120); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs b/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs index fe8feda0934e2..14107463511f3 100644 --- a/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs +++ b/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //! check that pattern types can have traits implemented for them if //! their base type is a local type. diff --git a/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr b/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr index ed2e4c0bd5f8c..f01510557588c 100644 --- a/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr +++ b/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr @@ -1,12 +1,12 @@ error[E0390]: cannot define inherent `impl` for primitive types outside of `core` - --> $DIR/range_patterns_inherent_impls.rs:12:1 + --> $DIR/range_patterns_inherent_impls.rs:10:1 | LL | impl Y { | ^^^^^^ | = help: consider moving this inherent impl into `core` if possible help: alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items - --> $DIR/range_patterns_inherent_impls.rs:14:5 + --> $DIR/range_patterns_inherent_impls.rs:12:5 | LL | fn foo() {} | ^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls.rs b/tests/ui/type/pattern_types/range_patterns_trait_impls.rs index 1731cd470fe2c..e7c5479e43d0c 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls.rs +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //! check that pattern types can have local traits //! implemented for them. diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs b/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs index 90f80a2f34645..d367bd174f3ef 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //! check that pattern types can have local traits //! implemented for them. diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr b/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr index 4517c7e910f4e..2f372751277a2 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/range_patterns_trait_impls2.rs:12:1 + --> $DIR/range_patterns_trait_impls2.rs:10:1 | LL | impl Eq for Y {} | ^^^^^^^^^^^^- diff --git a/tests/ui/type/pattern_types/range_patterns_unusable.rs b/tests/ui/type/pattern_types/range_patterns_unusable.rs index 98f13ca0bc0bb..d023541d12e48 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable.rs +++ b/tests/ui/type/pattern_types/range_patterns_unusable.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //! Some practical niche checks. diff --git a/tests/ui/type/pattern_types/range_patterns_unusable.stderr b/tests/ui/type/pattern_types/range_patterns_unusable.stderr index 5c61f6347bbfc..15e83bfad5228 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable.stderr +++ b/tests/ui/type/pattern_types/range_patterns_unusable.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/range_patterns_unusable.rs:13:35 + --> $DIR/range_patterns_unusable.rs:11:35 | LL | let _: Option = unsafe { std::mem::transmute(z) }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_unusable_math.rs b/tests/ui/type/pattern_types/range_patterns_unusable_math.rs index 71becd28d1cac..f44ac1e7be392 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable_math.rs +++ b/tests/ui/type/pattern_types/range_patterns_unusable_math.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //! check that pattern types don't have an `Add` impl. diff --git a/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr b/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr index b55031dc3cf8b..5dab944cfe2de 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr +++ b/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `u32` to `pattern_type!(u32 is 1..)` - --> $DIR/range_patterns_unusable_math.rs:14:15 + --> $DIR/range_patterns_unusable_math.rs:12:15 | LL | let x = x + 1_u32; | - ^ ----- u32 diff --git a/tests/ui/type/pattern_types/range_patterns_usage.rs b/tests/ui/type/pattern_types/range_patterns_usage.rs index 0ecbdcaa0f7a3..5d09785e8faa8 100644 --- a/tests/ui/type/pattern_types/range_patterns_usage.rs +++ b/tests/ui/type/pattern_types/range_patterns_usage.rs @@ -1,6 +1,4 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(pattern_type_macro)] -#![allow(incomplete_features)] //@ check-pass //! check that pattern types can actually be part of code that compiles successfully. diff --git a/tests/ui/type/pattern_types/reverse_range.rs b/tests/ui/type/pattern_types/reverse_range.rs index 34c931e4e965a..8d0fd8ca1b628 100644 --- a/tests/ui/type/pattern_types/reverse_range.rs +++ b/tests/ui/type/pattern_types/reverse_range.rs @@ -1,6 +1,5 @@ //! Check that the range start must be smaller than the range end #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/reverse_range.stderr b/tests/ui/type/pattern_types/reverse_range.stderr index 6e6e34409a39e..bcaf19790ba38 100644 --- a/tests/ui/type/pattern_types/reverse_range.stderr +++ b/tests/ui/type/pattern_types/reverse_range.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation panicked: exclusive range end at minimum value of type - --> $DIR/reverse_range.rs:7:36 + --> $DIR/reverse_range.rs:6:36 | LL | const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) }; | ^ evaluation of `NONE::{constant#1}` failed here diff --git a/tests/ui/type/pattern_types/signed_ranges.rs b/tests/ui/type/pattern_types/signed_ranges.rs index 3725fbda7292a..e18c0299cbba6 100644 --- a/tests/ui/type/pattern_types/signed_ranges.rs +++ b/tests/ui/type/pattern_types/signed_ranges.rs @@ -1,5 +1,4 @@ #![feature(pattern_types)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/signed_ranges.stderr b/tests/ui/type/pattern_types/signed_ranges.stderr index 79bf8501b639f..66df48363af65 100644 --- a/tests/ui/type/pattern_types/signed_ranges.stderr +++ b/tests/ui/type/pattern_types/signed_ranges.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `u8: Neg` is not satisfied - --> $DIR/signed_ranges.rs:14:9 + --> $DIR/signed_ranges.rs:13:9 | LL | -10..253 => {} | ^^^ the trait `Neg` is not implemented for `u8` @@ -16,13 +16,13 @@ LL | -10..253 => {} and 12 others error[E0277]: the trait bound `char: Neg` is not satisfied - --> $DIR/signed_ranges.rs:20:9 + --> $DIR/signed_ranges.rs:19:9 | LL | -'\0'..'a' => {} | ^^^^^ the trait `Neg` is not implemented for `char` error[E0600]: cannot apply unary operator `-` to type `u32` - --> $DIR/signed_ranges.rs:6:34 + --> $DIR/signed_ranges.rs:5:34 | LL | type Sign = pattern_type!(u32 is -10..); | ^^^ cannot apply unary operator `-` @@ -30,7 +30,7 @@ LL | type Sign = pattern_type!(u32 is -10..); = note: unsigned values cannot be negated error[E0600]: cannot apply unary operator `-` to type `char` - --> $DIR/signed_ranges.rs:9:41 + --> $DIR/signed_ranges.rs:8:41 | LL | type SignedChar = pattern_type!(char is -'A'..); | ^^^^ cannot apply unary operator `-` diff --git a/tests/ui/type/pattern_types/transmute.rs b/tests/ui/type/pattern_types/transmute.rs index 4e686245f9375..77f99253543ca 100644 --- a/tests/ui/type/pattern_types/transmute.rs +++ b/tests/ui/type/pattern_types/transmute.rs @@ -1,7 +1,7 @@ //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(pattern_types, pattern_type_macro, generic_pattern_types)] +#![feature(pattern_types, generic_pattern_types)] #![expect(incomplete_features)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/unimplemented_pat.rs b/tests/ui/type/pattern_types/unimplemented_pat.rs index 44851ec1a1049..7e57e1f7ff8d6 100644 --- a/tests/ui/type/pattern_types/unimplemented_pat.rs +++ b/tests/ui/type/pattern_types/unimplemented_pat.rs @@ -1,7 +1,7 @@ //! This test ensures we do not ICE for unimplemented //! patterns even if the feature gate is enabled. -#![feature(pattern_type_macro, pattern_types)] +#![feature(pattern_types)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/unsize.rs b/tests/ui/type/pattern_types/unsize.rs index 1020dd8c21544..18d9a52a9195e 100644 --- a/tests/ui/type/pattern_types/unsize.rs +++ b/tests/ui/type/pattern_types/unsize.rs @@ -2,7 +2,7 @@ //@ check-pass -#![feature(pattern_type_macro, pattern_types)] +#![feature(pattern_types)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/validity.rs b/tests/ui/type/pattern_types/validity.rs index f4c62dc6712e9..cbabe06c312ce 100644 --- a/tests/ui/type/pattern_types/validity.rs +++ b/tests/ui/type/pattern_types/validity.rs @@ -3,7 +3,6 @@ //@ normalize-stderr: "([[:xdigit:]]{2}\s){4,8}\s+│\s.{4,8}" -> "HEX_DUMP" #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] -#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr index 7cfa6b3400a41..9ddc07ce89cee 100644 --- a/tests/ui/type/pattern_types/validity.stderr +++ b/tests/ui/type/pattern_types/validity.stderr @@ -1,5 +1,5 @@ error[E0080]: constructing invalid value of type pattern_type!(u32 is 1..): encountered 0, but expected something greater or equal to 1 - --> $DIR/validity.rs:10:1 + --> $DIR/validity.rs:9:1 | LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -10,7 +10,7 @@ LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; } error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory - --> $DIR/validity.rs:13:1 + --> $DIR/validity.rs:12:1 | LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINIT` failed here @@ -20,7 +20,7 @@ LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = } error[E0080]: unable to turn pointer into integer - --> $DIR/validity.rs:17:1 + --> $DIR/validity.rs:16:1 | LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_PTR` failed here @@ -29,7 +29,7 @@ LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(& = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: constructing invalid value of type (pattern_type!(u32 is 1..), u32): at .0, encountered 0, but expected something greater or equal to 1 - --> $DIR/validity.rs:20:1 + --> $DIR/validity.rs:19:1 | LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -40,7 +40,7 @@ LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem: } error[E0080]: constructing invalid value of type Foo: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/validity.rs:26:1 + --> $DIR/validity.rs:25:1 | LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -51,7 +51,7 @@ LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); } error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory - --> $DIR/validity.rs:29:1 + --> $DIR/validity.rs:28:1 | LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `CHAR_UNINIT` failed here @@ -61,7 +61,7 @@ LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = } error[E0080]: constructing invalid value of type pattern_type!(char is 'A'..='Y'): encountered 97, but expected something in the range 65..=89 - --> $DIR/validity.rs:33:1 + --> $DIR/validity.rs:32:1 | LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -72,7 +72,7 @@ LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::tr } error[E0080]: constructing invalid value of type pattern_type!(char is 'A'..='Y'): encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) - --> $DIR/validity.rs:36:1 + --> $DIR/validity.rs:35:1 | LL | const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index 3551d40dffbfc..0bd7aca6a007b 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -21,7 +21,6 @@ #![feature(more_qualified_paths)] #![feature(never_patterns)] #![feature(pattern_types)] -#![feature(pattern_type_macro)] #![feature(prelude_import)] #![feature(specialization)] #![feature(trace_macros)] @@ -632,7 +631,7 @@ mod types { /*! FIXME: todo */ } /// TyKind::Pat - fn ty_pat() { let _: u32 is const 1..; } + fn ty_pat() { let _: k#pattern_type(u32 is const 1..); } } mod visibilities { /// VisibilityKind::Public diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr index 276bc5b5d2573..5ca4b080a95e5 100644 --- a/tests/ui/unpretty/exhaustive.hir.stderr +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -1,17 +1,17 @@ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:210:9 + --> $DIR/exhaustive.rs:209:9 | LL | static || value; | ^^^^^^^^^ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:211:9 + --> $DIR/exhaustive.rs:210:9 | LL | static move || value; | ^^^^^^^^^^^^^^ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/exhaustive.rs:240:13 + --> $DIR/exhaustive.rs:239:13 | LL | fn expr_await() { | --------------- this is not `async` @@ -20,19 +20,19 @@ LL | fut.await; | ^^^^^ only allowed inside `async` functions and blocks error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/exhaustive.rs:291:9 + --> $DIR/exhaustive.rs:290:9 | LL | _; | ^ `_` not allowed here error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:301:9 + --> $DIR/exhaustive.rs:300:9 | LL | x::(); | ^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:302:9 + --> $DIR/exhaustive.rs:301:9 | LL | x::(T, T) -> T; | ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses @@ -44,31 +44,31 @@ LL + x:: -> T; | error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:303:9 + --> $DIR/exhaustive.rs:302:9 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:303:26 + --> $DIR/exhaustive.rs:302:26 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:306:9 + --> $DIR/exhaustive.rs:305:9 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:306:19 + --> $DIR/exhaustive.rs:305:19 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^^^ only `Fn` traits may use parentheses error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks - --> $DIR/exhaustive.rs:393:9 + --> $DIR/exhaustive.rs:392:9 | LL | yield; | ^^^^^ @@ -79,7 +79,7 @@ LL | #[coroutine] fn expr_yield() { | ++++++++++++ error[E0703]: invalid ABI: found `C++` - --> $DIR/exhaustive.rs:473:23 + --> $DIR/exhaustive.rs:472:23 | LL | unsafe extern "C++" {} | ^^^^^ invalid ABI @@ -87,7 +87,7 @@ LL | unsafe extern "C++" {} = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions error: `..` patterns are not allowed here - --> $DIR/exhaustive.rs:675:13 + --> $DIR/exhaustive.rs:674:13 | LL | let ..; | ^^ @@ -95,13 +95,13 @@ LL | let ..; = note: only allowed in tuple, tuple struct, and slice patterns error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:790:16 + --> $DIR/exhaustive.rs:789:16 | LL | let _: T() -> !; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:804:16 + --> $DIR/exhaustive.rs:803:16 | LL | let _: impl Send; | ^^^^^^^^^ @@ -112,7 +112,7 @@ LL | let _: impl Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:805:16 + --> $DIR/exhaustive.rs:804:16 | LL | let _: impl Send + 'static; | ^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ LL | let _: impl Send + 'static; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:806:16 + --> $DIR/exhaustive.rs:805:16 | LL | let _: impl 'static + Send; | ^^^^^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | let _: impl 'static + Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:807:16 + --> $DIR/exhaustive.rs:806:16 | LL | let _: impl ?Sized; | ^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | let _: impl ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:808:16 + --> $DIR/exhaustive.rs:807:16 | LL | let _: impl [const] Clone; | ^^^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ LL | let _: impl [const] Clone; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:809:16 + --> $DIR/exhaustive.rs:808:16 | LL | let _: impl for<'a> Send; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 6af4d3b5b81de..4726e9aa762e7 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -1,9 +1,8 @@ #![attr = Feature([auto_traits#0, internal_syntax#0, const_trait_impl#0, coroutines#0, decl_macro#0, deref_patterns#0, explicit_tail_calls#0, forced_keywords#0, gen_blocks#0, more_qualified_paths#0, never_patterns#0, -pattern_types#0, pattern_type_macro#0, prelude_import#0, specialization#0, -trace_macros#0, trait_alias#0, try_blocks#0, try_blocks_heterogeneous#0, -yeet_expr#0])] +pattern_types#0, prelude_import#0, specialization#0, trace_macros#0, +trait_alias#0, try_blocks#0, try_blocks_heterogeneous#0, yeet_expr#0])] #![attr = LintCheck([LintCheck {lint_name: LintName { tool: None, name: "incomplete_features" }, kind: Allow}, LintCheck {lint_name: LintName { tool: None, name: "unused_attributes" }, diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 15f684fc3dd72..36cc724351a64 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -20,7 +20,6 @@ #![feature(more_qualified_paths)] #![feature(never_patterns)] #![feature(pattern_types)] -#![feature(pattern_type_macro)] #![feature(prelude_import)] #![feature(specialization)] #![feature(trace_macros)] @@ -846,7 +845,7 @@ mod types { /// TyKind::Pat fn ty_pat() { - let _: core::pattern_type!(u32 is 1..); + let _: pattern_type!(u32 is 1..); } } From 8f7bf49027808e4b050e193258c9eda39745ddf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Thu, 5 Nov 2026 00:49:56 +0100 Subject: [PATCH 3/3] Turn `view_type` into a macro 2.0 that expands to `k#view_type(...)` This also means that it's now available under `core::view` instead of `core` directly. This makes it consistent with the `std` re-export which is only available under `std::view` and not under `std` directly. Moreover, drop library feature `view_type_macro` and demote language feature `view_types` to a library feature. This is nice because it means `std::view::view_type` is no longer unnecessarily gated behind two (!) feature gates. --- compiler/rustc_ast_passes/src/feature_gate.rs | 4 -- compiler/rustc_ast_pretty/src/pprust/state.rs | 6 +++ compiler/rustc_ast_pretty/src/pprust/tests.rs | 2 +- compiler/rustc_builtin_macros/src/lib.rs | 2 - .../rustc_builtin_macros/src/view_type.rs | 47 ------------------- compiler/rustc_feature/src/unstable.rs | 2 - compiler/rustc_parse/src/parser/mod.rs | 4 +- compiler/rustc_parse/src/parser/ty.rs | 15 ++++++ compiler/rustc_span/src/symbol.rs | 2 +- library/core/src/lib.rs | 2 +- library/core/src/view.rs | 14 +++--- library/std/src/lib.rs | 2 +- library/std/src/view.rs | 2 +- tests/ui/view-types/auxiliary/hygiene.rs | 2 +- tests/ui/view-types/duplicate_field.rs | 3 +- tests/ui/view-types/duplicate_field.stderr | 8 ++-- .../ui/view-types/feature-gate-view-types.rs | 4 +- .../view-types/feature-gate-view-types.stderr | 8 ++-- tests/ui/view-types/hygiene.rs | 2 +- tests/ui/view-types/must-be-struct.rs | 3 +- tests/ui/view-types/must-be-struct.stderr | 6 +-- tests/ui/view-types/must-exist.rs | 3 +- tests/ui/view-types/must-exist.stderr | 4 +- tests/ui/view-types/must-restrict.rs | 2 +- tests/ui/view-types/syntax-errors.rs | 3 +- tests/ui/view-types/syntax-errors.stderr | 20 ++++---- tests/ui/view-types/tuple-structs.rs | 2 +- 27 files changed, 67 insertions(+), 107 deletions(-) delete mode 100644 compiler/rustc_builtin_macros/src/view_type.rs diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 02adcc2296610..89105722f6c8e 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -241,9 +241,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Function pointers cannot be `const` self.check_late_bound_lifetime_defs(&fn_ptr_ty.generic_params); } - ast::TyKind::View(..) => { - gate!(self, view_types, ty.span, "view types are unstable"); - } _ => {} } visit::walk_ty(self, ty) @@ -466,7 +463,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { gate_all!(unnamed_enum_variants, "unnamed enum variants are experimental"); gate_all!(unsafe_binders, "unsafe binder types are experimental"); gate_all!(unsafe_fields, "`unsafe` fields are experimental"); - gate_all!(view_types, "view types are experimental"); gate_all!(where_clause_attrs, "attributes in `where` clause are unstable"); gate_all!(yeet_expr, "`do yeet` expression is experimental"); // tidy-alphabetical-end diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index a5dbaf81376c1..36096cb09eb1b 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1437,9 +1437,12 @@ impl<'a> State<'a> { self.word("..."); } ast::TyKind::Pat(ty, pat) => { + self.word("k#pattern_type"); + self.popen(); self.print_type(ty); self.word(" is "); self.print_ty_pat(pat); + self.pclose(); } ast::TyKind::FieldOf(ty, variant, field) => { self.word("k#field_of"); @@ -1459,8 +1462,11 @@ impl<'a> State<'a> { self.pclose(); } ast::TyKind::View(ty, fields) => { + self.word("k#view_type"); + self.popen(); self.print_type(ty); self.print_view(fields); + self.pclose(); } ast::TyKind::GcaMacro(expr) => { self.word_nbsp("core::gca!"); diff --git a/compiler/rustc_ast_pretty/src/pprust/tests.rs b/compiler/rustc_ast_pretty/src/pprust/tests.rs index 43bb68216d929..1a5a518ee41e0 100644 --- a/compiler/rustc_ast_pretty/src/pprust/tests.rs +++ b/compiler/rustc_ast_pretty/src/pprust/tests.rs @@ -80,6 +80,6 @@ fn test_field_view() { }; let ty_str = ty_to_string(&ty); - assert_eq!(ty_str, "(/*DUMMY*/).{ milhouse, apu }"); + assert_eq!(ty_str, "k#view_type((/*DUMMY*/).{ milhouse, apu })"); }); } diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index f801dc5917d8a..9a0e28609bf47 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -50,7 +50,6 @@ mod source_util; mod test; mod test_binder_constraints; mod trace_macros; -mod view_type; pub mod asm; pub mod cmdline_attrs; @@ -104,7 +103,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { test_binder_constraints: test_binder_constraints::expand, trace_macros: trace_macros::expand_trace_macros, unreachable: edition_panic::expand_unreachable, - view_type: view_type::expand, // tidy-alphabetical-end } diff --git a/compiler/rustc_builtin_macros/src/view_type.rs b/compiler/rustc_builtin_macros/src/view_type.rs deleted file mode 100644 index 69bd8f2727fc3..0000000000000 --- a/compiler/rustc_builtin_macros/src/view_type.rs +++ /dev/null @@ -1,47 +0,0 @@ -use rustc_ast::token::TokenKind; -use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{Ty, ast}; -use rustc_errors::PResult; -use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; -use rustc_parse::parser::{ExpTokenPair, TokenType}; -use rustc_span::{Ident, Span}; -use thin_vec::ThinVec; - -pub(crate) fn expand<'cx>( - cx: &'cx mut ExtCtxt<'_>, - sp: Span, - tts: TokenStream, -) -> MacroExpanderResult<'cx> { - let (ty, pat) = match parse_view_ty(cx, tts) { - Ok(parsed) => parsed, - Err(err) => { - return ExpandResult::Ready(DummyResult::any(sp, err.emit_err())); - } - }; - - ExpandResult::Ready(base::MacEager::ty(cx.ty(sp, ast::TyKind::View(ty, pat)))) -} - -fn parse_view_ty<'a>( - cx: &mut ExtCtxt<'a>, - stream: TokenStream, -) -> PResult<'a, (Box, ThinVec)> { - let mut parser = cx.new_parser_from_tts(stream); - - let ty = parser.parse_ty()?; - - parser.expect(ExpTokenPair { tok: TokenKind::Dot, token_type: TokenType::Dot })?; - - let fields = match parser.parse_delim_comma_seq( - ExpTokenPair { tok: TokenKind::OpenBrace, token_type: TokenType::OpenBrace }, - ExpTokenPair { tok: TokenKind::CloseBrace, token_type: TokenType::CloseBrace }, - |p| p.parse_field_name(), - ) { - Ok((fields, _)) => fields, - Err(diag) => { - return Err(diag); - } - }; - - Ok((ty, fields)) -} diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index bd203ccf6e218..e8f7400af076e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -778,8 +778,6 @@ declare_features! ( (internal, unsized_fn_params, "1.49.0", Some(48055)), /// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute. (unstable, used_with_arg, "1.60.0", Some(93798)), - /// Allows view types. - (unstable, view_types, "1.97.0", Some(155938)), /// Target features on wasm. (unstable, wasm_target_feature, "1.30.0", Some(150260)), /// Allows use of attributes in `where` clauses. diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index a89fd9b6298f3..10f4d73e3e4cd 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1101,7 +1101,7 @@ impl<'a> Parser<'a> { /// Parses a comma-separated sequence, including both delimiters. /// The function `f` must consume tokens until reaching the next separator or /// closing bracket. - pub fn parse_delim_comma_seq( + fn parse_delim_comma_seq( &mut self, open: ExpTokenPair, close: ExpTokenPair, @@ -1351,7 +1351,7 @@ impl<'a> Parser<'a> { /// ```enbf /// FieldName = IntLit | Ident /// ``` - pub fn parse_field_name(&mut self) -> PResult<'a, Ident> { + fn parse_field_name(&mut self) -> PResult<'a, Ident> { if let token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) = self.token.kind { if let Some(suffix) = suffix { diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 029aab9e0e601..f09faad96e16a 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -425,6 +425,8 @@ impl<'a> Parser<'a> { self.parse_ty_field_of(lo)? } else if self.eat_forced_keyword_noexpect(kw::PatternType) { self.parse_pat_ty(lo)? + } else if self.eat_forced_keyword_noexpect(kw::ViewType) { + self.parse_view_ty(lo)? } else { let msg = format!("expected type, found {}", super::token_descr(&self.token)); let mut err = self.dcx().struct_span_err(lo, msg); @@ -923,6 +925,19 @@ impl<'a> Parser<'a> { ast::TyPat { id: DUMMY_NODE_ID, kind, span } } + fn parse_view_ty(&mut self, lo: Span) -> PResult<'a, ast::TyKind> { + self.expect(exp!(OpenParen))?; + let ty = self.parse_ty()?; + self.expect(exp!(Dot))?; + let (fields, _) = self + .parse_delim_comma_seq(exp!(OpenBrace), exp!(CloseBrace), |p| p.parse_field_name())?; + self.expect(exp!(CloseParen))?; + + self.psess.gated_spans.gate(sym::internal_syntax, lo.to(self.prev_token.span)); + + Ok(ast::TyKind::View(ty, fields)) + } + /// Parses a function pointer type (`TyKind::FnPtr`). /// ```ignore (illustrative) /// [unsafe] [extern "ABI"] fn (S) -> T diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 6b5299d7eb1be..99192f89c4d01 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -141,6 +141,7 @@ symbols! { TypeAscribe: "type_ascribe", Union: "union", UnwrapBinder: "unwrap_binder", + ViewType: "view_type", WrapBinder: "wrap_binder", Yeet: "yeet", // tidy-alphabetical-end @@ -2387,7 +2388,6 @@ symbols! { vgpr384, vgpr512, vgpr1024, - view_type, view_types, vis, visible_private_types, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 00c7c3c824cfa..186f2ab1002db 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -350,7 +350,7 @@ mod bool; mod escape; mod tuple; mod unit; -#[unstable(feature = "view_type_macro", issue = "155938")] +#[unstable(feature = "view_types", issue = "155938")] pub mod view; #[stable(feature = "core_primitive", since = "1.43.0")] diff --git a/library/core/src/view.rs b/library/core/src/view.rs index 68eca3f3598d2..c68382b2effc9 100644 --- a/library/core/src/view.rs +++ b/library/core/src/view.rs @@ -2,7 +2,7 @@ /// Creates a view type. /// ``` -/// #![feature(view_types, view_type_macro)] +/// #![feature(view_types)] // /// struct Foo { /// bar: usize, @@ -11,11 +11,9 @@ /// /// type FooBar = std::view::view_type!(Foo.{ bar }); /// ``` -#[macro_export] -#[rustc_builtin_macro(view_type)] -#[unstable(feature = "view_type_macro", issue = "155938")] -macro_rules! view_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +#[unstable(feature = "view_types", issue = "155938")] +#[diagnostic::opaque] +pub macro view_type($($arg:tt)*) { + k#view_type($($arg)*) } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 0c3d29324c9ae..6b0d32f3ba5f2 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -649,7 +649,7 @@ pub mod process; pub mod random; pub mod sync; pub mod time; -#[unstable(feature = "view_type_macro", issue = "155938")] +#[unstable(feature = "view_types", issue = "155938")] pub mod view; // Pull in `std_float` crate into std. The contents of diff --git a/library/std/src/view.rs b/library/std/src/view.rs index 5806cf27c2cc8..3e0e7d1d1038a 100644 --- a/library/std/src/view.rs +++ b/library/std/src/view.rs @@ -1,3 +1,3 @@ //! Helper module for exporting the `view_types` macro. -pub use core::view_type; +pub use core::view::view_type; diff --git a/tests/ui/view-types/auxiliary/hygiene.rs b/tests/ui/view-types/auxiliary/hygiene.rs index cf842b56e6970..3b022299733c9 100644 --- a/tests/ui/view-types/auxiliary/hygiene.rs +++ b/tests/ui/view-types/auxiliary/hygiene.rs @@ -1,6 +1,6 @@ //@ edition:2015 -#![feature(view_types, view_type_macro)] +#![feature(view_types)] pub use std::view::view_type; diff --git a/tests/ui/view-types/duplicate_field.rs b/tests/ui/view-types/duplicate_field.rs index b45580510b6cb..4b3e0ca0850e0 100644 --- a/tests/ui/view-types/duplicate_field.rs +++ b/tests/ui/view-types/duplicate_field.rs @@ -1,5 +1,4 @@ -#![feature(view_types, view_type_macro)] -#![allow(unused)] +#![feature(view_types)] use std::view::view_type; diff --git a/tests/ui/view-types/duplicate_field.stderr b/tests/ui/view-types/duplicate_field.stderr index f0162f6e0a67d..c974b0ead238a 100644 --- a/tests/ui/view-types/duplicate_field.stderr +++ b/tests/ui/view-types/duplicate_field.stderr @@ -1,5 +1,5 @@ error: field `bar` is already part of the view - --> $DIR/duplicate_field.rs:13:38 + --> $DIR/duplicate_field.rs:12:38 | LL | _foo: &mut view_type!(Foo.{ bar, bar }), | --- ^^^ @@ -7,7 +7,7 @@ LL | _foo: &mut view_type!(Foo.{ bar, bar }), | field `bar` is declared as viewed here error: field `0` is already part of the view - --> $DIR/duplicate_field.rs:15:38 + --> $DIR/duplicate_field.rs:14:38 | LL | _pair: &mut view_type!(Pair.{ 0, 0 }), | - ^ @@ -15,7 +15,7 @@ LL | _pair: &mut view_type!(Pair.{ 0, 0 }), | field `0` is declared as viewed here error: field `bar` is already part of the view - --> $DIR/duplicate_field.rs:21:44 + --> $DIR/duplicate_field.rs:20:44 | LL | fn f(self: &mut view_type!(Self.{ bar, bar })) {} | --- ^^^ @@ -23,7 +23,7 @@ LL | fn f(self: &mut view_type!(Self.{ bar, bar })) {} | field `bar` is declared as viewed here error: field `0` is already part of the view - --> $DIR/duplicate_field.rs:26:42 + --> $DIR/duplicate_field.rs:25:42 | LL | fn f(self: &mut view_type!(Self.{ 0, 0 })) {} | - ^ diff --git a/tests/ui/view-types/feature-gate-view-types.rs b/tests/ui/view-types/feature-gate-view-types.rs index 961f96e18bb99..d30c737c130c7 100644 --- a/tests/ui/view-types/feature-gate-view-types.rs +++ b/tests/ui/view-types/feature-gate-view-types.rs @@ -8,6 +8,6 @@ struct Foo { } type FooBar = view_type!(Foo.{ bar }); -//~^ ERROR use of unstable library feature `view_type_macro` +//~^ ERROR use of unstable library feature `view_types` type FooBaz = view_type!(Foo.{ baz }); -//~^ ERROR use of unstable library feature `view_type_macro` +//~^ ERROR use of unstable library feature `view_types` diff --git a/tests/ui/view-types/feature-gate-view-types.stderr b/tests/ui/view-types/feature-gate-view-types.stderr index 407bf343ca13b..bda3aebf2b744 100644 --- a/tests/ui/view-types/feature-gate-view-types.stderr +++ b/tests/ui/view-types/feature-gate-view-types.stderr @@ -1,21 +1,21 @@ -error[E0658]: use of unstable library feature `view_type_macro` +error[E0658]: use of unstable library feature `view_types` --> $DIR/feature-gate-view-types.rs:10:15 | LL | type FooBar = view_type!(Foo.{ bar }); | ^^^^^^^^^ | = note: see issue #155938 for more information - = help: add `#![feature(view_type_macro)]` to the crate attributes to enable + = help: add `#![feature(view_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `view_type_macro` +error[E0658]: use of unstable library feature `view_types` --> $DIR/feature-gate-view-types.rs:12:15 | LL | type FooBaz = view_type!(Foo.{ baz }); | ^^^^^^^^^ | = note: see issue #155938 for more information - = help: add `#![feature(view_type_macro)]` to the crate attributes to enable + = help: add `#![feature(view_types)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 2 previous errors diff --git a/tests/ui/view-types/hygiene.rs b/tests/ui/view-types/hygiene.rs index 15a9f7f228f90..20d184e184697 100644 --- a/tests/ui/view-types/hygiene.rs +++ b/tests/ui/view-types/hygiene.rs @@ -1,7 +1,7 @@ //@ run-pass //@ aux-build: hygiene.rs -#![feature(view_types, view_type_macro, decl_macro)] +#![feature(view_types, decl_macro)] #![allow(unused)] extern crate hygiene; diff --git a/tests/ui/view-types/must-be-struct.rs b/tests/ui/view-types/must-be-struct.rs index fb30ef1234cc5..2ee8fb6430f13 100644 --- a/tests/ui/view-types/must-be-struct.rs +++ b/tests/ui/view-types/must-be-struct.rs @@ -1,5 +1,4 @@ -#![feature(view_types, view_type_macro)] -#![allow(unused)] +#![feature(view_types)] use std::view::view_type; diff --git a/tests/ui/view-types/must-be-struct.stderr b/tests/ui/view-types/must-be-struct.stderr index 3d47e4903af6c..51b6f0bec8ebe 100644 --- a/tests/ui/view-types/must-be-struct.stderr +++ b/tests/ui/view-types/must-be-struct.stderr @@ -1,17 +1,17 @@ error: only structs can be viewed - --> $DIR/must-be-struct.rs:11:9 + --> $DIR/must-be-struct.rs:10:9 | LL | fn f(_: view_type!(Foo.{})) {} | ^^^^^^^^^^^^^^^^^^ `Foo` is an enum, it cannot be viewed error: only structs can be viewed - --> $DIR/must-be-struct.rs:13:9 + --> $DIR/must-be-struct.rs:12:9 | LL | fn g(_: view_type!(u8.{})) {} | ^^^^^^^^^^^^^^^^^ type `u8` cannot be viewed error: only structs can be viewed - --> $DIR/must-be-struct.rs:15:9 + --> $DIR/must-be-struct.rs:14:9 | LL | fn h(_: view_type!(char.{})) {} | ^^^^^^^^^^^^^^^^^^^ type `char` cannot be viewed diff --git a/tests/ui/view-types/must-exist.rs b/tests/ui/view-types/must-exist.rs index efb43eb509e9c..da912c1ee9749 100644 --- a/tests/ui/view-types/must-exist.rs +++ b/tests/ui/view-types/must-exist.rs @@ -1,5 +1,4 @@ -#![feature(view_types, view_type_macro)] -#![allow(unused)] +#![feature(view_types)] use std::view::view_type; diff --git a/tests/ui/view-types/must-exist.stderr b/tests/ui/view-types/must-exist.stderr index a775ad84a7edf..d977f060754d2 100644 --- a/tests/ui/view-types/must-exist.stderr +++ b/tests/ui/view-types/must-exist.stderr @@ -1,11 +1,11 @@ error[E0609]: no field `bar` on type `S` - --> $DIR/must-exist.rs:10:24 + --> $DIR/must-exist.rs:9:24 | LL | fn f(_: view_type!(S.{ bar })) {} | ^^^ error[E0609]: no field `bar` on type `S` - --> $DIR/must-exist.rs:12:29 + --> $DIR/must-exist.rs:11:29 | LL | fn g(_: view_type!(S.{ foo, bar })) {} | ^^^ diff --git a/tests/ui/view-types/must-restrict.rs b/tests/ui/view-types/must-restrict.rs index c0e1f5115d27c..a523f07e9aadd 100644 --- a/tests/ui/view-types/must-restrict.rs +++ b/tests/ui/view-types/must-restrict.rs @@ -1,7 +1,7 @@ //@ known-bug: unknown //@ run-pass -#![feature(view_types, view_type_macro)] +#![feature(view_types)] #![allow(unused)] use std::view::view_type; diff --git a/tests/ui/view-types/syntax-errors.rs b/tests/ui/view-types/syntax-errors.rs index 18ccb859d549e..84bcb977827e0 100644 --- a/tests/ui/view-types/syntax-errors.rs +++ b/tests/ui/view-types/syntax-errors.rs @@ -1,5 +1,4 @@ -#![feature(view_types, view_type_macro)] -#![allow(unused)] +#![feature(view_types)] use std::view::view_type; diff --git a/tests/ui/view-types/syntax-errors.stderr b/tests/ui/view-types/syntax-errors.stderr index 1c1e5fdafae1a..479151b267e2e 100644 --- a/tests/ui/view-types/syntax-errors.stderr +++ b/tests/ui/view-types/syntax-errors.stderr @@ -1,17 +1,17 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/syntax-errors.rs:12:49 + --> $DIR/syntax-errors.rs:11:49 | LL | fn not_a_field(self: &mut view_type!(Self.{ _ }), _: &mut view_type!(Foo.{ _ })) {} | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/syntax-errors.rs:12:80 + --> $DIR/syntax-errors.rs:11:80 | LL | fn not_a_field(self: &mut view_type!(Self.{ _ }), _: &mut view_type!(Foo.{ _ })) {} | ^ expected identifier, found reserved identifier error: expected identifier, found keyword `where` - --> $DIR/syntax-errors.rs:18:44 + --> $DIR/syntax-errors.rs:17:44 | LL | fn keyword(self: &mut view_type!(Foo.{ where }), _: &mut view_type!(Foo.{ for })) {} | ^^^^^ expected identifier, found keyword @@ -22,7 +22,7 @@ LL | fn keyword(self: &mut view_type!(Foo.{ r#where }), _: &mut view_type!(F | ++ error: expected identifier, found keyword `for` - --> $DIR/syntax-errors.rs:18:79 + --> $DIR/syntax-errors.rs:17:79 | LL | fn keyword(self: &mut view_type!(Foo.{ where }), _: &mut view_type!(Foo.{ for })) {} | ^^^ expected identifier, found keyword @@ -33,7 +33,7 @@ LL | fn keyword(self: &mut view_type!(Foo.{ where }), _: &mut view_type!(Foo | ++ error: expected one of `,` or `}`, found `baz` - --> $DIR/syntax-errors.rs:24:49 + --> $DIR/syntax-errors.rs:23:49 | LL | fn no_comma(self: &mut view_type!(Foo.{ bar baz }), _: &mut view_type!(Foo.{ bar baz })) {} | -^^^ expected one of `,` or `}` @@ -41,7 +41,7 @@ LL | fn no_comma(self: &mut view_type!(Foo.{ bar baz }), _: &mut view_type!( | help: missing `,` error: expected one of `,` or `}`, found `baz` - --> $DIR/syntax-errors.rs:24:86 + --> $DIR/syntax-errors.rs:23:86 | LL | fn no_comma(self: &mut view_type!(Foo.{ bar baz }), _: &mut view_type!(Foo.{ bar baz })) {} | -^^^ expected one of `,` or `}` @@ -49,25 +49,25 @@ LL | fn no_comma(self: &mut view_type!(Foo.{ bar baz }), _: &mut view_type!( | help: missing `,` error[E0609]: no field `_` on type `Foo` - --> $DIR/syntax-errors.rs:12:49 + --> $DIR/syntax-errors.rs:11:49 | LL | fn not_a_field(self: &mut view_type!(Self.{ _ }), _: &mut view_type!(Foo.{ _ })) {} | ^ error[E0609]: no field `_` on type `Foo` - --> $DIR/syntax-errors.rs:12:80 + --> $DIR/syntax-errors.rs:11:80 | LL | fn not_a_field(self: &mut view_type!(Self.{ _ }), _: &mut view_type!(Foo.{ _ })) {} | ^ error[E0609]: no field `r#where` on type `Foo` - --> $DIR/syntax-errors.rs:18:44 + --> $DIR/syntax-errors.rs:17:44 | LL | fn keyword(self: &mut view_type!(Foo.{ where }), _: &mut view_type!(Foo.{ for })) {} | ^^^^^ error[E0609]: no field `r#for` on type `Foo` - --> $DIR/syntax-errors.rs:18:79 + --> $DIR/syntax-errors.rs:17:79 | LL | fn keyword(self: &mut view_type!(Foo.{ where }), _: &mut view_type!(Foo.{ for })) {} | ^^^ diff --git a/tests/ui/view-types/tuple-structs.rs b/tests/ui/view-types/tuple-structs.rs index f0442d4e308fb..04dd222cef98d 100644 --- a/tests/ui/view-types/tuple-structs.rs +++ b/tests/ui/view-types/tuple-structs.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(view_types, view_type_macro)] +#![feature(view_types)] #![allow(unused)] use std::view::view_type;