summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps/stable-mir
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /tests/ui-fulldeps/stable-mir
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui-fulldeps/stable-mir')
-rw-r--r--tests/ui-fulldeps/stable-mir/crate-info.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs
index dfde8c97e..a3db2e9ef 100644
--- a/tests/ui-fulldeps/stable-mir/crate-info.rs
+++ b/tests/ui-fulldeps/stable-mir/crate-info.rs
@@ -33,7 +33,6 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
// Find items in the local crate.
let items = stable_mir::all_local_items();
- assert!(get_item(tcx, &items, (DefKind::Fn, "foo_bar")).is_some());
assert!(get_item(tcx, &items, (DefKind::Fn, "foo::bar")).is_some());
// Find the `std` crate.
@@ -41,6 +40,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
let bar = get_item(tcx, &items, (DefKind::Fn, "bar")).unwrap();
let body = bar.body();
+ assert_eq!(body.locals.len(), 2);
assert_eq!(body.blocks.len(), 1);
let block = &body.blocks[0];
assert_eq!(block.statements.len(), 1);
@@ -52,6 +52,34 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
stable_mir::mir::Terminator::Return => {}
other => panic!("{other:?}"),
}
+
+ let foo_bar = get_item(tcx, &items, (DefKind::Fn, "foo_bar")).unwrap();
+ let body = foo_bar.body();
+ assert_eq!(body.locals.len(), 7);
+ assert_eq!(body.blocks.len(), 4);
+ let block = &body.blocks[0];
+ match &block.terminator {
+ stable_mir::mir::Terminator::Call { .. } => {}
+ other => panic!("{other:?}"),
+ }
+
+ let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
+ let body = drop.body();
+ assert_eq!(body.blocks.len(), 2);
+ let block = &body.blocks[0];
+ match &block.terminator {
+ stable_mir::mir::Terminator::Drop { .. } => {}
+ other => panic!("{other:?}"),
+ }
+
+ let assert = get_item(tcx, &items, (DefKind::Fn, "assert")).unwrap();
+ let body = assert.body();
+ assert_eq!(body.blocks.len(), 2);
+ let block = &body.blocks[0];
+ match &block.terminator {
+ stable_mir::mir::Terminator::Assert { .. } => {}
+ other => panic!("{other:?}"),
+ }
}
// Use internal API to find a function in a crate.
@@ -97,7 +125,7 @@ impl Callbacks for SMirCalls {
queries: &'tcx Queries<'tcx>,
) -> Compilation {
queries.global_ctxt().unwrap().enter(|tcx| {
- test_stable_mir(tcx);
+ rustc_smir::rustc_internal::run(tcx, || test_stable_mir(tcx));
});
// No need to keep going.
Compilation::Stop
@@ -123,6 +151,12 @@ fn generate_input(path: &str) -> std::io::Result<()> {
let x_64 = foo::bar(x);
let y_64 = foo::bar(y);
x_64.wrapping_add(y_64)
+ }}
+
+ pub fn drop(_: String) {{}}
+
+ pub fn assert(x: i32) -> i32 {{
+ x + 1
}}"#
)?;
Ok(())