Skip to content

Commit

Permalink
Remove rustc_version from dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Nov 7, 2019
1 parent 3cbbbaa commit ca23e47
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ quote = "1"
syn = { version = "1", features = ["extra-traits"] }

[build-dependencies]
rustc_version = "0.2"
peg = { version = "0.5", optional = true }

[badges]
Expand Down
14 changes: 1 addition & 13 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
extern crate rustc_version;

#[cfg(feature = "generate-parsing-rs")]
extern crate peg;

use rustc_version::{version_meta, Channel};

#[cfg(not(feature = "generate-parsing-rs"))]
fn main() {
if version_meta().unwrap().channel == Channel::Nightly {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}
}
fn main() {}

#[cfg(feature = "generate-parsing-rs")]
fn main() {
if version_meta().unwrap().channel == Channel::Nightly {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}

let contents = match ::std::fs::read_to_string("src/parsing.rustpeg") {
Ok(contents) => contents,
Err(e) => panic!("{}", e),
Expand Down
12 changes: 5 additions & 7 deletions doc/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ E.g. `Octal` -> `octal`, `Pointer` -> `pointer`, `UpperHex` -> `upper_hex`.

# Generic data types

When deriving `Display` (or other formatting trait) for a generic struct/enum, all generic type
When deriving `Display` (or other formatting trait) for a generic struct/enum, all generic type
arguments used during formatting are bound by respective formatting trait.

E.g., for a structure `Foo` defined like this:
Expand Down Expand Up @@ -63,7 +63,7 @@ The following where clauses would be generated:
Sometimes you may want to specify additional trait bounds on your generic type parameters, so that they
could be used during formatting. This can be done with a `#[display(bound = "...")]` attribute.

`#[display(bound = "...")]` accepts a single string argument in a format similar to the format
`#[display(bound = "...")]` accepts a single string argument in a format similar to the format
used in angle bracket list: `T: MyTrait, U: Trait1 + Trait2`.

Only type parameters defined on a struct allowed to appear in bound-string and they can only be bound
Expand All @@ -75,9 +75,9 @@ used this way. That means that you'll **have to** explicitly specify all trait b
struct/enum definition, or via `#[display(bound = "...")]` attribute.

Note how we have to bound `U` and `V` by `Display` in the following example, as no bound is inferred.
Not even `Display`.
Not even `Display`.

Also note, that `"c"` case is just a curious example. Bound inference works as expected if you simply
Also note, that `"c"` case is just a curious example. Bound inference works as expected if you simply
write `c` without double-quotes.

```rust
Expand All @@ -87,7 +87,7 @@ write `c` without double-quotes.

#[derive(Display)]
#[display(bound = "T: MyTrait, U: Display, V: Display")]
#[display(fmt = "{} {} {}", "a.my_function()", "b.to_string().len()", "c")]
#[display(fmt = "{} {} {}", "a.my_function()", "b.to_string().len()", "c")]
struct MyStruct<T, U, V> {
a: T,
b: U,
Expand Down Expand Up @@ -119,7 +119,6 @@ enum E {
Binary {
i: i8,
},
#[cfg(feature = "nightly")]
#[display(fmt = "I am C {}", "_0.display()")]
Path(PathBuf),
}
Expand Down Expand Up @@ -158,7 +157,6 @@ fn main() {
assert_eq!(Point2D { x: 3, y: 4 }.to_string(), "(3, 4)");
assert_eq!(E::Uint(2).to_string(), "2");
assert_eq!(E::Binary { i: -2 }.to_string(), "I am B 11111110");
#[cfg(feature = "nightly")]
assert_eq!(E::Path("abc".into()).to_string(), "I am C abc");
assert_eq!(EE::A.to_string(), "Java EE: A");
assert_eq!(EE::B.to_string(), "Java EE: B");
Expand Down
2 changes: 0 additions & 2 deletions tests/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum E {
Binary {
i: i8,
},
#[cfg(feature = "nightly")]
#[display(fmt = "I am C {}", "_0.display()")]
Path(PathBuf),
}
Expand Down Expand Up @@ -104,7 +103,6 @@ fn check_display() {
assert_eq!(Error::new("Error").to_string(), "Error");
assert_eq!(E::Uint(2).to_string(), "2");
assert_eq!(E::Binary { i: -2 }.to_string(), "I am B 11111110");
#[cfg(feature = "nightly")]
assert_eq!(E::Path("abc".into()).to_string(), "I am C abc");
assert_eq!(EE::A.to_string(), "Java EE");
assert_eq!(EE::B.to_string(), "Java EE");
Expand Down

0 comments on commit ca23e47

Please sign in to comment.