diff options
| author | bors <bors@rust-lang.org> | 2023-11-17 07:53:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-17 07:53:40 +0000 |
| commit | ee5ef3aac9cfa6c51457f9afc720071212362d7c (patch) | |
| tree | 8a5e0a7553fc2918763164697fe5c90ee322f789 /tests | |
| parent | 00bfd6b2734d9c28a147bf237490995731781fdd (diff) | |
| parent | 488c2aac2979a6c99b0c8bb21073b1b72d5ef2a3 (diff) | |
| download | rust-ee5ef3aac9cfa6c51457f9afc720071212362d7c.tar.gz rust-ee5ef3aac9cfa6c51457f9afc720071212362d7c.zip | |
Auto merge of #118003 - matthiaskrgr:rollup-80t3uky, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #115476 (document ABI compatibility) - #117688 (Misc changes to StableMIR required to Kani use case.) - #117998 (On resolve error of `[rest..]`, suggest `[rest @ ..]`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/check_instance.rs | 14 | ||||
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/crate-info.rs | 8 | ||||
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/projections.rs | 8 | ||||
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/smir_visitor.rs | 2 | ||||
| -rw-r--r-- | tests/ui/abi/compatibility.rs | 8 | ||||
| -rw-r--r-- | tests/ui/match/issue-92100.stderr | 5 | ||||
| -rw-r--r-- | tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs | 9 | ||||
| -rw-r--r-- | tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr | 30 | ||||
| -rw-r--r-- | tests/ui/typeck/issue-105946.stderr | 5 |
9 files changed, 74 insertions, 15 deletions
diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index a340877752d..e5a480cd61d 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -49,7 +49,7 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { assert!(generic.iter().all(|item| mir::mono::Instance::try_from(*item).is_err())); for instance in instances { - test_body(instance.body()) + test_body(instance.body().unwrap()) } ControlFlow::Continue(()) } @@ -61,8 +61,10 @@ fn test_body(body: mir::Body) { Call { func, .. } => { let TyKind::RigidTy(ty) = func.ty(body.locals()).kind() else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() }; - let result = Instance::resolve(def, &args); - assert!(result.is_ok()); + let instance = Instance::resolve(def, &args).unwrap(); + let mangled_name = instance.mangled_name(); + let body = instance.body(); + assert!(body.is_some() || mangled_name == "setpwent", "Failed: {func:?}"); } Goto { .. } | Assert { .. } | SwitchInt { .. } | Return | Drop { .. } => { /* Do nothing */ @@ -105,10 +107,16 @@ fn generate_input(path: &str) -> std::io::Result<()> { LEN > 0 && a[0] }} + extern "C" {{ + // Body should not be available. + fn setpwent(); + }} + pub fn monomorphic() {{ let v = vec![10]; let dup = ty_param(&v); assert_eq!(v, dup); + unsafe {{ setpwent() }}; }} pub mod foo {{ diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index ed6b786f5e1..025ed1b6a95 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -22,6 +22,7 @@ extern crate stable_mir; use rustc_hir::def::DefKind; use rustc_middle::ty::TyCtxt; use rustc_smir::rustc_internal; +use stable_mir::ItemKind; use stable_mir::mir::mono::Instance; use stable_mir::ty::{RigidTy, TyKind}; use std::assert_matches::assert_matches; @@ -120,13 +121,13 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let monomorphic = get_item(&items, (DefKind::Fn, "monomorphic")).unwrap(); let instance = Instance::try_from(monomorphic.clone()).unwrap(); - for block in instance.body().blocks { + for block in instance.body().unwrap().blocks { match &block.terminator.kind { stable_mir::mir::TerminatorKind::Call { func, .. } => { let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() }; let RigidTy::FnDef(def, args) = ty else { unreachable!() }; let next_func = Instance::resolve(def, &args).unwrap(); - match next_func.body().locals()[1].ty.kind() { + match next_func.body().unwrap().locals()[1].ty.kind() { TyKind::RigidTy(RigidTy::Uint(_)) | TyKind::RigidTy(RigidTy::Tuple(_)) => {} other => panic!("{other:?}"), } @@ -172,7 +173,8 @@ fn get_item<'a>( item: (DefKind, &str), ) -> Option<&'a stable_mir::CrateItem> { items.iter().find(|crate_item| { - crate_item.kind().to_string() == format!("{:?}", item.0) && crate_item.name() == item.1 + matches!((item.0, crate_item.kind()), (DefKind::Fn, ItemKind::Fn) | (DefKind::Const, + ItemKind::Const)) && crate_item.name() == item.1 }) } diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/stable-mir/projections.rs index 9c649a2effc..d00f17d206b 100644 --- a/tests/ui-fulldeps/stable-mir/projections.rs +++ b/tests/ui-fulldeps/stable-mir/projections.rs @@ -19,11 +19,11 @@ extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; -use rustc_hir::def::DefKind; use rustc_middle::ty::TyCtxt; use rustc_smir::rustc_internal; use stable_mir::mir::{ProjectionElem, Rvalue, StatementKind}; use stable_mir::ty::{RigidTy, TyKind}; +use stable_mir::ItemKind; use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; @@ -33,7 +33,7 @@ const CRATE_NAME: &str = "input"; /// Tests projections within Place objects fn test_place_projections(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let items = stable_mir::all_local_items(); - let body = get_item(&items, (DefKind::Fn, "projections")).unwrap().body(); + let body = get_item(&items, (ItemKind::Fn, "projections")).unwrap().body(); assert_eq!(body.blocks.len(), 4); // The first statement assigns `&s.c` to a local. The projections include a deref for `s`, since // `s` is passed as a reference argument, and a field access for field `c`. @@ -131,10 +131,10 @@ fn test_place_projections(_tcx: TyCtxt<'_>) -> ControlFlow<()> { // Use internal API to find a function in a crate. fn get_item<'a>( items: &'a stable_mir::CrateItems, - item: (DefKind, &str), + item: (ItemKind, &str), ) -> Option<&'a stable_mir::CrateItem> { items.iter().find(|crate_item| { - crate_item.kind().to_string() == format!("{:?}", item.0) && crate_item.name() == item.1 + crate_item.kind() == item.0 && crate_item.name() == item.1 }) } diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs index de5148bb5f4..3ec63efcc06 100644 --- a/tests/ui-fulldeps/stable-mir/smir_visitor.rs +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -40,7 +40,7 @@ fn test_visitor(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let exit_fn = main_visitor.calls.last().unwrap(); assert!(exit_fn.mangled_name().contains("exit_fn"), "Unexpected last function: {exit_fn:?}"); - let exit_body = exit_fn.body(); + let exit_body = exit_fn.body().unwrap(); let exit_visitor = TestVisitor::collect(&exit_body); assert!(exit_visitor.ret_val.is_some()); assert_eq!(exit_visitor.args.len(), 1); diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 0cdf229711a..53e1eff9d72 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -231,8 +231,7 @@ macro_rules! test_abi_compatible { }; } -// Compatibility of pointers is probably de-facto guaranteed, -// but that does not seem to be documented. +// Compatibility of pointers. test_abi_compatible!(ptr_mut, *const i32, *mut i32); test_abi_compatible!(ptr_pointee, *const i32, *const Vec<i32>); test_abi_compatible!(ref_mut, &i32, &mut i32); @@ -241,14 +240,15 @@ test_abi_compatible!(box_ptr, Box<i32>, *const i32); test_abi_compatible!(nonnull_ptr, NonNull<i32>, *const i32); test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32); -// Some further guarantees we will likely (have to) make. +// Compatibility of 1-ZST. test_abi_compatible!(zst_unit, Zst, ()); #[cfg(not(any(target_arch = "sparc64")))] test_abi_compatible!(zst_array, Zst, [u8; 0]); test_abi_compatible!(nonzero_int, NonZeroI32, i32); // `DispatchFromDyn` relies on ABI compatibility. -// This is interesting since these types are not `repr(transparent)`. +// This is interesting since these types are not `repr(transparent)`. So this is not part of our +// public ABI guarantees, but is relied on by the compiler. test_abi_compatible!(rc, Rc<i32>, *mut i32); test_abi_compatible!(arc, Arc<i32>, *mut i32); diff --git a/tests/ui/match/issue-92100.stderr b/tests/ui/match/issue-92100.stderr index 0f694c587fc..d0e50f3ae16 100644 --- a/tests/ui/match/issue-92100.stderr +++ b/tests/ui/match/issue-92100.stderr @@ -3,6 +3,11 @@ error[E0425]: cannot find value `a` in this scope | LL | [a.., a] => {} | ^ not found in this scope + | +help: if you meant to collect the rest of the slice in `a`, use the at operator + | +LL | [a @ .., a] => {} + | + error: aborting due to previous error diff --git a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs new file mode 100644 index 00000000000..a619fcafc86 --- /dev/null +++ b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs @@ -0,0 +1,9 @@ +fn main() { + match &[1, 2, 3][..] { + [1, rest..] => println!("{rest:?}"), + //~^ ERROR cannot find value `rest` in this scope + //~| ERROR cannot find value `rest` in this scope + //~| ERROR `X..` patterns in slices are experimental + _ => {} + } +} diff --git a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr new file mode 100644 index 00000000000..cddd0121279 --- /dev/null +++ b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr @@ -0,0 +1,30 @@ +error[E0425]: cannot find value `rest` in this scope + --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13 + | +LL | [1, rest..] => println!("{rest:?}"), + | ^^^^ not found in this scope + | +help: if you meant to collect the rest of the slice in `rest`, use the at operator + | +LL | [1, rest @ ..] => println!("{rest:?}"), + | + + +error[E0425]: cannot find value `rest` in this scope + --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:35 + | +LL | [1, rest..] => println!("{rest:?}"), + | ^^^^ not found in this scope + +error[E0658]: `X..` patterns in slices are experimental + --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13 + | +LL | [1, rest..] => println!("{rest:?}"), + | ^^^^^^ + | + = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information + = help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/typeck/issue-105946.stderr b/tests/ui/typeck/issue-105946.stderr index 26c3b7fbc84..2220271e581 100644 --- a/tests/ui/typeck/issue-105946.stderr +++ b/tests/ui/typeck/issue-105946.stderr @@ -3,6 +3,11 @@ error[E0425]: cannot find value `_y` in this scope | LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^ not found in this scope + | +help: if you meant to collect the rest of the slice in `_y`, use the at operator + | +LL | let [_y @ ..] = [Box::new(1), Box::new(2)]; + | + error[E0658]: `X..` patterns in slices are experimental --> $DIR/issue-105946.rs:6:10 |
