Skip to content

Commit ad558c4

Browse files
committed
---
yaml --- r: 207821 b: refs/heads/snap-stage3 c: 2e23d81 h: refs/heads/master i: 207819: db6b54b v: v3
1 parent edf002e commit ad558c4

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 78130a4690997ba0c2090e0b6d752ad37cb07b5c
4+
refs/heads/snap-stage3: 2e23d8196e94d5b4a8c383e834829f900ab368c3
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check we reject structs that mix a `Drop` impl with `#[repr(C)]`.
12+
//
13+
// As a special case, also check that we do not warn on such structs
14+
// if they also are declared with `#[unsafe_no_drop_flag]`
15+
16+
#![feature(unsafe_no_drop_flag)]
17+
#![deny(drop_with_repr_extern)]
18+
19+
#[repr(C)] struct As { x: Box<i8> }
20+
#[repr(C)] enum Ae { Ae(Box<i8>), _None }
21+
22+
struct Bs { x: Box<i8> }
23+
enum Be { Be(Box<i8>), _None }
24+
25+
#[repr(C)] struct Cs { x: Box<i8> }
26+
//~^ NOTE the `#[repr(C)]` attribute is attached here
27+
28+
impl Drop for Cs { fn drop(&mut self) { } }
29+
//~^ ERROR implementing Drop adds hidden state to types, possibly conflicting with `#[repr(C)]`
30+
31+
#[repr(C)] enum Ce { Ce(Box<i8>), _None }
32+
//~^ NOTE the `#[repr(C)]` attribute is attached here
33+
34+
impl Drop for Ce { fn drop(&mut self) { } }
35+
//~^ ERROR implementing Drop adds hidden state to types, possibly conflicting with `#[repr(C)]`
36+
37+
#[unsafe_no_drop_flag]
38+
#[repr(C)] struct Ds { x: Box<i8> }
39+
40+
impl Drop for Ds { fn drop(&mut self) { } }
41+
42+
#[unsafe_no_drop_flag]
43+
#[repr(C)] enum De { De(Box<i8>), _None }
44+
45+
impl Drop for De { fn drop(&mut self) { } }
46+
47+
fn main() {
48+
let a = As { x: Box::new(3) };
49+
let b = Bs { x: Box::new(3) };
50+
let c = Cs { x: Box::new(3) };
51+
let d = Ds { x: Box::new(3) };
52+
53+
println!("{:?}", (*a.x, *b.x, *c.x, *d.x));
54+
55+
let _a = Ae::Ae(Box::new(3));
56+
let _b = Be::Be(Box::new(3));
57+
let _c = Ce::Ce(Box::new(3));
58+
let _d = De::De(Box::new(3));
59+
}

0 commit comments

Comments
 (0)