Skip to content

Commit 51ff9e8

Browse files
committed
Rollup merge of #21602 - japaric:derive-copy, r=alexcrichton
2 parents 8418725 + bff4623 commit 51ff9e8

File tree

99 files changed

+136
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+136
-289
lines changed

src/compiletest/common.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313
use std::str::FromStr;
1414

1515
#[cfg(stage0)] // NOTE: remove impl after snapshot
16-
#[derive(Clone, PartialEq, Show)]
16+
#[derive(Clone, Copy, PartialEq, Show)]
1717
pub enum Mode {
1818
CompileFail,
1919
RunFail,
@@ -26,7 +26,7 @@ pub enum Mode {
2626
}
2727

2828
#[cfg(not(stage0))] // NOTE: remove cfg after snapshot
29-
#[derive(Clone, PartialEq, Debug)]
29+
#[derive(Clone, Copy, PartialEq, Debug)]
3030
pub enum Mode {
3131
CompileFail,
3232
RunFail,
@@ -38,9 +38,6 @@ pub enum Mode {
3838
Codegen
3939
}
4040

41-
42-
impl Copy for Mode {}
43-
4441
impl FromStr for Mode {
4542
fn from_str(s: &str) -> Option<Mode> {
4643
match s {

src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,8 +1680,8 @@ specific type.
16801680
Implementations are defined with the keyword `impl`.
16811681

16821682
```
1683+
# #[derive(Copy)]
16831684
# struct Point {x: f64, y: f64};
1684-
# impl Copy for Point {}
16851685
# type Surface = i32;
16861686
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
16871687
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }

src/etc/unicode.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,13 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
392392
use core::slice;
393393
394394
#[allow(non_camel_case_types)]
395-
#[derive(Clone)]
395+
#[derive(Clone, Copy)]
396396
pub enum GraphemeCat {
397397
""")
398398
for cat in grapheme_cats + ["Any"]:
399399
f.write(" GC_" + cat + ",\n")
400400
f.write(""" }
401401
402-
impl Copy for GraphemeCat {}
403-
404402
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
405403
use core::cmp::Ordering::{Equal, Less, Greater};
406404
match r.binary_search(|&(lo, hi, _)| {

src/libcore/ops.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,9 @@ rem_float_impl! { f64, fmod }
445445
/// ```
446446
/// use std::ops::Neg;
447447
///
448+
/// #[derive(Copy)]
448449
/// struct Foo;
449450
///
450-
/// impl Copy for Foo {}
451-
///
452451
/// impl Neg for Foo {
453452
/// type Output = Foo;
454453
///
@@ -522,10 +521,9 @@ neg_uint_impl! { u64, i64 }
522521
/// ```
523522
/// use std::ops::Not;
524523
///
524+
/// #[derive(Copy)]
525525
/// struct Foo;
526526
///
527-
/// impl Copy for Foo {}
528-
///
529527
/// impl Not for Foo {
530528
/// type Output = Foo;
531529
///

src/librustc_llvm/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ impl OptimizationDiagnosticKind {
3737
}
3838
}
3939

40+
#[allow(raw_pointer_derive)]
41+
#[derive(Copy)]
4042
pub struct OptimizationDiagnostic {
4143
pub kind: OptimizationDiagnosticKind,
4244
pub pass_name: *const c_char,
@@ -45,8 +47,6 @@ pub struct OptimizationDiagnostic {
4547
pub message: TwineRef,
4648
}
4749

48-
impl Copy for OptimizationDiagnostic {}
49-
5050
impl OptimizationDiagnostic {
5151
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
5252
-> OptimizationDiagnostic {

src/libstd/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@ pub struct MemoryMap {
815815
}
816816

817817
/// Type of memory map
818+
#[allow(raw_pointer_derive)]
819+
#[derive(Copy)]
818820
pub enum MemoryMapKind {
819821
/// Virtual memory map. Usually used to change the permissions of a given
820822
/// chunk of memory. Corresponds to `VirtualAlloc` on Windows.
@@ -825,9 +827,9 @@ pub enum MemoryMapKind {
825827
MapVirtual
826828
}
827829

828-
impl Copy for MemoryMapKind {}
829-
830830
/// Options the memory map is created with
831+
#[allow(raw_pointer_derive)]
832+
#[derive(Copy)]
831833
pub enum MapOption {
832834
/// The memory should be readable
833835
MapReadable,
@@ -854,8 +856,6 @@ pub enum MapOption {
854856
MapNonStandardFlags(c_int),
855857
}
856858

857-
impl Copy for MapOption {}
858-
859859
/// Possible errors when creating a map.
860860
#[derive(Copy, Show)]
861861
pub enum MapError {

src/libunicode/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ mod std {
8282
pub use core::clone;
8383
pub use core::cmp;
8484
pub use core::fmt;
85+
pub use core::marker;
8586
}

src/libunicode/tables.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7801,13 +7801,12 @@ pub mod charwidth {
78017801
}
78027802

78037803
pub mod grapheme {
7804-
use core::marker::Copy;
78057804
use core::slice::SliceExt;
78067805
pub use self::GraphemeCat::*;
78077806
use core::result::Result::{Ok, Err};
78087807

78097808
#[allow(non_camel_case_types)]
7810-
#[derive(Clone)]
7809+
#[derive(Clone, Copy)]
78117810
pub enum GraphemeCat {
78127811
GC_LV,
78137812
GC_LVT,
@@ -7821,8 +7820,6 @@ pub mod grapheme {
78217820
GC_Any,
78227821
}
78237822

7824-
impl Copy for GraphemeCat {}
7825-
78267823
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
78277824
use core::cmp::Ordering::{Equal, Less, Greater};
78287825
match r.binary_search_by(|&(lo, hi, _)| {

src/libunicode/u_str.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,14 @@ pub struct Utf16Items<'a> {
410410
iter: slice::Iter<'a, u16>
411411
}
412412
/// The possibilities for values decoded from a `u16` stream.
413-
#[derive(PartialEq, Eq, Clone, Show)]
413+
#[derive(Copy, PartialEq, Eq, Clone, Show)]
414414
pub enum Utf16Item {
415415
/// A valid codepoint.
416416
ScalarValue(char),
417417
/// An invalid surrogate without its pair.
418418
LoneSurrogate(u16)
419419
}
420420

421-
impl Copy for Utf16Item {}
422-
423421
impl Utf16Item {
424422
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
425423
/// replacement character (U+FFFD).

src/test/auxiliary/issue-14422.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ mod src {
2323
pub mod hidden_core {
2424
use super::aliases::B;
2525

26+
#[derive(Copy)]
2627
pub struct A;
2728

28-
impl Copy for A {}
29-
3029
pub fn make() -> B { A }
3130

3231
impl A {

0 commit comments

Comments
 (0)