Skip to content

Commit 1962ade

Browse files
committed
Auto merge of #60877 - Centril:rollup-j0o5mo5, r=Centril
Rollup of 6 pull requests Successful merges: - #59825 (string: implement From<&String> for String) - #59923 (Fix convert module's documentation links) - #60691 (Include expression to wait for to the span of Await) - #60769 (Update rustc book CLI docs.) - #60816 (README.md: Mention MSVC 2017+, not 2013(!)) - #60851 (Move `box` from the stable keyword to unstable keywords list) Failed merges: r? @ghost
2 parents 472211a + b59ce94 commit 1962ade

File tree

8 files changed

+197
-38
lines changed

8 files changed

+197
-38
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,15 @@ build.
128128
#### MSVC
129129
[windows-msvc]: #windows-msvc
130130

131-
MSVC builds of Rust additionally require an installation of Visual Studio 2013
132-
(or later) so `rustc` can use its linker. Make sure to check the “C++ tools”
133-
option.
131+
MSVC builds of Rust additionally require an installation of Visual Studio 2017
132+
(or later) so `rustc` can use its linker. The simplest way is to get the
133+
[Visual Studio Build Tools] and check the “C++ build tools” workload.
134+
135+
[Visual Studio Build Tools]: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
136+
137+
At last check (cmake 3.14.3 and msvc 16.0.3) using the 2019 tools fails to
138+
build the in-tree LLVM build with a CMake error, so use 2017 instead by
139+
including the “MSVC v141 – VS 2017 C++ x64/x86 build tools (v14.16)” component.
134140

135141
With these dependencies installed, you can build the compiler in a `cmd.exe`
136142
shell with:

src/doc/rustc/src/command-line-arguments.md

+156-11
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,147 @@ to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
1717

1818
## `-L`: add a directory to the library search path
1919

20-
When looking for external crates, a directory passed to this flag will be searched.
20+
When looking for external crates or libraries, a directory passed to this flag
21+
will be searched.
22+
23+
The kind of search path can optionally be specified with the form `-L
24+
KIND=PATH` where `KIND` may be one of:
25+
26+
- `dependency` — Only search for transitive dependencies in this directory.
27+
- `crate` — Only search for this crate's direct dependencies in this
28+
directory.
29+
- `native` — Only search for native libraries in this directory.
30+
- `framework` — Only search for macOS frameworks in this directory.
31+
- `all` — Search for all library kinds in this directory. This is the default
32+
if `KIND` is not specified.
2133

2234
## `-l`: link the generated crate to a native library
2335

2436
This flag allows you to specify linking to a specific native library when building
2537
a crate.
2638

39+
The kind of library can optionally be specified with the form `-l KIND=lib`
40+
where `KIND` may be one of:
41+
42+
- `dylib` — A native dynamic library.
43+
- `static` — A native static library (such as a `.a` archive).
44+
- `framework` — A macOS framework.
45+
46+
The kind of library can be specified in a [`#[link]`
47+
attribute][link-attribute]. If the kind is not specified in the `link`
48+
attribute or on the command-line, it will link a dynamic library if available,
49+
otherwise it will use a static library. If the kind is specified on the
50+
command-line, it will override the kind specified in a `link` attribute.
51+
52+
The name used in a `link` attribute may be overridden using the form `-l
53+
ATTR_NAME:LINK_NAME` where `ATTR_NAME` is the name in the `link` attribute,
54+
and `LINK_NAME` is the name of the actual library that will be linked.
55+
56+
[link-attribute]: ../reference/items/external-blocks.html#the-link-attribute
57+
2758
## `--crate-type`: a list of types of crates for the compiler to emit
2859

29-
This instructs `rustc` on which crate type to build.
60+
This instructs `rustc` on which crate type to build. This flag accepts a
61+
comma-separated list of values, and may be specified multiple times. The valid
62+
crate types are:
63+
64+
- `lib` — Generates a library kind preferred by the compiler, currently
65+
defaults to `rlib`.
66+
- `rlib` — A Rust static library.
67+
- `staticlib` — A native static library.
68+
- `dylib` — A Rust dynamic library.
69+
- `cdylib` — A native dynamic library.
70+
- `bin` — A runnable executable program.
71+
- `proc-macro` — Generates a format suitable for a procedural macro library
72+
that may be loaded by the compiler.
73+
74+
The crate type may be specified with the [`crate_type` attribute][crate_type].
75+
The `--crate-type` command-line value will override the `crate_type`
76+
attribute.
77+
78+
More details may be found in the [linkage chapter] of the reference.
79+
80+
[linkage chapter]: ../reference/linkage.html
81+
[crate_type]: ../reference/linkage.html
3082

3183
## `--crate-name`: specify the name of the crate being built
3284

3385
This informs `rustc` of the name of your crate.
3486

35-
## `--emit`: emit output other than a crate
36-
37-
Instead of producing a crate, this flag can print out things like the assembly or LLVM-IR.
87+
## `--edition`: specify the edition to use
88+
89+
This flag takes a value of `2015` or `2018`. The default is `2015`. More
90+
information about editions may be found in the [edition guide].
91+
92+
[edition guide]: ../edition-guide/introduction.html
93+
94+
## `--emit`: specifies the types of output files to generate
95+
96+
This flag controls the types of output files generated by the compiler. It
97+
accepts a comma-separated list of values, and may be specified multiple times.
98+
The valid emit kinds are:
99+
100+
- `asm` — Generates a file with the crate's assembly code. The default output
101+
filename is `CRATE_NAME.s`.
102+
- `dep-info` — Generates a file with Makefile syntax that indicates all the
103+
source files that were loaded to generate the crate. The default output
104+
filename is `CRATE_NAME.d`.
105+
- `link` — Generates the crates specified by `--crate-type`. The default
106+
output filenames depend on the crate type and platform. This is the default
107+
if `--emit` is not specified.
108+
- `llvm-bc` — Generates a binary file containing the [LLVM bitcode]. The
109+
default output filename is `CRATE_NAME.bc`.
110+
- `llvm-ir` — Generates a file containing [LLVM IR]. The default output
111+
filename is `CRATE_NAME.ll`.
112+
- `metadata` — Generates a file containing metadata about the crate. The
113+
default output filename is `CRATE_NAME.rmeta`.
114+
- `mir` — Generates a file containing rustc's mid-level intermediate
115+
representation. The default output filename is `CRATE_NAME.mir`.
116+
- `obj` — Generates a native object file. The default output filename is
117+
`CRATE_NAME.o`.
118+
119+
The output filename can be set with the `-o` flag. A suffix may be added to
120+
the filename with the `-C extra-filename` flag. The files are written to the
121+
current directory unless the `--out-dir` flag is used. Each emission type may
122+
also specify the output filename with the form `KIND=PATH`, which takes
123+
precedence over the `-o` flag.
124+
125+
[LLVM bitcode]: https://llvm.org/docs/BitCodeFormat.html
126+
[LLVM IR]: https://llvm.org/docs/LangRef.html
38127

39128
## `--print`: print compiler information
40129

41-
This flag prints out various information about the compiler.
130+
This flag prints out various information about the compiler. This flag may be
131+
specified multiple times, and the information is printed in the order the
132+
flags are specified. Specifying a `--print` flag will usually disable the
133+
`--emit` step and will only print the requested information. The valid types
134+
of print values are:
135+
136+
- `crate-name` — The name of the crate.
137+
- `file-names` — The names of the files created by the `link` emit kind.
138+
- `sysroot` — Path to the sysroot.
139+
- `cfg` — List of cfg values. See [conditional compilation] for more
140+
information about cfg values.
141+
- `target-list` — List of known targets. The target may be selected with the
142+
`--target` flag.
143+
- `target-cpus` — List of available CPU values for the current target. The
144+
target CPU may be selected with the `-C target-cpu=val` flag.
145+
- `target-features` — List of available target features for the current
146+
target. Target features may be enabled with the `-C target-feature=val`
147+
flag.
148+
- `relocation-models` — List of relocation models. Relocation models may be
149+
selected with the `-C relocation-model=val` flag.
150+
- `code-models` — List of code models. Code models may be selected with the
151+
`-C code-model=val` flag.
152+
- `tls-models` — List of Thread Local Storage models supported. The model may
153+
be selected with the `-Z tls-model=val` flag.
154+
- `native-static-libs` — This may be used when creating a `staticlib` crate
155+
type. If this is the only flag, it will perform a full compilation and
156+
include a diagnostic note that indicates the linker flags to use when
157+
linking the resulting static library. The note starts with the text
158+
`native-static-libs:` to make it easier to fetch the output.
159+
160+
[conditional compilation]: ../reference/conditional-compilation.html
42161

43162
## `-g`: include debug information
44163

@@ -54,7 +173,8 @@ This flag controls the output filename.
54173

55174
## `--out-dir`: directory to write the output in
56175

57-
The outputted crate will be written to this directory.
176+
The outputted crate will be written to this directory. This flag is ignored if
177+
the `-o` flag is used.
58178

59179
## `--explain`: provide a detailed explanation of an error message
60180

@@ -111,8 +231,9 @@ This flag, when combined with other flags, makes them produce extra output.
111231

112232
## `--extern`: specify where an external library is located
113233

114-
This flag allows you to pass the name and location of an external crate that will
115-
be linked into the crate you're buildling.
234+
This flag allows you to pass the name and location of an external crate that
235+
will be linked into the crate you are building. This flag may be specified
236+
multiple times. The format of the value should be `CRATENAME=PATH`.
116237

117238
## `--sysroot`: Override the system root
118239

@@ -121,8 +242,32 @@ distribution; this flag allows that to be overridden.
121242

122243
## `--error-format`: control how errors are produced
123244

124-
This flag lets you control the format of errors.
245+
This flag lets you control the format of messages. Messages are printed to
246+
stderr. The valid options are:
247+
248+
- `human` — Human-readable output. This is the default.
249+
- `json` — Structured JSON output.
250+
- `short` — Short, one-line messages.
125251

126252
## `--color`: configure coloring of output
127253

128-
This flag lets you control color settings of the output.
254+
This flag lets you control color settings of the output. The valid options
255+
are:
256+
257+
- `auto` — Use colors if output goes to a tty. This is the default.
258+
- `always` — Always use colors.
259+
- `never` — Never colorize output.
260+
261+
## `--remap-path-prefix`: remap source names in output
262+
263+
Remap source path prefixes in all output, including compiler diagnostics,
264+
debug information, macro expansions, etc. It takes a value of the form
265+
`FROM=TO` where a path prefix equal to `FROM` is rewritten to the value `TO`.
266+
The `FROM` may itself contain an `=` symbol, but the `TO` value may not. This
267+
flag may be specified multiple times.
268+
269+
This is useful for normalizing build products, for example by removing the
270+
current directory out of pathnames emitted into the object files. The
271+
replacement is purely textual, with no consideration of the current system's
272+
pathname syntax. For example `--remap-path-prefix foo=bar` will match
273+
`foo/lib.rs` but not `./foo/lib.rs`.

src/liballoc/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,14 @@ impl From<&str> for String {
21892189
}
21902190
}
21912191

2192+
#[stable(feature = "from_ref_string", since = "1.35.0")]
2193+
impl From<&String> for String {
2194+
#[inline]
2195+
fn from(s: &String) -> String {
2196+
s.clone()
2197+
}
2198+
}
2199+
21922200
// note: test pulls in libstd, which causes errors here
21932201
#[cfg(not(test))]
21942202
#[stable(feature = "string_from_box", since = "1.18.0")]

src/libcore/convert.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub const fn identity<T>(x: T) -> T { x }
104104
/// If you need to do a costly conversion it is better to implement [`From`] with type
105105
/// `&T` or write a custom function.
106106
///
107-
///
108107
/// `AsRef` has the same signature as [`Borrow`], but `Borrow` is different in few aspects:
109108
///
110109
/// - Unlike `AsRef`, `Borrow` has a blanket impl for any `T`, and can be used to accept either
@@ -133,7 +132,7 @@ pub const fn identity<T>(x: T) -> T { x }
133132
/// converted a the specified type `T`.
134133
///
135134
/// For example: By creating a generic function that takes an `AsRef<str>` we express that we
136-
/// want to accept all references that can be converted to &str as an argument.
135+
/// want to accept all references that can be converted to `&str` as an argument.
137136
/// Since both [`String`] and `&str` implement `AsRef<str>` we can accept both as input argument.
138137
///
139138
/// [`String`]: ../../std/string/struct.String.html
@@ -149,7 +148,6 @@ pub const fn identity<T>(x: T) -> T { x }
149148
/// let s = "hello".to_string();
150149
/// is_hello(s);
151150
/// ```
152-
///
153151
#[stable(feature = "rust1", since = "1.0.0")]
154152
pub trait AsRef<T: ?Sized> {
155153
/// Performs the conversion.
@@ -182,6 +180,7 @@ pub trait AsRef<T: ?Sized> {
182180
/// write a function `add_one`that takes all arguments that can be converted to `&mut u64`.
183181
/// Because [`Box<T>`] implements `AsMut<T>` `add_one` accepts arguments of type
184182
/// `&mut Box<u64>` as well:
183+
///
185184
/// ```
186185
/// fn add_one<T: AsMut<u64>>(num: &mut T) {
187186
/// *num.as_mut() += 1;
@@ -191,8 +190,8 @@ pub trait AsRef<T: ?Sized> {
191190
/// add_one(&mut boxed_num);
192191
/// assert_eq!(*boxed_num, 1);
193192
/// ```
194-
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
195193
///
194+
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
196195
#[stable(feature = "rust1", since = "1.0.0")]
197196
pub trait AsMut<T: ?Sized> {
198197
/// Performs the conversion.
@@ -203,18 +202,18 @@ pub trait AsMut<T: ?Sized> {
203202
/// A value-to-value conversion that consumes the input value. The
204203
/// opposite of [`From`].
205204
///
206-
/// One should only implement [`Into`] if a conversion to a type outside the current crate is
207-
/// required. Otherwise one should always prefer implementing [`From`] over [`Into`] because
208-
/// implementing [`From`] automatically provides one with a implementation of [`Into`] thanks to
205+
/// One should only implement `Into` if a conversion to a type outside the current crate is
206+
/// required. Otherwise one should always prefer implementing [`From`] over `Into` because
207+
/// implementing [`From`] automatically provides one with a implementation of `Into` thanks to
209208
/// the blanket implementation in the standard library. [`From`] cannot do these type of
210209
/// conversions because of Rust's orphaning rules.
211210
///
212211
/// **Note: This trait must not fail**. If the conversion can fail, use [`TryInto`].
213212
///
214213
/// # Generic Implementations
215214
///
216-
/// - [`From<T>`]` for U` implies `Into<U> for T`
217-
/// - [`Into`]` is reflexive, which means that `Into<T> for T` is implemented
215+
/// - [`From`]`<T> for U` implies `Into<U> for T`
216+
/// - `Into` is reflexive, which means that `Into<T> for T` is implemented
218217
///
219218
/// # Implementing `Into` for conversions to external types
220219
///
@@ -273,7 +272,7 @@ pub trait AsMut<T: ?Sized> {
273272
/// [`Option<T>`]: ../../std/option/enum.Option.html
274273
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
275274
/// [`String`]: ../../std/string/struct.String.html
276-
/// [From]: trait.From.html
275+
/// [`From`]: trait.From.html
277276
/// [`into`]: trait.Into.html#tymethod.into
278277
#[stable(feature = "rust1", since = "1.0.0")]
279278
pub trait Into<T>: Sized {
@@ -285,18 +284,18 @@ pub trait Into<T>: Sized {
285284
/// Used to do value-to-value conversions while consuming the input value. It is the reciprocal of
286285
/// [`Into`].
287286
///
288-
/// One should always prefer implementing [`From`] over [`Into`]
289-
/// because implementing [`From`] automatically provides one with a implementation of [`Into`]
287+
/// One should always prefer implementing `From` over [`Into`]
288+
/// because implementing `From` automatically provides one with a implementation of [`Into`]
290289
/// thanks to the blanket implementation in the standard library.
291290
///
292291
/// Only implement [`Into`] if a conversion to a type outside the current crate is required.
293-
/// [`From`] cannot do these type of conversions because of Rust's orphaning rules.
292+
/// `From` cannot do these type of conversions because of Rust's orphaning rules.
294293
/// See [`Into`] for more details.
295294
///
296-
/// Prefer using [`Into`] over using [`From`] when specifying trait bounds on a generic function.
295+
/// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function.
297296
/// This way, types that directly implement [`Into`] can be used as arguments as well.
298297
///
299-
/// The [`From`] is also very useful when performing error handling. When constructing a function
298+
/// The `From` is also very useful when performing error handling. When constructing a function
300299
/// that is capable of failing, the return type will generally be of the form `Result<T, E>`.
301300
/// The `From` trait simplifies error handling by allowing a function to return a single error type
302301
/// that encapsulate multiple error types. See the "Examples" section and [the book][book] for more
@@ -306,14 +305,15 @@ pub trait Into<T>: Sized {
306305
///
307306
/// # Generic Implementations
308307
///
309-
/// - [`From<T>`]` for U` implies [`Into<U>`]` for T`
310-
/// - [`From`] is reflexive, which means that `From<T> for T` is implemented
308+
/// - `From<T> for U` implies [`Into`]`<U> for T`
309+
/// - `From` is reflexive, which means that `From<T> for T` is implemented
311310
///
312311
/// # Examples
313312
///
314313
/// [`String`] implements `From<&str>`:
315314
///
316-
/// An explicit conversion from a &str to a String is done as follows:
315+
/// An explicit conversion from a `&str` to a String is done as follows:
316+
///
317317
/// ```
318318
/// let string = "hello".to_string();
319319
/// let other_string = String::from("hello");
@@ -361,7 +361,7 @@ pub trait Into<T>: Sized {
361361
/// [`Option<T>`]: ../../std/option/enum.Option.html
362362
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
363363
/// [`String`]: ../../std/string/struct.String.html
364-
/// [`Into<U>`]: trait.Into.html
364+
/// [`Into`]: trait.Into.html
365365
/// [`from`]: trait.From.html#tymethod.from
366366
/// [book]: ../../book/ch09-00-error-handling.html
367367
#[stable(feature = "rust1", since = "1.0.0")]
@@ -422,7 +422,7 @@ pub trait TryInto<T>: Sized {
422422
///
423423
/// # Generic Implementations
424424
///
425-
/// - `TryFrom<T> for U` implies [`TryInto<U>`]` for T`
425+
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
426426
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
427427
/// is implemented and cannot fail -- the associated `Error` type for
428428
/// calling `T::try_from()` on a value of type `T` is `Infallible`.

src/librustc/session/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1744,8 +1744,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
17441744
opt::multi_s(
17451745
"",
17461746
"print",
1747-
"Comma separated list of compiler information to \
1748-
print on stdout",
1747+
"Compiler information to print on stdout",
17491748
"[crate-name|file-names|sysroot|cfg|target-list|\
17501749
target-cpus|target-features|relocation-models|\
17511750
code-models|tls-models|target-spec-json|native-static-libs]",

src/libsyntax/parse/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,7 @@ impl<'a> Parser<'a> {
26352635
self.expect(&token::OpenDelim(token::Paren))?;
26362636
let expr = self.parse_expr()?;
26372637
self.expect(&token::CloseDelim(token::Paren))?;
2638+
hi = self.prev_span;
26382639
ex = ExprKind::Await(ast::AwaitOrigin::MacroLike, expr);
26392640
} else if self.token.is_path_start() {
26402641
let path = self.parse_path(PathStyle::Expr)?;

0 commit comments

Comments
 (0)