Skip to content

Commit 0a0231c

Browse files
committed
add stable_mir output test
1 parent c3def26 commit 0a0231c

File tree

4 files changed

+275
-14
lines changed

4 files changed

+275
-14
lines changed

compiler/stable_mir/src/mir/pretty.rs

+26-13
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,31 @@ pub fn pretty_statement(statement: &StatementKind) -> String {
5858
pretty.push_str(format!(" _{} = ", place.local).as_str());
5959
pretty.push_str(format!("{}", &pretty_rvalue(rval)).as_str());
6060
}
61-
StatementKind::FakeRead(_, _) => todo!(),
62-
StatementKind::SetDiscriminant { .. } => todo!(),
63-
StatementKind::Deinit(_) => todo!(),
64-
StatementKind::StorageLive(_) => todo!(),
65-
StatementKind::StorageDead(_) => todo!(),
66-
StatementKind::Retag(_, _) => todo!(),
67-
StatementKind::PlaceMention(_) => todo!(),
68-
StatementKind::AscribeUserType { .. } => todo!(),
69-
StatementKind::Coverage(_) => todo!(),
70-
StatementKind::Intrinsic(_) => todo!(),
71-
StatementKind::ConstEvalCounter => (),
72-
StatementKind::Nop => (),
61+
// FIXME: Add rest of the statements
62+
StatementKind::FakeRead(_, _) => return format!("StatementKind::FakeRead:Unimplemented"),
63+
StatementKind::SetDiscriminant { .. } => {
64+
return format!("StatementKind::SetDiscriminant:Unimplemented");
65+
}
66+
StatementKind::Deinit(_) => return format!("StatementKind::Deinit:Unimplemented"),
67+
StatementKind::StorageLive(_) => {
68+
return format!("StatementKind::StorageLive:Unimplemented");
69+
}
70+
StatementKind::StorageDead(_) => {
71+
return format!("StatementKind::StorageDead:Unimplemented");
72+
}
73+
StatementKind::Retag(_, _) => return format!("StatementKind::Retag:Unimplemented"),
74+
StatementKind::PlaceMention(_) => {
75+
return format!("StatementKind::PlaceMention:Unimplemented");
76+
}
77+
StatementKind::AscribeUserType { .. } => {
78+
return format!("StatementKind::AscribeUserType:Unimplemented");
79+
}
80+
StatementKind::Coverage(_) => return format!("StatementKind::Coverage:Unimplemented"),
81+
StatementKind::Intrinsic(_) => return format!("StatementKind::Intrinsic:Unimplemented"),
82+
StatementKind::ConstEvalCounter => {
83+
return format!("StatementKind::ConstEvalCounter:Unimplemented");
84+
}
85+
StatementKind::Nop => return format!("StatementKind::Nop:Unimplemented"),
7386
}
7487
pretty
7588
}
@@ -355,7 +368,7 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String {
355368
pretty.push_str(" ");
356369
pretty.push_str(&pretty_ty(cnst.ty().kind()));
357370
}
358-
Rvalue::ShallowInitBox(_, _) => todo!(),
371+
Rvalue::ShallowInitBox(_, _) => (),
359372
Rvalue::ThreadLocalRef(item) => {
360373
pretty.push_str("thread_local_ref");
361374
pretty.push_str(format!("{:#?}", item).as_str());

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1852;
14-
const ROOT_ENTRY_LIMIT: usize = 866;
14+
const ROOT_ENTRY_LIMIT: usize = 867;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3
2+
// check-pass
3+
4+
fn foo(i:i32) -> i32 {
5+
i + 1
6+
}
7+
8+
fn bar(vec: &mut Vec<i32>) -> Vec<i32> {
9+
let mut new_vec = vec.clone();
10+
new_vec.push(1);
11+
new_vec
12+
}
13+
14+
fn main(){}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
// WARNING: This is highly experimental output it's intended for stable-mir developers only.
2+
// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir.
3+
fn foo(_0: i32) -> i32 {
4+
let mut _0: (i32, bool);
5+
}
6+
bb0: {
7+
_2 = 1 Add const 1_i32
8+
assert(!move _2 bool),"attempt to compute `{} + {}`, which would overflow", 1, const 1_i32) -> [success: bb1, unwind continue]
9+
}
10+
bb1: {
11+
_0 = move _2
12+
return
13+
}
14+
fn bar(_0: &mut Ty {
15+
id: 10,
16+
kind: RigidTy(
17+
Adt(
18+
AdtDef(
19+
DefId {
20+
id: 3,
21+
name: "std::vec::Vec",
22+
},
23+
),
24+
GenericArgs(
25+
[
26+
Type(
27+
Ty {
28+
id: 11,
29+
kind: Param(
30+
ParamTy {
31+
index: 0,
32+
name: "T",
33+
},
34+
),
35+
},
36+
),
37+
Type(
38+
Ty {
39+
id: 12,
40+
kind: Param(
41+
ParamTy {
42+
index: 1,
43+
name: "A",
44+
},
45+
),
46+
},
47+
),
48+
],
49+
),
50+
),
51+
),
52+
}) -> Ty {
53+
id: 10,
54+
kind: RigidTy(
55+
Adt(
56+
AdtDef(
57+
DefId {
58+
id: 3,
59+
name: "std::vec::Vec",
60+
},
61+
),
62+
GenericArgs(
63+
[
64+
Type(
65+
Ty {
66+
id: 11,
67+
kind: Param(
68+
ParamTy {
69+
index: 0,
70+
name: "T",
71+
},
72+
),
73+
},
74+
),
75+
Type(
76+
Ty {
77+
id: 12,
78+
kind: Param(
79+
ParamTy {
80+
index: 1,
81+
name: "A",
82+
},
83+
),
84+
},
85+
),
86+
],
87+
),
88+
),
89+
),
90+
} {
91+
let mut _0: Ty {
92+
id: 10,
93+
kind: RigidTy(
94+
Adt(
95+
AdtDef(
96+
DefId {
97+
id: 3,
98+
name: "std::vec::Vec",
99+
},
100+
),
101+
GenericArgs(
102+
[
103+
Type(
104+
Ty {
105+
id: 11,
106+
kind: Param(
107+
ParamTy {
108+
index: 0,
109+
name: "T",
110+
},
111+
),
112+
},
113+
),
114+
Type(
115+
Ty {
116+
id: 12,
117+
kind: Param(
118+
ParamTy {
119+
index: 1,
120+
name: "A",
121+
},
122+
),
123+
},
124+
),
125+
],
126+
),
127+
),
128+
),
129+
};
130+
let mut _1: &Ty {
131+
id: 10,
132+
kind: RigidTy(
133+
Adt(
134+
AdtDef(
135+
DefId {
136+
id: 3,
137+
name: "std::vec::Vec",
138+
},
139+
),
140+
GenericArgs(
141+
[
142+
Type(
143+
Ty {
144+
id: 11,
145+
kind: Param(
146+
ParamTy {
147+
index: 0,
148+
name: "T",
149+
},
150+
),
151+
},
152+
),
153+
Type(
154+
Ty {
155+
id: 12,
156+
kind: Param(
157+
ParamTy {
158+
index: 1,
159+
name: "A",
160+
},
161+
),
162+
},
163+
),
164+
],
165+
),
166+
),
167+
),
168+
};
169+
let _2: ();
170+
let mut _3: &mut Ty {
171+
id: 10,
172+
kind: RigidTy(
173+
Adt(
174+
AdtDef(
175+
DefId {
176+
id: 3,
177+
name: "std::vec::Vec",
178+
},
179+
),
180+
GenericArgs(
181+
[
182+
Type(
183+
Ty {
184+
id: 11,
185+
kind: Param(
186+
ParamTy {
187+
index: 0,
188+
name: "T",
189+
},
190+
),
191+
},
192+
),
193+
Type(
194+
Ty {
195+
id: 12,
196+
kind: Param(
197+
ParamTy {
198+
index: 1,
199+
name: "A",
200+
},
201+
),
202+
},
203+
),
204+
],
205+
),
206+
),
207+
),
208+
};
209+
}
210+
bb0: {
211+
_3 = refShared1
212+
_2 = const <Vec<i32> as Clone>::clone(move _3) -> [return: bb1, unwind continue]
213+
}
214+
bb1: {
215+
_5 = refMut {
216+
kind: TwoPhaseBorrow,
217+
}2
218+
_4 = const Vec::<i32>::push(move _5, const 1_i32) -> [return: bb2, unwind: bb3]
219+
}
220+
bb2: {
221+
_0 = move _2
222+
return
223+
}
224+
bb3: {
225+
drop(_2) -> [return: bb4, unwind terminate]
226+
}
227+
bb4: {
228+
resume
229+
}
230+
fn main() -> () {
231+
}
232+
bb0: {
233+
return
234+
}

0 commit comments

Comments
 (0)