//@ revisions: expanded hir //@[expanded]compile-flags: -Zunpretty=expanded //@[expanded]check-pass //@[hir]compile-flags: -Zunpretty=hir //@[hir]check-fail //@ edition:2024 // Note: the HIR revision includes a `.stderr` file because there are some // errors that only occur once we get past the AST. #![feature(auto_traits)] #![feature(box_patterns)] #![feature(builtin_syntax)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] #![feature(never_patterns)] #![feature(never_type)] #![feature(pattern_types)] #![feature(pattern_type_macro)] #![feature(prelude_import)] #![feature(specialization)] #![feature(trace_macros)] #![feature(trait_alias)] #![feature(try_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] #[prelude_import] use std::prelude::rust_2024::*; #[macro_use] extern crate std; #[prelude_import] use self::prelude::*; mod prelude { use std::prelude::rust_2024::*; type T = _; trait Trait { const CONST: (); } } /// inner single-line doc comment /** * inner multi-line doc comment */ #[doc = "inner doc attribute"] #[allow(dead_code, unused_variables)] #[no_std] mod attributes { /// outer single-line doc comment /** * outer multi-line doc comment */ #[doc = "outer doc attribute"] #[doc = "macro"] #[allow()] #[attr = Repr {reprs: [ReprC]}] struct Struct; } mod expressions { /// ExprKind::Array fn expr_array() { []; [true]; [true]; [true, true]; ["long........................................................................"]; ["long............................................................", true]; } /// ExprKind::ConstBlock fn expr_const_block() { const { }; const { 1 }; const { struct S; }; } /// ExprKind::Call fn expr_call() { let f; f(); f::(); f::<1>(); f::<'static, u8, 1>(); f(true); f(true); ()(); } /// ExprKind::MethodCall fn expr_method_call() { let x; x.f(); x.f::(); x.collect::>(); } /// ExprKind::Tup fn expr_tup() { (); (true,); (true, false); (true, false); } /// ExprKind::Binary fn expr_binary() { let (a, b, c, d, x, y); true || false; true || false && false; a < 1 && 2 < b && c > 3 && 4 > d; a & b & !c; a + b * c - d + -1 * -2 - -3; x = !y; } /// ExprKind::Unary fn expr_unary() { let expr; *expr; !expr; -expr; } /// ExprKind::Lit fn expr_lit() { 'x'; 1000i8; 1.00000000000000000000001; } /// ExprKind::Cast fn expr_cast() { let expr; expr as T; expr as T; } /// ExprKind::Type fn expr_type() { let expr; type_ascribe!(expr, T); } /// ExprKind::Let fn expr_let() { let b; if let Some(a) = b { } if let _ = true && false { } if let _ = (true && false) { } } /// ExprKind::If fn expr_if() { if true { } if !true { } if let true = true { } else { } if true { } else if false { } if true { } else if false { } else { } if true { return; } else if false { 0 } else { 0 } } /// ExprKind::While fn expr_while() { loop { if false { } else { break; } } 'a: loop { if false { } else { break; } } loop { if let true = true { } else { break; } } } /// ExprKind::ForLoop fn expr_for_loop() { let x; { let _t = match #[lang = "into_iter"](x) { mut iter => loop { match #[lang = "next"](&mut iter) { #[lang = "None"] {} => break, #[lang = "Some"] { 0: _ } => { } } }, }; _t }; { let _t = match #[lang = "into_iter"](x) { mut iter => 'a: loop { match #[lang = "next"](&mut iter) { #[lang = "None"] {} => break, #[lang = "Some"] { 0: _ } => { } } }, }; _t } } /// ExprKind::Loop fn expr_loop() { loop { } 'a: loop { } } /// ExprKind::Match fn expr_match() { let value; match value { } match value { ok => 1, } match value { ok => 1, err => 0, } } /// ExprKind::Closure fn expr_closure() { let value; || { }; |x| { }; |x: u8| { }; || (); move || value; || |mut _task_context: ResumeTy| { { let _t = value; _t } }; move || |mut _task_context: ResumeTy| { { let _t = value; _t } }; || value; move || value; || |mut _task_context: ResumeTy| { { let _t = value; _t } }; move || |mut _task_context: ResumeTy| { { let _t = value; _t } }; || -> u8 { value }; 1 + (|| { }); } /// ExprKind::Block fn expr_block() { { } unsafe { } 'a: { } #[allow()] { } #[allow()] { } } /// ExprKind::Gen fn expr_gen() { |mut _task_context: ResumeTy| { }; move |mut _task_context: ResumeTy| { }; || { }; move || { }; |mut _task_context: ResumeTy| { }; move |mut _task_context: ResumeTy| { }; } /// ExprKind::Await fn expr_await() { let fut; { fut; (/*ERROR*/) }; } /// ExprKind::TryBlock fn expr_try_block() { { #[lang = "from_output"](()) } { return; #[lang = "from_output"](()) } } /// ExprKind::Assign fn expr_assign() { let expr; expr = true; } /// ExprKind::AssignOp fn expr_assign_op() { let expr; expr += true; } /// ExprKind::Field fn expr_field() { let expr; expr.field; expr.0; } /// ExprKind::Index fn expr_index() { let expr; expr[true]; } /// ExprKind::Range fn expr_range() { let (lo, hi); #[lang = "RangeFull"] { }; #[lang = "RangeTo"] { end: hi }; #[lang = "RangeFrom"] { start: lo }; #[lang = "Range"] { start: lo, end: hi }; #[lang = "Range"] { start: lo, end: hi }; #[lang = "RangeToInclusive"] { end: hi }; #[lang = "range_inclusive_new"](lo, hi); #[lang = "range_inclusive_new"](-2, -1); } /// ExprKind::Underscore fn expr_underscore() { (/*ERROR*/); } /// ExprKind::Path fn expr_path() { let x; crate::expressions::expr_path; crate::expressions::expr_path::<'static>; ::default; ::default; x; x::; crate::expressions::expr_path; core::marker::PhantomData; } /// ExprKind::AddrOf fn expr_addr_of() { let expr; &expr; &mut expr; &raw const expr; &raw mut expr; } /// ExprKind::Break fn expr_break() { 'a: { break; break 'a; break true; break 'a true; } } /// ExprKind::Continue fn expr_continue() { 'a: { continue; continue 'a; } } /// ExprKind::Ret fn expr_ret() { return; return true; } /// ExprKind::InlineAsm: see exhaustive-asm.rs /// ExprKind::OffsetOf fn expr_offset_of() { // ... { offset_of!(T, field) }; } /// ExprKind::MacCall fn expr_mac_call() { "..."; "..."; "..."; } /// ExprKind::Struct fn expr_struct() { struct Struct { } let (x, base); Struct { }; ::Owned { }; Struct { .. }; Struct { ..base }; Struct { x }; Struct { x, ..base }; Struct { x: true }; Struct { x: true, .. }; Struct { x: true, ..base }; Struct { 0: true, ..base }; } /// ExprKind::Repeat fn expr_repeat() { [(); 0]; } /// ExprKind::Paren fn expr_paren() { let expr; expr; } /// ExprKind::Try fn expr_try() { let expr; match #[lang = "branch"](expr) { #[lang = "Break"] { 0: residual } => #[allow(unreachable_code)] return #[lang = "from_residual"](residual), #[lang = "Continue"] { 0: val } => #[allow(unreachable_code)] val, }; } /// ExprKind::Yield fn expr_yield() { yield (); yield true; } /// ExprKind::Yeet fn expr_yeet() { return #[lang = "from_yeet"](()); return #[lang = "from_yeet"](0); } /// ExprKind::Become fn expr_become() { become true; } /// ExprKind::IncludedBytes fn expr_include_bytes() { b"data for include_bytes in ../expanded-exhaustive.rs\n"; } /// ExprKind::FormatArgs fn expr_format_args() { let expr; format_arguments::new_const(&[]); { super let args = [format_argument::new_display(&expr)]; format_arguments::new_v1(&[""], &args) }; } } mod items { /// ItemKind::ExternCrate mod item_extern_crate { extern crate core; extern crate self as unpretty; extern crate core as _; } /// ItemKind::Use mod item_use { use ::{}; use crate::expressions; use crate::items::item_use; use core::*; } /// ItemKind::Static mod item_static { static A: () = { }; static mut B: () = { }; } /// ItemKind::Const mod item_const { const A: () = { }; trait TraitItems { const B: (); const C: () = { }; } } /// ItemKind::Fn mod item_fn { const unsafe extern "C" fn f() { } async unsafe extern "C" fn g() -> /*impl Trait*/ |mut _task_context: ResumeTy| { { let _t = { }; _t } } fn h<'a, T>() where T: 'a { } trait TraitItems { unsafe extern "C" fn f(); } impl TraitItems for _ { unsafe extern "C" fn f() { } } } /// ItemKind::Mod mod item_mod { } /// ItemKind::ForeignMod mod item_foreign_mod { extern "Rust" { } extern "C" { } } /// ItemKind::GlobalAsm: see exhaustive-asm.rs /// ItemKind::TyAlias mod item_ty_alias { type Type<'a> where T: 'a = T; } /// ItemKind::Enum mod item_enum { enum Void { } enum Empty { Unit, Tuple(), Struct { }, } enum Generic<'a, T> where T: 'a { Tuple(T), Struct { t: T, }, } } /// ItemKind::Struct mod item_struct { struct Unit; struct Tuple(); struct Newtype(Unit); struct Struct { } struct Generic<'a, T> where T: 'a { t: T, } } /// ItemKind::Union mod item_union { union Generic<'a, T> where T: 'a { t: T, } } /// ItemKind::Trait mod item_trait { auto unsafe trait Send { } trait Trait<'a>: Sized where Self: 'a { } } /// ItemKind::TraitAlias mod item_trait_alias { trait Trait = Sized where for<'a> T: 'a; } /// ItemKind::Impl mod item_impl { impl () { } impl () { } impl Default for () { } impl const Default for () { } } /// ItemKind::MacCall mod item_mac_call { } /// ItemKind::MacroDef mod item_macro_def { macro_rules! mac { () => {...}; } macro stringify { () => {} } } /// ItemKind::Delegation /** FIXME: todo */ mod item_delegation { } /// ItemKind::DelegationMac /** FIXME: todo */ mod item_delegation_mac { } } mod patterns { /// PatKind::Missing fn pat_missing() { let _: for fn(u32, T, &'_ str); } /// PatKind::Wild fn pat_wild() { let _; } /// PatKind::Ident fn pat_ident() { let x; let ref x; let mut x; let ref mut x; let ref mut x@_; } /// PatKind::Struct fn pat_struct() { let T {}; let T:: {}; let T::<'static> {}; let T { x }; let T { x: _x }; let T { .. }; let T { x, .. }; let T { x: _x, .. }; let T { 0: _x, .. }; let ::Owned {}; } /// PatKind::TupleStruct fn pat_tuple_struct() { struct Tuple(); let Tuple(); let Tuple::(); let Tuple::<'static>(); let Tuple(x); let Tuple(..); let Tuple(x, ..); } /// PatKind::Or fn pat_or() { let true | false; let true; let true | false; } /// PatKind::Path fn pat_path() { let core::marker::PhantomData; let core::marker::PhantomData::; let core::marker::PhantomData::<'static>; let ::CONST; } /// PatKind::Tuple fn pat_tuple() { let (); let (true,); let (true, false); } /// PatKind::Box fn pat_box() { let box pat; } /// PatKind::Deref fn pat_deref() { let deref!(pat); } /// PatKind::Ref fn pat_ref() { let &pat; let &mut pat; } /// PatKind::Expr fn pat_expr() { let 1000i8; let -""; } /// PatKind::Range fn pat_range() { let ..1; let 0...; let 0..1; let 0...1; let -2...-1; } /// PatKind::Slice fn pat_slice() { let []; let [true]; let [true]; let [true, false]; } /// PatKind::Rest fn pat_rest() { let _; } /// PatKind::Never fn pat_never() { let !; let Some(!); } /// PatKind::Paren fn pat_paren() { let pat; } /// PatKind::MacCall fn pat_mac_call() { let ""; let ""; let ""; } } mod statements { /// StmtKind::Let fn stmt_let() { let _; let _ = true; let _: T = true; let _ = true else { return; }; } /// StmtKind::Item fn stmt_item() { struct Struct { } struct Unit; } /// StmtKind::Expr fn stmt_expr() { () } /// StmtKind::Semi fn stmt_semi() { 1 + 1; } /// StmtKind::Empty fn stmt_empty() { } /// StmtKind::MacCall fn stmt_mac_call() { "..."; "..."; "..."; } } mod types { /// TyKind::Slice fn ty_slice() { let _: [T]; } /// TyKind::Array fn ty_array() { let _: [T; 0]; } /// TyKind::Ptr fn ty_ptr() { let _: *const T; let _: *mut T; } /// TyKind::Ref fn ty_ref() { let _: &T; let _: &mut T; let _: &'static T; let _: &'static mut [T]; let _: &T>>>; let _: &T>>>; } /// TyKind::BareFn fn ty_bare_fn() { let _: fn(); let _: fn() -> (); let _: fn(T); let _: fn(t: T); let _: fn(); let _: for<'a> fn(); } /// TyKind::Never fn ty_never() { let _: !; } /// TyKind::Tup fn ty_tup() { let _: (); let _: (T,); let _: (T, T); } /// TyKind::Path fn ty_path() { let _: T; let _: T<'static>; let _: T; let _: T; let _: T; let _: ::Owned; } /// TyKind::TraitObject fn ty_trait_object() { let _: dyn Send; let _: dyn Send + 'static; let _: dyn Send + 'static; let _: dyn for<'a> Send; } /// TyKind::ImplTrait const fn ty_impl_trait() { let _: (/*ERROR*/); let _: (/*ERROR*/); let _: (/*ERROR*/); let _: (/*ERROR*/); let _: (/*ERROR*/); let _: (/*ERROR*/); } /// TyKind::Paren fn ty_paren() { let _: T; } /// TyKind::Typeof /** unused for now */ fn ty_typeof() { } /// TyKind::Infer fn ty_infer() { let _: _; } /// TyKind::ImplicitSelf /** there is no syntax for this */ fn ty_implicit_self() { } /// TyKind::MacCall fn ty_mac_call() { macro_rules! ty { ($ty:ty) => { $ty } } let _: T; let _: T; let _: T; } /// TyKind::CVarArgs /** FIXME: todo */ fn ty_c_var_args() { } /// TyKind::Pat fn ty_pat() { let _: u32 is 1..=RangeMax; } } mod visibilities { /// VisibilityKind::Public mod visibility_public { struct Pub; } /// VisibilityKind::Restricted mod visibility_restricted { struct PubCrate; struct PubSelf; struct PubSuper; struct PubInCrate; struct PubInSelf; struct PubInSuper; struct PubInCrateVisibilities; struct PubInSelfSuper; struct PubInSuperMod; } }