]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/drop.rs
Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkov
[rust.git] / src / test / codegen / drop.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4
5 struct SomeUniqueName;
6
7 impl Drop for SomeUniqueName {
8     fn drop(&mut self) {
9     }
10 }
11
12 pub fn possibly_unwinding() {
13 }
14
15 // CHECK-LABEL: @droppy
16 #[no_mangle]
17 pub fn droppy() {
18 // Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
19 // that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
20 // regular function exit. We used to have problems with quadratic growths of drop calls in such
21 // functions.
22 // CHECK-NOT: invoke{{.*}}drop{{.*}}SomeUniqueName
23 // CHECK: call{{.*}}drop{{.*}}SomeUniqueName
24 // CHECK: call{{.*}}drop{{.*}}SomeUniqueName
25 // CHECK-NOT: call{{.*}}drop{{.*}}SomeUniqueName
26 // CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
27 // CHECK: call{{.*}}drop{{.*}}SomeUniqueName
28 // CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
29 // CHECK: call{{.*}}drop{{.*}}SomeUniqueName
30 // CHECK-NOT: {{(call|invoke).*}}drop{{.*}}SomeUniqueName
31 // The next line checks for the } that ends the function definition
32 // CHECK-LABEL: {{^[}]}}
33     let _s = SomeUniqueName;
34     possibly_unwinding();
35     let _s = SomeUniqueName;
36     possibly_unwinding();
37     let _s = SomeUniqueName;
38     possibly_unwinding();
39 }