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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
353 B
Rust
Raw Normal View History

2020-08-19 10:05:44 +00: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 14:52:39 +00:00
fn unnameable_type() -> impl Drop {
struct Unnameable;
impl Drop for Unnameable {
2020-08-19 10:05:44 +00:00
fn drop(&mut self) {}
}
2023-09-05 14:52:39 +00:00
Unnameable
2020-08-19 10:05:44 +00:00
}
fn main() {
2023-09-05 14:52:39 +00:00
let _ = unnameable_type();
2020-08-19 10:05:44 +00:00
}