Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust Reference still talks about #[deriving(...)], instead of #[derive(...)] #20984

Closed
jimblandy opened this issue Jan 12, 2015 · 2 comments
Closed

Comments

@jimblandy
Copy link
Contributor

It seems that #[deriving(Show)] has stopped defining the Show trait for structs.

In the code below, if I remove the #[cfg(skip)] before the explicit Show derivation, the program runs correctly.

$ cargo --version
cargo 0.0.1-pre-nightly (8c01b6b 2015-01-08 20:52:43 +0000)
$ rustc --version
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
$ cat src/main.rs
use std::fmt::{Error, Formatter, Show};

#[deriving(Show)]
struct Stuff;

#[cfg(skip)]
impl Show for Stuff {
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
        f.write_str("Stuff()")
    }
}

fn main() {
    let x = Stuff;
    assert_eq!(format!("{:?}", x), "Stuff()");
}
$ cargo run --verbose
   Compiling bug v0.0.1 (file:///home/jimb/rust/bug)
     Running `rustc /home/jimb/rust/bug/src/main.rs --crate-name bug --crate-type bin -g --out-dir /home/jimb/rust/bug/target --emit=dep-info,link -L dependency=/home/jimb/rust/bug/target -L dependency=/home/jimb/rust/bug/target/deps`
/home/jimb/rust/bug/src/main.rs:15:32: 15:33 error: the trait `core::fmt::Show` is not implemented for the type `Stuff`
/home/jimb/rust/bug/src/main.rs:15     assert_eq!(format!("{:?}", x), "Stuff()");
                                                                  ^
note: in expansion of format_args!
<std macros>:2:28: 2:61 note: expansion site
<std macros>:1:1: 2:63 note: in expansion of format!
/home/jimb/rust/bug/src/main.rs:15:16: 15:35 note: expansion site
<std macros>:1:1: 9:39 note: in expansion of assert_eq!
/home/jimb/rust/bug/src/main.rs:15:5: 15:47 note: expansion site
error: aborting due to previous error
Could not compile `bug`.

Caused by:
  Process didn't exit successfully: `rustc /home/jimb/rust/bug/src/main.rs --crate-name bug --crate-type bin -g --out-dir /home/jimb/rust/bug/target --emit=dep-info,link -L dependency=/home/jimb/rust/bug/target -L dependency=/home/jimb/rust/bug/target/deps` (status=101)
$
@jimblandy
Copy link
Contributor Author

Ah, sorry. This is a doc issue. #[derive(Show)] works. The Rust reference still describes deriving.

@jimblandy jimblandy changed the title #[deriving(Show)] doesn't derive Show Rust Reference still talks about #[deriving(...)], instead of #[derive(...)] Jan 12, 2015
@nrc nrc added the A-docs label Jan 12, 2015
@nrc
Copy link
Member

nrc commented Jan 12, 2015

cc @steveklabnik

@bors bors closed this as completed in 6ab95bd Jan 21, 2015
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
There are a large number of places that incorrectly refer
to deriving in comments, instead of derives.

Fixes rust-lang#20984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants