From cb192afdb4d86fcc91d346391422f9eba59f0520 Mon Sep 17 00:00:00 2001 From: ouz-a Date: Mon, 27 Nov 2023 18:40:00 +0300 Subject: [PATCH 1/2] add stable_mir output test --- compiler/rustc_smir/src/rustc_smir/context.rs | 11 ++++-- compiler/stable_mir/src/compiler_interface.rs | 7 ++-- compiler/stable_mir/src/mir/body.rs | 1 + compiler/stable_mir/src/mir/pretty.rs | 35 +++++++++++-------- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/stable-mir-print/basic_function.rs | 3 ++ 6 files changed, 40 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index 3a8289f38bdc4..8460da316c248 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -3,7 +3,7 @@ //! This trait is currently the main interface between the Rust compiler, //! and the `stable_mir` crate. -use rustc_middle::ty; +use crate::rustc_smir::stable_mir::opaque; use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths}; use rustc_middle::ty::{ GenericPredicates, Instance, ParamEnv, ScalarInt, TypeVisitableExt, ValTree, @@ -18,7 +18,8 @@ use stable_mir::ty::{ AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FieldDef, FnDef, GenericArgs, LineInfo, PolyFnSig, RigidTy, Span, Ty, TyKind, VariantDef, }; -use stable_mir::{Crate, CrateItem, DefId, Error, Filename, ItemKind, Symbol}; +use stable_mir::Opaque; +use stable_mir::{self, Crate, CrateItem, Error, Filename, ItemKind, Symbol}; use std::cell::RefCell; use crate::rustc_internal::{internal, RustcInternal}; @@ -297,6 +298,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> { internal(cnst).to_string() } + fn adt_literal(&self, adt: &AdtDef) -> Opaque { + let mut tables = self.0.borrow_mut(); + let internal = adt.internal(&mut *tables); + opaque(&internal) + } + fn span_of_an_item(&self, def_id: stable_mir::DefId) -> Span { let mut tables = self.0.borrow_mut(); tables.tcx.def_span(tables[def_id]).stable(&mut *tables) diff --git a/compiler/stable_mir/src/compiler_interface.rs b/compiler/stable_mir/src/compiler_interface.rs index 2fac59e71fd5b..c5c376009ab31 100644 --- a/compiler/stable_mir/src/compiler_interface.rs +++ b/compiler/stable_mir/src/compiler_interface.rs @@ -15,8 +15,8 @@ use crate::ty::{ TraitDef, Ty, TyKind, VariantDef, }; use crate::{ - mir, Crate, CrateItem, CrateItems, DefId, Error, Filename, ImplTraitDecls, ItemKind, Symbol, - TraitDecls, + mir, Crate, CrateItem, CrateItems, DefId, Error, Filename, ImplTraitDecls, ItemKind, Opaque, + Symbol, TraitDecls, }; /// This trait defines the interface between stable_mir and the Rust compiler. @@ -106,6 +106,9 @@ pub trait Context { /// Returns literal value of a const as a string. fn const_literal(&self, cnst: &Const) -> String; + /// Returns literal version of a Adt as a Opaque + fn adt_literal(&self, adt: &AdtDef) -> Opaque; + /// `Span` of an item fn span_of_an_item(&self, def_id: DefId) -> Span; diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 5023af9ab79ec..b93f1878ee124 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -107,6 +107,7 @@ impl Body { Ok(()) }) .collect::, _>>()?; + writeln!(w, "}}")?; Ok(()) } diff --git a/compiler/stable_mir/src/mir/pretty.rs b/compiler/stable_mir/src/mir/pretty.rs index 8b7b488d312cf..710aba27850e7 100644 --- a/compiler/stable_mir/src/mir/pretty.rs +++ b/compiler/stable_mir/src/mir/pretty.rs @@ -7,6 +7,8 @@ use std::{io, iter}; use super::{AssertMessage, BinOp, TerminatorKind}; +use super::BorrowKind; + pub fn function_name(item: CrateItem) -> String { let mut pretty_name = String::new(); let body = item.body(); @@ -40,7 +42,6 @@ pub fn function_body(body: &Body) -> String { pretty_body.push_str(format!("{}", pretty_ty(local.ty.kind())).as_str()); pretty_body.push_str(";\n"); }); - pretty_body.push_str("}"); pretty_body } @@ -320,6 +321,7 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { pretty.push_str(format!("(*_{})", addr.local).as_str()); } Rvalue::Aggregate(aggregatekind, operands) => { + // FIXME: Add pretty_aggregate function that returns a pretty string pretty.push_str(format!("{:#?}", aggregatekind).as_str()); pretty.push_str("("); operands.iter().enumerate().for_each(|(i, op)| { @@ -330,12 +332,13 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { }); pretty.push_str(")"); } - Rvalue::BinaryOp(bin, op, op2) => { - pretty.push_str(&pretty_operand(op)); - pretty.push_str(" "); + Rvalue::BinaryOp(bin, op1, op2) => { pretty.push_str(format!("{:#?}", bin).as_str()); - pretty.push_str(" "); - pretty.push_str(&pretty_operand(op2)); + pretty.push_str("("); + pretty.push_str(format!("_{}", &pretty_operand(op1)).as_str()); + pretty.push_str(", "); + pretty.push_str(format!("{}", &pretty_operand(op2)).as_str()); + pretty.push_str(")"); } Rvalue::Cast(_, op, ty) => { pretty.push_str(&pretty_operand(op)); @@ -343,11 +346,12 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { pretty.push_str(&pretty_ty(ty.kind())); } Rvalue::CheckedBinaryOp(bin, op1, op2) => { - pretty.push_str(&pretty_operand(op1)); - pretty.push_str(" "); - pretty.push_str(format!("{:#?}", bin).as_str()); - pretty.push_str(" "); - pretty.push_str(&pretty_operand(op2)); + pretty.push_str(format!("Checked{:#?}", bin).as_str()); + pretty.push_str("("); + pretty.push_str(format!("_{}", &pretty_operand(op1)).as_str()); + pretty.push_str(", "); + pretty.push_str(format!("{}", &pretty_operand(op2)).as_str()); + pretty.push_str(")"); } Rvalue::CopyForDeref(deref) => { pretty.push_str("CopyForDeref"); @@ -362,8 +366,11 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { pretty.push_str(format!("{}", len.local).as_str()); } Rvalue::Ref(_, borrowkind, place) => { - pretty.push_str("ref"); - pretty.push_str(format!("{:#?}", borrowkind).as_str()); + match borrowkind { + BorrowKind::Shared => pretty.push_str("&"), + BorrowKind::Fake => pretty.push_str("&fake "), + BorrowKind::Mut { .. } => pretty.push_str("&mut "), + } pretty.push_str(format!("{}", place.local).as_str()); } Rvalue::Repeat(op, cnst) => { @@ -418,7 +425,7 @@ pub fn pretty_ty(ty: TyKind) -> String { FloatTy::F64 => "f64".to_string(), }, RigidTy::Adt(def, _) => { - format!("{:#?}", with(|cx| cx.def_ty(def.0))) + format!("{}", with(|cx| cx.adt_literal(&def))) } RigidTy::Str => "str".to_string(), RigidTy::Array(ty, len) => { diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index dfa386b49de7c..0fb57bf6f6c80 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1852; -const ROOT_ENTRY_LIMIT: usize = 867; +const ROOT_ENTRY_LIMIT: usize = 868; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/stable-mir-print/basic_function.rs b/tests/ui/stable-mir-print/basic_function.rs index 6394edcbb7847..55fbf3f4acdf6 100644 --- a/tests/ui/stable-mir-print/basic_function.rs +++ b/tests/ui/stable-mir-print/basic_function.rs @@ -1,6 +1,9 @@ // compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3 // check-pass +<<<<<<< HEAD // only-x86_64 +======= +>>>>>>> 9a9a3a91e41 (add stable_mir output test) fn foo(i:i32) -> i32 { i + 1 From dc78b1c676476885e603b8060de5365fc5da66ea Mon Sep 17 00:00:00 2001 From: ouz-a Date: Fri, 1 Dec 2023 09:13:39 +0300 Subject: [PATCH 2/2] update test, compress push_str misc fixes --- compiler/rustc_smir/src/rustc_smir/context.rs | 7 +- compiler/stable_mir/src/mir/pretty.rs | 107 +++----- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/stable-mir-print/basic_function.rs | 12 +- .../ui/stable-mir-print/basic_function.stdout | 242 +++--------------- 5 files changed, 95 insertions(+), 275 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index 8460da316c248..b2ca5b5ce29ad 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -3,7 +3,7 @@ //! This trait is currently the main interface between the Rust compiler, //! and the `stable_mir` crate. -use crate::rustc_smir::stable_mir::opaque; +use rustc_middle::ty; use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths}; use rustc_middle::ty::{ GenericPredicates, Instance, ParamEnv, ScalarInt, TypeVisitableExt, ValTree, @@ -18,8 +18,9 @@ use stable_mir::ty::{ AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FieldDef, FnDef, GenericArgs, LineInfo, PolyFnSig, RigidTy, Span, Ty, TyKind, VariantDef, }; -use stable_mir::Opaque; -use stable_mir::{self, Crate, CrateItem, Error, Filename, ItemKind, Symbol}; +use stable_mir::{ + self, opaque, Crate, CrateItem, DefId, Error, Filename, ItemKind, Opaque, Symbol, +}; use std::cell::RefCell; use crate::rustc_internal::{internal, RustcInternal}; diff --git a/compiler/stable_mir/src/mir/pretty.rs b/compiler/stable_mir/src/mir/pretty.rs index 710aba27850e7..fcf20022bb945 100644 --- a/compiler/stable_mir/src/mir/pretty.rs +++ b/compiler/stable_mir/src/mir/pretty.rs @@ -12,24 +12,20 @@ use super::BorrowKind; pub fn function_name(item: CrateItem) -> String { let mut pretty_name = String::new(); let body = item.body(); - pretty_name.push_str("fn "); - pretty_name.push_str(item.name().as_str()); + pretty_name.push_str(format!("fn {}", item.name()).as_str()); if body.arg_locals().is_empty() { pretty_name.push_str("()"); } else { pretty_name.push_str("("); } body.arg_locals().iter().enumerate().for_each(|(index, local)| { - pretty_name.push_str(format!("_{}: ", index).as_str()); - pretty_name.push_str(&pretty_ty(local.ty.kind())); + pretty_name.push_str(format!("_{}: {}", index, pretty_ty(local.ty.kind())).as_str()); }); if !body.arg_locals().is_empty() { pretty_name.push_str(")"); } let return_local = body.ret_local(); - pretty_name.push_str(" -> "); - pretty_name.push_str(&pretty_ty(return_local.ty.kind())); - pretty_name.push_str(" {"); + pretty_name.push_str(format!(" -> {} {{", pretty_ty(return_local.ty.kind())).as_str()); pretty_name } @@ -37,10 +33,15 @@ pub fn function_body(body: &Body) -> String { let mut pretty_body = String::new(); body.inner_locals().iter().enumerate().for_each(|(index, local)| { pretty_body.push_str(" "); - pretty_body.push_str(format!("let {}", ret_mutability(&local.mutability)).as_str()); - pretty_body.push_str(format!("_{}: ", index).as_str()); - pretty_body.push_str(format!("{}", pretty_ty(local.ty.kind())).as_str()); - pretty_body.push_str(";\n"); + pretty_body.push_str( + format!( + "let {}_{}: {};\n", + ret_mutability(&local.mutability), + index, + pretty_ty(local.ty.kind()) + ) + .as_str(), + ); }); pretty_body } @@ -56,8 +57,7 @@ pub fn pretty_statement(statement: &StatementKind) -> String { let mut pretty = String::new(); match statement { StatementKind::Assign(place, rval) => { - pretty.push_str(format!(" _{} = ", place.local).as_str()); - pretty.push_str(format!("{}", &pretty_rvalue(rval)).as_str()); + pretty.push_str(format!(" _{} = {}", place.local, pretty_rvalue(rval)).as_str()); } // FIXME: Add rest of the statements StatementKind::FakeRead(_, _) => { @@ -117,7 +117,7 @@ pub fn pretty_terminator(terminator: &TerminatorKind, w: &mut W) - Ok(()) } (1, false) => { - write!(w, " -> {:?}", successors[0])?; + write!(w, " -> bb{:?}", successors[0])?; Ok(()) } _ => { @@ -154,9 +154,7 @@ pub fn pretty_terminator_head(terminator: &TerminatorKind) -> String { Drop { place, .. } => format!(" drop(_{:?})", place.local), Call { func, args, destination, .. } => { pretty.push_str(" "); - pretty.push_str(format!("_{} = ", destination.local).as_str()); - pretty.push_str(&pretty_operand(func)); - pretty.push_str("("); + pretty.push_str(format!("_{} = {}(", destination.local, pretty_operand(func)).as_str()); args.iter().enumerate().for_each(|(i, arg)| { if i > 0 { pretty.push_str(", "); @@ -171,9 +169,9 @@ pub fn pretty_terminator_head(terminator: &TerminatorKind) -> String { if !expected { pretty.push_str("!"); } - pretty.push_str(format!("{} bool),", &pretty_operand(cond)).as_str()); - pretty.push_str(&pretty_assert_message(msg)); - pretty.push_str(")"); + pretty.push_str( + format!("{} bool),{})", &pretty_operand(cond), pretty_assert_message(msg)).as_str(), + ); pretty } InlineAsm { .. } => todo!(), @@ -297,16 +295,14 @@ pub fn pretty_operand(operand: &Operand) -> String { let mut pretty = String::new(); match operand { Operand::Copy(copy) => { - pretty.push_str(""); - pretty.push_str(format!("{}", copy.local).as_str()); + pretty.push_str(format!("_{}", copy.local).as_str()); } Operand::Move(mv) => { - pretty.push_str("move "); - pretty.push_str(format!("_{}", mv.local).as_str()); + pretty.push_str(format!("move _{}", mv.local).as_str()); } Operand::Constant(cnst) => { - pretty.push_str("const "); - pretty.push_str(with(|cx| cx.const_literal(&cnst.literal)).as_str()); + pretty + .push_str(format!("const {}", with(|cx| cx.const_literal(&cnst.literal))).as_str()); } } pretty @@ -316,14 +312,11 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { let mut pretty = String::new(); match rval { Rvalue::AddressOf(muta, addr) => { - pretty.push_str("&raw "); - pretty.push_str(&ret_mutability(muta)); - pretty.push_str(format!("(*_{})", addr.local).as_str()); + pretty.push_str(format!("&raw {}(*_{})", &ret_mutability(muta), addr.local).as_str()); } Rvalue::Aggregate(aggregatekind, operands) => { // FIXME: Add pretty_aggregate function that returns a pretty string - pretty.push_str(format!("{:#?}", aggregatekind).as_str()); - pretty.push_str("("); + pretty.push_str(format!("{:#?} (", aggregatekind).as_str()); operands.iter().enumerate().for_each(|(i, op)| { pretty.push_str(&pretty_operand(op)); if i != operands.len() - 1 { @@ -333,37 +326,27 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { pretty.push_str(")"); } Rvalue::BinaryOp(bin, op1, op2) => { - pretty.push_str(format!("{:#?}", bin).as_str()); - pretty.push_str("("); - pretty.push_str(format!("_{}", &pretty_operand(op1)).as_str()); - pretty.push_str(", "); - pretty.push_str(format!("{}", &pretty_operand(op2)).as_str()); - pretty.push_str(")"); + pretty.push_str( + format!("{:#?}({}, {})", bin, &pretty_operand(op1), pretty_operand(op2)).as_str(), + ); } Rvalue::Cast(_, op, ty) => { - pretty.push_str(&pretty_operand(op)); - pretty.push_str(" as "); - pretty.push_str(&pretty_ty(ty.kind())); + pretty.push_str(format!("{} as {}", pretty_operand(op), pretty_ty(ty.kind())).as_str()); } Rvalue::CheckedBinaryOp(bin, op1, op2) => { - pretty.push_str(format!("Checked{:#?}", bin).as_str()); - pretty.push_str("("); - pretty.push_str(format!("_{}", &pretty_operand(op1)).as_str()); - pretty.push_str(", "); - pretty.push_str(format!("{}", &pretty_operand(op2)).as_str()); - pretty.push_str(")"); + pretty.push_str( + format!("Checked{:#?}({}, {})", bin, &pretty_operand(op1), pretty_operand(op2)) + .as_str(), + ); } Rvalue::CopyForDeref(deref) => { - pretty.push_str("CopyForDeref"); - pretty.push_str(format!("{}", deref.local).as_str()); + pretty.push_str(format!("CopyForDeref{}", deref.local).as_str()); } Rvalue::Discriminant(place) => { - pretty.push_str("discriminant"); - pretty.push_str(format!("{}", place.local).as_str()); + pretty.push_str(format!("discriminant{}", place.local).as_str()); } Rvalue::Len(len) => { - pretty.push_str("len"); - pretty.push_str(format!("{}", len.local).as_str()); + pretty.push_str(format!("len{}", len.local).as_str()); } Rvalue::Ref(_, borrowkind, place) => { match borrowkind { @@ -374,24 +357,19 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { pretty.push_str(format!("{}", place.local).as_str()); } Rvalue::Repeat(op, cnst) => { - pretty.push_str(&pretty_operand(op)); - pretty.push_str(" "); - pretty.push_str(&pretty_ty(cnst.ty().kind())); + pretty.push_str( + &format!("{} \" \" {}", &pretty_operand(op), pretty_ty(cnst.ty().kind())).as_str(), + ); } Rvalue::ShallowInitBox(_, _) => (), Rvalue::ThreadLocalRef(item) => { - pretty.push_str("thread_local_ref"); - pretty.push_str(format!("{:#?}", item).as_str()); + pretty.push_str(format!("thread_local_ref{:#?}", item).as_str()); } Rvalue::NullaryOp(nul, ty) => { - pretty.push_str(format!("{:#?}", nul).as_str()); - pretty.push_str(&pretty_ty(ty.kind())); - pretty.push_str(" "); + pretty.push_str(format!("{:#?} {} \" \"", nul, pretty_ty(ty.kind())).as_str()); } Rvalue::UnaryOp(un, op) => { - pretty.push_str(&pretty_operand(op)); - pretty.push_str(" "); - pretty.push_str(format!("{:#?}", un).as_str()); + pretty.push_str(format!("{} \" \" {:#?}", pretty_operand(op), un).as_str()); } Rvalue::Use(op) => pretty.push_str(&pretty_operand(op)), } @@ -458,8 +436,7 @@ pub fn pretty_ty(ty: TyKind) -> String { DynKind::Dyn => pretty.push_str("dyn "), DynKind::DynStar => pretty.push_str("dyn* "), } - pretty.push_str(format!("{:#?}", data).as_str()); - pretty.push_str(format!(" + {:#?} )", region).as_str()); + pretty.push_str(format!("{:#?} + {:#?}", data, region).as_str()); pretty } RigidTy::Never => "!".to_string(), diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 0fb57bf6f6c80..dfa386b49de7c 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1852; -const ROOT_ENTRY_LIMIT: usize = 868; +const ROOT_ENTRY_LIMIT: usize = 867; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/stable-mir-print/basic_function.rs b/tests/ui/stable-mir-print/basic_function.rs index 55fbf3f4acdf6..5af3b21302e13 100644 --- a/tests/ui/stable-mir-print/basic_function.rs +++ b/tests/ui/stable-mir-print/basic_function.rs @@ -1,9 +1,6 @@ // compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3 // check-pass -<<<<<<< HEAD // only-x86_64 -======= ->>>>>>> 9a9a3a91e41 (add stable_mir output test) fn foo(i:i32) -> i32 { i + 1 @@ -15,4 +12,13 @@ fn bar(vec: &mut Vec) -> Vec { new_vec } +pub fn demux(input: u8) -> u8 { + match input { + 0 => 10, + 1 => 6, + 2 => 8, + _ => 0, + } +} + fn main(){} diff --git a/tests/ui/stable-mir-print/basic_function.stdout b/tests/ui/stable-mir-print/basic_function.stdout index d9b33a4257c2c..5a858a86d7b87 100644 --- a/tests/ui/stable-mir-print/basic_function.stdout +++ b/tests/ui/stable-mir-print/basic_function.stdout @@ -2,219 +2,28 @@ // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. fn foo(_0: i32) -> i32 { let mut _0: (i32, bool); -} + bb0: { - _2 = 1 Add const 1_i32 - assert(!move _2 bool),"attempt to compute `{} + {}`, which would overflow", 1, const 1_i32) -> [success: bb1, unwind continue] + _2 = CheckedAdd(_1, const 1_i32) + assert(!move _2 bool),"attempt to compute `{} + {}`, which would overflow", _1, const 1_i32) -> [success: bb1, unwind continue] } bb1: { _0 = move _2 return } -fn bar(_0: &mut Ty { - id: 10, - kind: RigidTy( - Adt( - AdtDef( - DefId { - id: 3, - name: "std::vec::Vec", - }, - ), - GenericArgs( - [ - Type( - Ty { - id: 11, - kind: Param( - ParamTy { - index: 0, - name: "T", - }, - ), - }, - ), - Type( - Ty { - id: 12, - kind: Param( - ParamTy { - index: 1, - name: "A", - }, - ), - }, - ), - ], - ), - ), - ), -}) -> Ty { - id: 10, - kind: RigidTy( - Adt( - AdtDef( - DefId { - id: 3, - name: "std::vec::Vec", - }, - ), - GenericArgs( - [ - Type( - Ty { - id: 11, - kind: Param( - ParamTy { - index: 0, - name: "T", - }, - ), - }, - ), - Type( - Ty { - id: 12, - kind: Param( - ParamTy { - index: 1, - name: "A", - }, - ), - }, - ), - ], - ), - ), - ), -} { - let mut _0: Ty { - id: 10, - kind: RigidTy( - Adt( - AdtDef( - DefId { - id: 3, - name: "std::vec::Vec", - }, - ), - GenericArgs( - [ - Type( - Ty { - id: 11, - kind: Param( - ParamTy { - index: 0, - name: "T", - }, - ), - }, - ), - Type( - Ty { - id: 12, - kind: Param( - ParamTy { - index: 1, - name: "A", - }, - ), - }, - ), - ], - ), - ), - ), -}; - let mut _1: &Ty { - id: 10, - kind: RigidTy( - Adt( - AdtDef( - DefId { - id: 3, - name: "std::vec::Vec", - }, - ), - GenericArgs( - [ - Type( - Ty { - id: 11, - kind: Param( - ParamTy { - index: 0, - name: "T", - }, - ), - }, - ), - Type( - Ty { - id: 12, - kind: Param( - ParamTy { - index: 1, - name: "A", - }, - ), - }, - ), - ], - ), - ), - ), -}; - let _2: (); - let mut _3: &mut Ty { - id: 10, - kind: RigidTy( - Adt( - AdtDef( - DefId { - id: 3, - name: "std::vec::Vec", - }, - ), - GenericArgs( - [ - Type( - Ty { - id: 11, - kind: Param( - ParamTy { - index: 0, - name: "T", - }, - ), - }, - ), - Type( - Ty { - id: 12, - kind: Param( - ParamTy { - index: 1, - name: "A", - }, - ), - }, - ), - ], - ), - ), - ), -}; } +fn bar(_0: &mut std::vec::Vec) -> std::vec::Vec { + let mut _0: std::vec::Vec; + let mut _1: &std::vec::Vec; + let _2: (); + let mut _3: &mut std::vec::Vec; + bb0: { - _3 = refShared1 + _3 = &1 _2 = const as Clone>::clone(move _3) -> [return: bb1, unwind continue] } bb1: { - _5 = refMut { - kind: TwoPhaseBorrow, -}2 + _5 = &mut 2 _4 = const Vec::::push(move _5, const 1_i32) -> [return: bb2, unwind: bb3] } bb2: { @@ -227,8 +36,35 @@ fn bar(_0: &mut Ty { bb4: { resume } -fn main() -> () { } +fn demux(_0: u8) -> u8 { + bb0: { + switchInt(__1) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1] + } + bb1: { + _0 = const 0_u8 + goto -> bb5 + } + bb2: { + _0 = const 10_u8 + goto -> bb5 + } + bb3: { + _0 = const 6_u8 + goto -> bb5 + } + bb4: { + _0 = const 8_u8 + goto -> bb5 + } + bb5: { return } +} +fn main() -> () { + + bb0: { + return + } +}