rust/tests/ui/drop-bounds/drop-bounds-impl-drop.rs

15 lines
352 B
Rust
Raw Normal View History

2020-08-19 05:05:44 -05:00
// run-pass
#![deny(drop_bounds)]
// As a special exemption, `impl Drop` in the return position raises no error.
// This allows a convenient way to return an unnamed drop guard.
2023-09-05 09:52:39 -05:00
fn unnameable_type() -> impl Drop {
struct Unnameable;
impl Drop for Unnameable {
2020-08-19 05:05:44 -05:00
fn drop(&mut self) {}
}
2023-09-05 09:52:39 -05:00
Unnameable
2020-08-19 05:05:44 -05:00
}
fn main() {
2023-09-05 09:52:39 -05:00
let _ = unnameable_type();
2020-08-19 05:05:44 -05:00
}