Skip to content

Commit 1fb707d

Browse files
Rollup merge of rust-lang#33362 - andradei:master, r=Manishearth
Add mention to RFC 940 in the Rust Reference. This PR adds a mention to hyphens in Cargo package names being replaced by underscores when used as a crate, as per [RFC 940](https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md) It also formats the RFCs consistently as RFC XXX instead of RFCXXX.
2 parents dc8212f + ba6ce12 commit 1fb707d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/doc/reference.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,20 @@ extern crate std; // equivalent to: extern crate std as std;
853853
extern crate std as ruststd; // linking to 'std' under another name
854854
```
855855

856+
When naming Rust crates, hyphens are disallowed. However, Cargo packages may
857+
make use of them. In such case, when `Cargo.toml` doesn't specify a crate name,
858+
Cargo will transparently replace `-` with `_` (Refer to [RFC 940] for more
859+
details).
860+
861+
Here is an example:
862+
863+
```{.ignore}
864+
// Importing the Cargo package hello-world
865+
extern crate hello_world; // hyphen replaced with an underscore
866+
```
867+
868+
[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
869+
856870
#### Use declarations
857871

858872
A _use declaration_ creates one or more local name bindings synonymous with
@@ -3744,9 +3758,9 @@ Since `'static` "lives longer" than `'a`, `&'static str` is a subtype of
37443758

37453759
## Type coercions
37463760

3747-
Coercions are defined in [RFC401]. A coercion is implicit and has no syntax.
3761+
Coercions are defined in [RFC 401]. A coercion is implicit and has no syntax.
37483762

3749-
[RFC401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
3763+
[RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
37503764

37513765
### Coercion sites
37523766

@@ -3886,7 +3900,7 @@ Coercion is allowed between the following types:
38863900

38873901
In the future, coerce_inner will be recursively extended to tuples and
38883902
structs. In addition, coercions from sub-traits to super-traits will be
3889-
added. See [RFC401] for more details.
3903+
added. See [RFC 401] for more details.
38903904

38913905
# Special traits
38923906

0 commit comments

Comments
 (0)