diff options
| author | Arthur Carcano <arthur.carcano@ocamlpro.com> | 2023-08-02 14:47:38 +0200 |
|---|---|---|
| committer | Arthur Carcano <arthur.carcano@ocamlpro.com> | 2023-10-16 18:49:25 +0200 |
| commit | 0bcac8a7f25b994ddd3c2deda74dae04c677b816 (patch) | |
| tree | 2608c9c74afb59f2d8ae4542638f78c05e03b695 /tests/codegen | |
| parent | e7bdc5f9f869219e8d20060b42a09ea10a837851 (diff) | |
| download | rust-0bcac8a7f25b994ddd3c2deda74dae04c677b816.tar.gz rust-0bcac8a7f25b994ddd3c2deda74dae04c677b816.zip | |
Add invariant to Vec::pop that len < cap if pop successful
Fixes: https://github.com/rust-lang/rust/issues/114334
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/vec_pop_push_noop.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/codegen/vec_pop_push_noop.rs b/tests/codegen/vec_pop_push_noop.rs new file mode 100644 index 00000000000..8bc7b68a816 --- /dev/null +++ b/tests/codegen/vec_pop_push_noop.rs @@ -0,0 +1,24 @@ +// compile-flags: -O + +#![crate_type = "lib"] + +#[no_mangle] +// CHECK-LABEL: @noop( +pub fn noop(v: &mut Vec<u8>) { + // CHECK-NOT: reserve_for_push + // CHECK-NOT: call + // CHECK: tail call void @llvm.assume + // CHECK-NOT: reserve_for_push + // CHECK-NOT: call + // CHECK: ret + if let Some(x) = v.pop() { + v.push(x) + } +} + +#[no_mangle] +// CHECK-LABEL: @push_byte( +pub fn push_byte(v: &mut Vec<u8>) { + // CHECK: call {{.*}}reserve_for_push + v.push(3); +} |
