Skip to content

Commit 4a689da

Browse files
committed
Auto merge of rust-lang#74313 - Manishearth:rollup-b55rn6t, r=Manishearth
Rollup of 8 pull requests Successful merges: - rust-lang#73354 (Update RELEASES.md for 1.45.0) - rust-lang#73852 (rustdoc: insert newlines between attributes) - rust-lang#73867 (Document the union keyword) - rust-lang#74046 (Fix caching issue when building tools.) - rust-lang#74123 (clean up E0718 explanation) - rust-lang#74147 (rustdoc: Allow linking from private items to private types) - rust-lang#74285 (rust-lang#71669: add ui, codegen tests for volatile + nearby int intrinsics) - rust-lang#74286 (Added detailed error code explanation for issue E0688 in Rust compiler.) Failed merges: r? @ghost
2 parents 9d09331 + 9a1df31 commit 4a689da

File tree

18 files changed

+500
-20
lines changed

18 files changed

+500
-20
lines changed

RELEASES.md

+163
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,166 @@
1+
Version 1.45.0 (2020-07-16)
2+
==========================
3+
4+
Language
5+
--------
6+
- [Out of range float to int conversions using `as` has been defined as a saturating
7+
conversion.][71269] This was previously undefined behaviour, but you can use the
8+
`{f64, f32}::to_int_unchecked` methods to continue using the current behaviour, which
9+
may be desirable in rare performance sensitive situations.
10+
- [`mem::Discriminant<T>` now uses `T`'s discriminant type instead of always
11+
using `u64`.][70705]
12+
- [Function like procedural macros can now be used in expression, pattern, and statement
13+
positions.][68717] This means you can now use a function-like procedural macro
14+
anywhere you can use a declarative (`macro_rules!`) macro.
15+
16+
Compiler
17+
--------
18+
- [You can now override individual target features through the `target-feature`
19+
flag.][72094] E.g. `-C target-feature=+avx2 -C target-feature=+fma` is now
20+
equivalent to `-C target-feature=+avx2,+fma`.
21+
- [Added the `force-unwind-tables` flag.][69984] This option allows
22+
rustc to always generate unwind tables regardless of panic strategy.
23+
- [Added the `embed-bitcode` flag.][71716] This codegen flag allows rustc
24+
to include LLVM bitcode into generated `rlib`s (this is on by default).
25+
- [Added the `tiny` value to the `code-model` codegen flag.][72397]
26+
- [Added tier 3 support\* for the `mipsel-sony-psp` target.][72062]
27+
- [Added tier 3 support for the `thumbv7a-uwp-windows-msvc` target.][72133]
28+
29+
\* Refer to Rust's [platform support page][forge-platform-support] for more
30+
information on Rust's tiered platform support.
31+
32+
33+
Libraries
34+
---------
35+
- [`net::{SocketAddr, SocketAddrV4, SocketAddrV6}` now implements `PartialOrd`
36+
and `Ord`.][72239]
37+
- [`proc_macro::TokenStream` now implements `Default`.][72234]
38+
- [You can now use `char` with
39+
`ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo}` to iterate over
40+
a range of codepoints.][72413] E.g.
41+
you can now write the following;
42+
```rust
43+
for ch in 'a'..='z' {
44+
print!("{}", ch);
45+
}
46+
println!();
47+
// Prints "abcdefghijklmnopqrstuvwxyz"
48+
```
49+
- [`OsString` now implements `FromStr`.][71662]
50+
- [The `saturating_neg` method as been added to all signed integer primitive
51+
types, and the `saturating_abs` method has been added for all integer
52+
primitive types.][71886]
53+
- [`Arc<T>`, `Rc<T>` now implement `From<Cow<'_, T>>`, and `Box` now
54+
implements `From<Cow>` when `T` is `[T: Copy]`, `str`, `CStr`, `OsStr`,
55+
or `Path`.][71447]
56+
- [`Box<[T]>` now implements `From<[T; N]>`.][71095]
57+
- [`BitOr` and `BitOrAssign` are implemented for all `NonZero`
58+
integer types.][69813]
59+
- [The `fetch_min`, and `fetch_max` methods have been added to all atomic
60+
integer types.][72324]
61+
- [The `fetch_update` method has been added to all atomic integer types.][71843]
62+
63+
Stabilized APIs
64+
---------------
65+
- [`Arc::as_ptr`]
66+
- [`BTreeMap::remove_entry`]
67+
- [`Rc::as_ptr`]
68+
- [`rc::Weak::as_ptr`]
69+
- [`rc::Weak::from_raw`]
70+
- [`rc::Weak::into_raw`]
71+
- [`str::strip_prefix`]
72+
- [`str::strip_suffix`]
73+
- [`sync::Weak::as_ptr`]
74+
- [`sync::Weak::from_raw`]
75+
- [`sync::Weak::into_raw`]
76+
- [`char::UNICODE_VERSION`]
77+
- [`Span::resolved_at`]
78+
- [`Span::located_at`]
79+
- [`Span::mixed_site`]
80+
- [`unix::process::CommandExt::arg0`]
81+
82+
Cargo
83+
-----
84+
85+
Misc
86+
----
87+
- [Rustdoc now supports strikethrough text in Markdown.][71928] E.g.
88+
`~~outdated information~~` becomes "~~outdated information~~".
89+
- [Added an emoji to Rustdoc's deprecated API message.][72014]
90+
91+
Compatibility Notes
92+
-------------------
93+
- [Trying to self initialize a static value (that is creating a value using
94+
itself) is unsound and now causes a compile error.][71140]
95+
- [`{f32, f64}::powi` now returns a slightly different value on Windows.][73420]
96+
This is due to changes in LLVM's intrinsics which `{f32, f64}::powi` uses.
97+
- [Rustdoc's CLI's extra error exit codes have been removed.][71900] These were
98+
previously undocumented and not intended for public use. Rustdoc still provides
99+
a non-zero exit code on errors.
100+
101+
Internals Only
102+
--------------
103+
- [Make clippy a git subtree instead of a git submodule][70655]
104+
- [Unify the undo log of all snapshot types][69464]
105+
106+
[73420]: https://github.com/rust-lang/rust/issues/73420/
107+
[72324]: https://github.com/rust-lang/rust/pull/72324/
108+
[71843]: https://github.com/rust-lang/rust/pull/71843/
109+
[71886]: https://github.com/rust-lang/rust/pull/71886/
110+
[72234]: https://github.com/rust-lang/rust/pull/72234/
111+
[72239]: https://github.com/rust-lang/rust/pull/72239/
112+
[72397]: https://github.com/rust-lang/rust/pull/72397/
113+
[72413]: https://github.com/rust-lang/rust/pull/72413/
114+
[72014]: https://github.com/rust-lang/rust/pull/72014/
115+
[72062]: https://github.com/rust-lang/rust/pull/72062/
116+
[72094]: https://github.com/rust-lang/rust/pull/72094/
117+
[72133]: https://github.com/rust-lang/rust/pull/72133/
118+
[71900]: https://github.com/rust-lang/rust/pull/71900/
119+
[71928]: https://github.com/rust-lang/rust/pull/71928/
120+
[71662]: https://github.com/rust-lang/rust/pull/71662/
121+
[71716]: https://github.com/rust-lang/rust/pull/71716/
122+
[71447]: https://github.com/rust-lang/rust/pull/71447/
123+
[71269]: https://github.com/rust-lang/rust/pull/71269/
124+
[71095]: https://github.com/rust-lang/rust/pull/71095/
125+
[71140]: https://github.com/rust-lang/rust/pull/71140/
126+
[70655]: https://github.com/rust-lang/rust/pull/70655/
127+
[70705]: https://github.com/rust-lang/rust/pull/70705/
128+
[69984]: https://github.com/rust-lang/rust/pull/69984/
129+
[69813]: https://github.com/rust-lang/rust/pull/69813/
130+
[69464]: https://github.com/rust-lang/rust/pull/69464/
131+
[68717]: https://github.com/rust-lang/rust/pull/68717/
132+
[`Arc::as_ptr`]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.as_ptr
133+
[`BTreeMap::remove_entry`]: https://doc.rust-lang.org/stable/std/collections/struct.BTreeMap.html#method.remove_entry
134+
[`Rc::as_ptr`]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.as_ptr
135+
[`rc::Weak::as_ptr`]: https://doc.rust-lang.org/stable/std/rc/struct.Weak.html#method.as_ptr
136+
[`rc::Weak::from_raw`]: https://doc.rust-lang.org/stable/std/rc/struct.Weak.html#method.from_raw
137+
[`rc::Weak::into_raw`]: https://doc.rust-lang.org/stable/std/rc/struct.Weak.html#method.into_raw
138+
[`sync::Weak::as_ptr`]: https://doc.rust-lang.org/stable/std/sync/struct.Weak.html#method.as_ptr
139+
[`sync::Weak::from_raw`]: https://doc.rust-lang.org/stable/std/sync/struct.Weak.html#method.from_raw
140+
[`sync::Weak::into_raw`]: https://doc.rust-lang.org/stable/std/sync/struct.Weak.html#method.into_raw
141+
[`str::strip_prefix`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.strip_prefix
142+
[`str::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.strip_suffix
143+
[`char::UNICODE_VERSION`]: https://doc.rust-lang.org/stable/std/char/constant.UNICODE_VERSION.html
144+
[`Span::resolved_at`]: https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.resolved_at
145+
[`Span::located_at`]: https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.located_at
146+
[`Span::mixed_site`]: https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.mixed_site
147+
[`unix::process::CommandExt::arg0`]: https://doc.rust-lang.org/std/os/unix/process/trait.CommandExt.html#tymethod.arg0
148+
149+
150+
Version 1.44.1 (2020-06-18)
151+
===========================
152+
153+
* [rustfmt accepts rustfmt_skip in cfg_attr again.][73078]
154+
* [Don't hash executable filenames on apple platforms, fixing backtraces.][cargo/8329]
155+
* [Fix crashes when finding backtrace on macOS.][71397]
156+
* [Clippy applies lint levels into different files.][clippy/5356]
157+
158+
[71397]: https://github.com/rust-lang/rust/issues/71397
159+
[73078]: https://github.com/rust-lang/rust/issues/73078
160+
[cargo/8329]: https://github.com/rust-lang/cargo/pull/8329
161+
[clippy/5356]: https://github.com/rust-lang/rust-clippy/issues/5356
162+
163+
1164
Version 1.44.0 (2020-06-04)
2165
==========================
3166

src/bootstrap/bin/rustc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ fn main() {
7676
cmd.env("RUST_BACKTRACE", "1");
7777
}
7878

79+
if let Ok(lint_flags) = env::var("RUSTC_LINT_FLAGS") {
80+
cmd.args(lint_flags.split_whitespace());
81+
}
82+
7983
if target.is_some() {
8084
// The stage0 compiler has a special sysroot distinct from what we
8185
// actually downloaded, so we just always pass the `--sysroot` option,

src/bootstrap/builder.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -1130,22 +1130,32 @@ impl<'a> Builder<'a> {
11301130
cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
11311131

11321132
if source_type == SourceType::InTree {
1133+
let mut lint_flags = Vec::new();
11331134
// When extending this list, add the new lints to the RUSTFLAGS of the
11341135
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
11351136
// some code doesn't go through this `rustc` wrapper.
1136-
rustflags.arg("-Wrust_2018_idioms");
1137-
rustflags.arg("-Wunused_lifetimes");
1137+
lint_flags.push("-Wrust_2018_idioms");
1138+
lint_flags.push("-Wunused_lifetimes");
11381139

11391140
if self.config.deny_warnings {
1140-
rustflags.arg("-Dwarnings");
1141+
lint_flags.push("-Dwarnings");
11411142
}
11421143

11431144
// FIXME(#58633) hide "unused attribute" errors in incremental
11441145
// builds of the standard library, as the underlying checks are
11451146
// not yet properly integrated with incremental recompilation.
11461147
if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
1147-
rustflags.arg("-Aunused-attributes");
1148+
lint_flags.push("-Aunused-attributes");
11481149
}
1150+
// This does not use RUSTFLAGS due to caching issues with Cargo.
1151+
// Clippy is treated as an "in tree" tool, but shares the same
1152+
// cache as other "submodule" tools. With these options set in
1153+
// RUSTFLAGS, that causes *every* shared dependency to be rebuilt.
1154+
// By injecting this into the rustc wrapper, this circumvents
1155+
// Cargo's fingerprint detection. This is fine because lint flags
1156+
// are always ignored in dependencies. Eventually this should be
1157+
// fixed via better support from Cargo.
1158+
cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
11491159
}
11501160

11511161
if let Mode::Rustc | Mode::Codegen = mode {

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ E0669: include_str!("./error_codes/E0669.md"),
383383
E0670: include_str!("./error_codes/E0670.md"),
384384
E0671: include_str!("./error_codes/E0671.md"),
385385
E0687: include_str!("./error_codes/E0687.md"),
386+
E0688: include_str!("./error_codes/E0688.md"),
386387
E0689: include_str!("./error_codes/E0689.md"),
387388
E0690: include_str!("./error_codes/E0690.md"),
388389
E0691: include_str!("./error_codes/E0691.md"),
@@ -616,7 +617,6 @@ E0768: include_str!("./error_codes/E0768.md"),
616617
E0640, // infer outlives requirements
617618
// E0645, // trait aliases not finished
618619
E0667, // `impl Trait` in projections
619-
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
620620
// E0694, // an unknown tool name found in scoped attributes
621621
// E0702, // replaced with a generic attribute input check
622622
// E0707, // multiple elided lifetimes used in arguments of `async fn`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
In-band lifetimes were mixed with explicit lifetime binders.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0688
6+
#![feature(in_band_lifetimes)]
7+
8+
fn foo<'a>(x: &'a u32, y: &'b u32) {} // error!
9+
10+
struct Foo<'a> { x: &'a u32 }
11+
12+
impl Foo<'a> {
13+
fn bar<'b>(x: &'a u32, y: &'b u32, z: &'c u32) {} // error!
14+
}
15+
16+
impl<'b> Foo<'a> { // error!
17+
fn baz() {}
18+
}
19+
```
20+
21+
In-band lifetimes cannot be mixed with explicit lifetime binders.
22+
For example:
23+
24+
```
25+
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) {} // ok!
26+
27+
struct Foo<'a> { x: &'a u32 }
28+
29+
impl<'a> Foo<'a> {
30+
fn bar<'b,'c>(x: &'a u32, y: &'b u32, z: &'c u32) {} // ok!
31+
}
32+
33+
impl<'a> Foo<'a> { // ok!
34+
fn baz() {}
35+
}
36+
```

src/librustc_error_codes/error_codes/E0718.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
This error indicates that a `#[lang = ".."]` attribute was placed
2-
on the wrong type of item.
1+
A `#[lang = ".."]` attribute was placed on the wrong item type.
32

4-
Examples of erroneous code:
3+
Erroneous code example:
54

65
```compile_fail,E0718
76
#![feature(lang_items)]

src/librustdoc/html/render.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use std::str;
4242
use std::string::ToString;
4343
use std::sync::Arc;
4444

45+
use itertools::Itertools;
4546
use rustc_ast_pretty::pprust;
4647
use rustc_data_structures::flock;
4748
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -3170,15 +3171,19 @@ const ALLOWED_ATTRIBUTES: &[Symbol] = &[
31703171
// bar: usize,
31713172
// }
31723173
fn render_attributes(w: &mut Buffer, it: &clean::Item, top: bool) {
3173-
let mut attrs = String::new();
3174-
3175-
for attr in &it.attrs.other_attrs {
3176-
if !ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
3177-
continue;
3178-
}
3174+
let attrs = it
3175+
.attrs
3176+
.other_attrs
3177+
.iter()
3178+
.filter_map(|attr| {
3179+
if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
3180+
Some(pprust::attribute_to_string(&attr))
3181+
} else {
3182+
None
3183+
}
3184+
})
3185+
.join("\n");
31793186

3180-
attrs.push_str(&pprust::attribute_to_string(&attr));
3181-
}
31823187
if !attrs.is_empty() {
31833188
write!(
31843189
w,

src/librustdoc/passes/collect_intra_doc_links.rs

+1
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
799799

800800
let hir_id = self.cx.tcx.hir().as_local_hir_id(local);
801801
if !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_id)
802+
&& (item.visibility == Visibility::Public)
802803
&& !self.cx.render_options.document_private
803804
{
804805
let item_name = item.name.as_deref().unwrap_or("<unknown>");

src/libstd/keyword_docs.rs

+66-2
Original file line numberDiff line numberDiff line change
@@ -1732,8 +1732,72 @@ mod dyn_keyword {}
17321732
//
17331733
/// The [Rust equivalent of a C-style union][union].
17341734
///
1735-
/// The documentation for this keyword is [not yet complete]. Pull requests welcome!
1735+
/// A `union` looks like a [`struct`] in terms of declaration, but all of its
1736+
/// fields exist in the same memory, superimposed over one another. For instance,
1737+
/// if we wanted some bits in memory that we sometimes interpret as a `u32` and
1738+
/// sometimes as an `f32`, we could write:
1739+
///
1740+
/// ```rust
1741+
/// union IntOrFloat {
1742+
/// i: u32,
1743+
/// f: f32,
1744+
/// }
1745+
///
1746+
/// let mut u = IntOrFloat { f: 1.0 };
1747+
/// // Reading the fields of an union is always unsafe
1748+
/// assert_eq!(unsafe { u.i }, 1065353216);
1749+
/// // Updating through any of the field will modify all of them
1750+
/// u.i = 1073741824;
1751+
/// assert_eq!(unsafe { u.f }, 2.0);
1752+
/// ```
1753+
///
1754+
/// # Matching on unions
1755+
///
1756+
/// It is possible to use pattern matching on `union`s. A single field name must
1757+
/// be used and it must match the name of one of the `union`'s field.
1758+
/// Like reading from a `union`, pattern matching on a `union` requires `unsafe`.
1759+
///
1760+
/// ```rust
1761+
/// union IntOrFloat {
1762+
/// i: u32,
1763+
/// f: f32,
1764+
/// }
1765+
///
1766+
/// let u = IntOrFloat { f: 1.0 };
1767+
///
1768+
/// unsafe {
1769+
/// match u {
1770+
/// IntOrFloat { i: 10 } => println!("Found exactly ten!"),
1771+
/// // Matching the field `f` provides an `f32`.
1772+
/// IntOrFloat { f } => println!("Found f = {} !", f),
1773+
/// }
1774+
/// }
1775+
/// ```
1776+
///
1777+
/// # References to union fields
1778+
///
1779+
/// All fields in a `union` are all at the same place in memory which means
1780+
/// borrowing one borrows the entire `union`, for the same lifetime:
1781+
///
1782+
/// ```rust,compile_fail,E0502
1783+
/// union IntOrFloat {
1784+
/// i: u32,
1785+
/// f: f32,
1786+
/// }
17361787
///
1788+
/// let mut u = IntOrFloat { f: 1.0 };
1789+
///
1790+
/// let f = unsafe { &u.f };
1791+
/// // This will not compile because the field has already been borrowed, even
1792+
/// // if only immutably
1793+
/// let i = unsafe { &mut u.i };
1794+
///
1795+
/// *i = 10;
1796+
/// println!("f = {} and i = {}", f, i);
1797+
/// ```
1798+
///
1799+
/// See the [Reference][union] for more informations on `union`s.
1800+
///
1801+
/// [`struct`]: keyword.struct.html
17371802
/// [union]: ../reference/items/unions.html
1738-
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
17391803
mod union_keyword {}

0 commit comments

Comments
 (0)