Skip to content

Commit f7bb8e3

Browse files
committed
Auto merge of rust-lang#92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#92055 (Add release notes for 1.58) - rust-lang#92490 (Move crate drop-down to search results page) - rust-lang#92510 (Don't resolve blocks in foreign functions) - rust-lang#92573 (expand: Refactor InvocationCollector visitor for better code reuse) - rust-lang#92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes) - rust-lang#92657 (Implemented const casts of raw pointers) - rust-lang#92671 (Make `Atomic*::from_mut` return `&mut Atomic*`) - rust-lang#92673 (Remove useless collapse toggle on "all items" page) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e19ca1d + e6aa48d commit f7bb8e3

File tree

31 files changed

+1339
-856
lines changed

31 files changed

+1339
-856
lines changed

RELEASES.md

+170
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,169 @@
1+
Version 1.58.0 (2022-01-13)
2+
==========================
3+
4+
Language
5+
--------
6+
7+
- [Format strings can now capture arguments simply by writing `{ident}` in the string.][90473] This works in all macros accepting format strings. Support for this in `panic!` (`panic!("{ident}")`) requires the 2021 edition; panic invocations in previous editions that appear to be trying to use this will result in a warning lint about not having the intended effect.
8+
- [`*const T` pointers can now be dereferenced in const contexts.][89551]
9+
- [The rules for when a generic struct implements `Unsize` have been relaxed.][90417]
10+
11+
Compiler
12+
--------
13+
14+
- [Add LLVM CFI support to the Rust compiler][89652]
15+
- [Stabilize -Z strip as -C strip][90058]. Note that while release builds already don't add debug symbols for the code you compile, the compiled standard library that ships with Rust includes debug symbols, so you may want to use the `strip` option to remove these symbols to produce smaller release binaries. Note that this release only includes support in rustc, not directly in cargo.
16+
- [Add support for LLVM coverage mapping format versions 5 and 6][91207]
17+
- [Emit LLVM optimization remarks when enabled with `-Cremark`][90833]
18+
- [Update the minimum external LLVM to 12][90175]
19+
- [Add `x86_64-unknown-none` at Tier 3*][89062]
20+
- [Build musl dist artifacts with debuginfo enabled][90733]. When building release binaries using musl, you may want to use the newly stabilized strip option to remove these debug symbols, reducing the size of your binaries.
21+
- [Don't abort compilation after giving a lint error][87337]
22+
- [Error messages point at the source of trait bound obligations in more places][89580]
23+
24+
\* Refer to Rust's [platform support page][platform-support-doc] for more
25+
information on Rust's tiered platform support.
26+
27+
Libraries
28+
---------
29+
30+
- [All remaining functions in the standard library have `#[must_use]` annotations where appropriate][89692], producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value.
31+
- [Paths are automatically canonicalized on Windows for operations that support it][89174]
32+
- [Re-enable debug checks for `copy` and `copy_nonoverlapping`][90041]
33+
- [Implement `RefUnwindSafe` for `Rc<T>`][87467]
34+
- [Make RSplit<T, P>: Clone not require T: Clone][90117]
35+
- [Implement `Termination` for `Result<Infallible, E>`][88601]. This allows writing `fn main() -> Result<Infallible, ErrorType>`, for a program whose successful exits never involve returning from `main` (for instance, a program that calls `exit`, or that uses `exec` to run another program).
36+
37+
Stabilized APIs
38+
---------------
39+
40+
- [`Metadata::is_symlink`]
41+
- [`Path::is_symlink`]
42+
- [`{integer}::saturating_div`]
43+
- [`Option::unwrap_unchecked`]
44+
- [`NonZero{unsigned}::is_power_of_two`]
45+
46+
These APIs are now usable in const contexts:
47+
48+
- [`Duration::new`]
49+
- [`Duration::checked_add`]
50+
- [`Duration::saturating_add`]
51+
- [`Duration::checked_sub`]
52+
- [`Duration::saturating_sub`]
53+
- [`Duration::checked_mul`]
54+
- [`Duration::saturating_mul`]
55+
- [`Duration::checked_div`]
56+
- [`MaybeUninit::as_ptr`]
57+
- [`MaybeUninit::as_mut_ptr`]
58+
- [`MaybeUninit::assume_init`]
59+
- [`MaybeUninit::assume_init_ref`]
60+
61+
Cargo
62+
-----
63+
64+
- [Add --message-format for install command][cargo/10107]
65+
- [Warn when alias shadows external subcommand][cargo/10082]
66+
67+
Rustdoc
68+
-------
69+
70+
- [Show all Deref implementations recursively in rustdoc][90183]
71+
- [Use computed visibility in rustdoc][88447]
72+
73+
Compatibility Notes
74+
-------------------
75+
76+
- [Try all stable method candidates first before trying unstable ones][90329]. This change ensures that adding new nightly-only methods to the Rust standard library will not break code invoking methods of the same name from traits outside the standard library.
77+
- Windows: [`std::process::Command` will no longer search the current directory for executables.][87704]
78+
- [All proc-macro backward-compatibility lints are now deny-by-default.][88041]
79+
- [proc_macro: Append .0 to unsuffixed float if it would otherwise become int token][90297]
80+
- [Refactor weak symbols in std::sys::unix][90846]. This optimizes accesses to glibc functions, by avoiding the use of dlopen. This does not increase the [minimum expected version of glibc](https://doc.rust-lang.org/nightly/rustc/platform-support.html). However, software distributions that use symbol versions to detect library dependencies, and which take weak symbols into account in that analysis, may detect rust binaries as requiring newer versions of glibc.
81+
- [rustdoc now rejects some unexpected semicolons in doctests][91026]
82+
83+
Internal Changes
84+
----------------
85+
86+
These changes provide no direct user facing benefits, but represent significant
87+
improvements to the internals and overall performance of rustc
88+
and related tools.
89+
90+
- [Implement coherence checks for negative trait impls][90104]
91+
- [Add rustc lint, warning when iterating over hashmaps][89558]
92+
- [Optimize live point computation][90491]
93+
- [Enable verification for 1/32nd of queries loaded from disk][90361]
94+
- [Implement version of normalize_erasing_regions that allows for normalization failure][91255]
95+
96+
[87337]: https://github.com/rust-lang/rust/pull/87337/
97+
[87467]: https://github.com/rust-lang/rust/pull/87467/
98+
[87704]: https://github.com/rust-lang/rust/pull/87704/
99+
[88041]: https://github.com/rust-lang/rust/pull/88041/
100+
[88300]: https://github.com/rust-lang/rust/pull/88300/
101+
[88447]: https://github.com/rust-lang/rust/pull/88447/
102+
[88601]: https://github.com/rust-lang/rust/pull/88601/
103+
[88624]: https://github.com/rust-lang/rust/pull/88624/
104+
[89062]: https://github.com/rust-lang/rust/pull/89062/
105+
[89174]: https://github.com/rust-lang/rust/pull/89174/
106+
[89542]: https://github.com/rust-lang/rust/pull/89542/
107+
[89551]: https://github.com/rust-lang/rust/pull/89551/
108+
[89558]: https://github.com/rust-lang/rust/pull/89558/
109+
[89580]: https://github.com/rust-lang/rust/pull/89580/
110+
[89652]: https://github.com/rust-lang/rust/pull/89652/
111+
[89677]: https://github.com/rust-lang/rust/pull/89677/
112+
[89951]: https://github.com/rust-lang/rust/pull/89951/
113+
[90041]: https://github.com/rust-lang/rust/pull/90041/
114+
[90058]: https://github.com/rust-lang/rust/pull/90058/
115+
[90104]: https://github.com/rust-lang/rust/pull/90104/
116+
[90117]: https://github.com/rust-lang/rust/pull/90117/
117+
[90175]: https://github.com/rust-lang/rust/pull/90175/
118+
[90183]: https://github.com/rust-lang/rust/pull/90183/
119+
[90297]: https://github.com/rust-lang/rust/pull/90297/
120+
[90329]: https://github.com/rust-lang/rust/pull/90329/
121+
[90361]: https://github.com/rust-lang/rust/pull/90361/
122+
[90417]: https://github.com/rust-lang/rust/pull/90417/
123+
[90473]: https://github.com/rust-lang/rust/pull/90473/
124+
[90491]: https://github.com/rust-lang/rust/pull/90491/
125+
[90733]: https://github.com/rust-lang/rust/pull/90733/
126+
[90833]: https://github.com/rust-lang/rust/pull/90833/
127+
[90846]: https://github.com/rust-lang/rust/pull/90846/
128+
[90896]: https://github.com/rust-lang/rust/pull/90896/
129+
[91026]: https://github.com/rust-lang/rust/pull/91026/
130+
[91207]: https://github.com/rust-lang/rust/pull/91207/
131+
[91255]: https://github.com/rust-lang/rust/pull/91255/
132+
[91301]: https://github.com/rust-lang/rust/pull/91301/
133+
[cargo/10082]: https://github.com/rust-lang/cargo/pull/10082/
134+
[cargo/10107]: https://github.com/rust-lang/cargo/pull/10107/
135+
[`Metadata::is_symlink`]: https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html#method.is_symlink
136+
[`Path::is_symlink`]: https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.is_symlink
137+
[`{integer}::saturating_div`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.saturating_div
138+
[`Option::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_unchecked
139+
[`NonZero{unsigned}::is_power_of_two`]: https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html#method.is_power_of_two
140+
[`unix::process::ExitStatusExt::core_dumped`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.core_dumped
141+
[`unix::process::ExitStatusExt::stopped_signal`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.stopped_signal
142+
[`unix::process::ExitStatusExt::continued`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.continued
143+
[`unix::process::ExitStatusExt::into_raw`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.into_raw
144+
[`Duration::new`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.new
145+
[`Duration::checked_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_add
146+
[`Duration::saturating_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_add
147+
[`Duration::checked_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_sub
148+
[`Duration::saturating_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_sub
149+
[`Duration::checked_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_mul
150+
[`Duration::saturating_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_mul
151+
[`Duration::checked_div`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_div
152+
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f64
153+
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f32
154+
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f64
155+
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f32
156+
[`Duration::mul_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f64
157+
[`Duration::mul_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f32
158+
[`Duration::div_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f64
159+
[`Duration::div_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f32
160+
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f64
161+
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f32
162+
[`MaybeUninit::as_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_ptr
163+
[`MaybeUninit::as_mut_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_mut_ptr
164+
[`MaybeUninit::assume_init`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init
165+
[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref
166+
1167
Version 1.57.0 (2021-12-02)
2168
==========================
3169

@@ -388,6 +554,10 @@ Compatibility Notes
388554
`Command` would cause them to be ASCII-uppercased.
389555
- [Rustdoc will now warn on using rustdoc lints that aren't prefixed
390556
with `rustdoc::`][86849]
557+
- `RUSTFLAGS` is no longer set for build scripts. Build scripts
558+
should use `CARGO_ENCODED_RUSTFLAGS` instead. See the
559+
[documentation](https://doc.rust-lang.org/nightly/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts)
560+
for more details.
391561

392562
[86849]: https://github.com/rust-lang/rust/pull/86849
393563
[86513]: https://github.com/rust-lang/rust/pull/86513

compiler/rustc_ast/src/ast_like.rs

+37-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ use super::{AssocItem, Expr, ForeignItem, Item, Local, MacCallStmt};
66
use super::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
77
use super::{AttrVec, Attribute, Stmt, StmtKind};
88

9-
use std::fmt::Debug;
9+
use std::fmt;
10+
use std::marker::PhantomData;
1011

1112
/// An `AstLike` represents an AST node (or some wrapper around
1213
/// and AST node) which stores some combination of attributes
1314
/// and tokens.
14-
pub trait AstLike: Sized + Debug {
15+
pub trait AstLike: Sized + fmt::Debug {
1516
/// This is `true` if this `AstLike` might support 'custom' (proc-macro) inner
1617
/// attributes. Attributes like `#![cfg]` and `#![cfg_attr]` are not
1718
/// considered 'custom' attributes
@@ -285,3 +286,37 @@ derive_has_attrs_no_tokens! {
285286
derive_has_tokens_no_attrs! {
286287
Ty, Block, AttrItem, Pat, Path, Visibility
287288
}
289+
290+
/// A newtype around an `AstLike` node that implements `AstLike` itself.
291+
pub struct AstLikeWrapper<Wrapped, Tag> {
292+
pub wrapped: Wrapped,
293+
pub tag: PhantomData<Tag>,
294+
}
295+
296+
impl<Wrapped, Tag> AstLikeWrapper<Wrapped, Tag> {
297+
pub fn new(wrapped: Wrapped, _tag: Tag) -> AstLikeWrapper<Wrapped, Tag> {
298+
AstLikeWrapper { wrapped, tag: Default::default() }
299+
}
300+
}
301+
302+
impl<Wrapped: fmt::Debug, Tag> fmt::Debug for AstLikeWrapper<Wrapped, Tag> {
303+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
304+
f.debug_struct("AstLikeWrapper")
305+
.field("wrapped", &self.wrapped)
306+
.field("tag", &self.tag)
307+
.finish()
308+
}
309+
}
310+
311+
impl<Wrapped: AstLike, Tag> AstLike for AstLikeWrapper<Wrapped, Tag> {
312+
const SUPPORTS_CUSTOM_INNER_ATTRS: bool = Wrapped::SUPPORTS_CUSTOM_INNER_ATTRS;
313+
fn attrs(&self) -> &[Attribute] {
314+
self.wrapped.attrs()
315+
}
316+
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<Attribute>)) {
317+
self.wrapped.visit_attrs(f)
318+
}
319+
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
320+
self.wrapped.tokens_mut()
321+
}
322+
}

compiler/rustc_ast/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod tokenstream;
4141
pub mod visit;
4242

4343
pub use self::ast::*;
44-
pub use self::ast_like::AstLike;
44+
pub use self::ast_like::{AstLike, AstLikeWrapper};
4545

4646
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4747

compiler/rustc_expand/src/config.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ macro_rules! configure {
238238
}
239239

240240
impl<'a> StripUnconfigured<'a> {
241-
pub fn configure<T: AstLike>(&mut self, mut node: T) -> Option<T> {
241+
pub fn configure<T: AstLike>(&self, mut node: T) -> Option<T> {
242242
self.process_cfg_attrs(&mut node);
243243
if self.in_cfg(node.attrs()) {
244244
self.try_configure_tokens(&mut node);
@@ -248,7 +248,7 @@ impl<'a> StripUnconfigured<'a> {
248248
}
249249
}
250250

251-
fn try_configure_tokens<T: AstLike>(&mut self, node: &mut T) {
251+
fn try_configure_tokens<T: AstLike>(&self, node: &mut T) {
252252
if self.config_tokens {
253253
if let Some(Some(tokens)) = node.tokens_mut() {
254254
let attr_annotated_tokens = tokens.create_token_stream();
@@ -257,10 +257,7 @@ impl<'a> StripUnconfigured<'a> {
257257
}
258258
}
259259

260-
fn configure_krate_attrs(
261-
&mut self,
262-
mut attrs: Vec<ast::Attribute>,
263-
) -> Option<Vec<ast::Attribute>> {
260+
fn configure_krate_attrs(&self, mut attrs: Vec<ast::Attribute>) -> Option<Vec<ast::Attribute>> {
264261
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
265262
if self.in_cfg(&attrs) { Some(attrs) } else { None }
266263
}
@@ -269,7 +266,7 @@ impl<'a> StripUnconfigured<'a> {
269266
/// This is only used during the invocation of `derive` proc-macros,
270267
/// which require that we cfg-expand their entire input.
271268
/// Normal cfg-expansion operates on parsed AST nodes via the `configure` method
272-
fn configure_tokens(&mut self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream {
269+
fn configure_tokens(&self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream {
273270
fn can_skip(stream: &AttrAnnotatedTokenStream) -> bool {
274271
stream.0.iter().all(|(tree, _spacing)| match tree {
275272
AttrAnnotatedTokenTree::Attributes(_) => false,
@@ -325,7 +322,7 @@ impl<'a> StripUnconfigured<'a> {
325322
/// Gives compiler warnings if any `cfg_attr` does not contain any
326323
/// attributes and is in the original source code. Gives compiler errors if
327324
/// the syntax of any `cfg_attr` is incorrect.
328-
fn process_cfg_attrs<T: AstLike>(&mut self, node: &mut T) {
325+
fn process_cfg_attrs<T: AstLike>(&self, node: &mut T) {
329326
node.visit_attrs(|attrs| {
330327
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
331328
});
@@ -338,7 +335,7 @@ impl<'a> StripUnconfigured<'a> {
338335
/// Gives a compiler warning when the `cfg_attr` contains no attributes and
339336
/// is in the original source file. Gives a compiler error if the syntax of
340337
/// the attribute is incorrect.
341-
fn process_cfg_attr(&mut self, attr: Attribute) -> Vec<Attribute> {
338+
fn process_cfg_attr(&self, attr: Attribute) -> Vec<Attribute> {
342339
if !attr.has_name(sym::cfg_attr) {
343340
return vec![attr];
344341
}
@@ -461,7 +458,7 @@ impl<'a> StripUnconfigured<'a> {
461458
}
462459
}
463460

464-
pub fn configure_expr(&mut self, expr: &mut P<ast::Expr>) {
461+
pub fn configure_expr(&self, expr: &mut P<ast::Expr>) {
465462
for attr in expr.attrs.iter() {
466463
self.maybe_emit_expr_attr_err(attr);
467464
}

0 commit comments

Comments
 (0)