summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps/stable-mir/crate-info.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/ui-fulldeps/stable-mir/crate-info.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.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/crate-info.rs')
-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(())