Skip to content

Commit a392d91

Browse files
committed
rollup merge of #21362: aochagavia/copy_rawptr
Fixes #21272 and #21296 r? @cmr
2 parents ddcfb15 + 8b84f09 commit a392d91

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustc/lint/builtin.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,15 @@ impl LintPass for RawPointerDerive {
592592
return
593593
}
594594
let did = match item.node {
595-
ast::ItemImpl(..) => {
595+
ast::ItemImpl(_, _, _, ref t_ref_opt, _, _) => {
596+
// Deriving the Copy trait does not cause a warning
597+
if let &Some(ref trait_ref) = t_ref_opt {
598+
let def_id = ty::trait_ref_to_def_id(cx.tcx, trait_ref);
599+
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
600+
return
601+
}
602+
}
603+
596604
match ty::node_id_to_type(cx.tcx, item.id).sty {
597605
ty::ty_enum(did, _) => did,
598606
ty::ty_struct(did, _) => did,

src/test/run-pass/issue-21296.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
#[forbid(raw_pointer_derive)]
12+
#[derive(Copy)]
13+
struct Test(*const i32);
14+
15+
fn main() {}

0 commit comments

Comments
 (0)