Skip to content

Commit 8876ffc

Browse files
committed
Auto merge of #77462 - jonas-schievink:rollup-m0rqdh5, r=jonas-schievink
Rollup of 12 pull requests Successful merges: - #76101 (Update RELEASES.md for 1.47.0) - #76739 (resolve: prohibit anon const non-static lifetimes) - #76811 (Doc alias name restriction) - #77405 (Add tracking issue of iter_advance_by feature) - #77409 (Add example for iter chain struct) - #77415 (Better error message for `async` blocks in a const-context) - #77423 (Add `-Zprecise-enum-drop-elaboration`) - #77432 (Use posix_spawn on musl targets) - #77441 (Fix AVR stack corruption bug) - #77442 (Clean up on example doc fixes for ptr::copy) - #77444 (Fix span for incorrect pattern field and add label) - #77453 (Stop running macOS builds on Azure Pipelines) Failed merges: r? `@ghost`
2 parents be38081 + 0c5f0b1 commit 8876ffc

File tree

32 files changed

+409
-212
lines changed

32 files changed

+409
-212
lines changed

RELEASES.md

+135
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,138 @@
1+
Version 1.47.0 (2020-10-08)
2+
==========================
3+
4+
Language
5+
--------
6+
- [Closures will now warn when not used.][74869]
7+
8+
Compiler
9+
--------
10+
- [Stabilized the `-C control-flow-guard` codegen option][73893], which enables
11+
[Control Flow Guard][1.47.0-cfg] for Windows platforms, and is ignored on other
12+
platforms.
13+
- [Upgraded to LLVM 11.][73526]
14+
- [Added tier 3\* support for the `thumbv4t-none-eabi` target.][74419]
15+
- [Upgrade the FreeBSD toolchain to version 11.4][75204]
16+
- [`RUST_BACKTRACE`'s output is now more compact.][75048]
17+
18+
\* Refer to Rust's [platform support page][forge-platform-support] for more
19+
information on Rust's tiered platform support.
20+
21+
Libraries
22+
---------
23+
- [`CStr` now implements `Index<RangeFrom<usize>>`.][74021]
24+
- [Traits in `std`/`core` are now implemented for arrays of any length, not just
25+
those of length less than 33.][74060]
26+
- [`ops::RangeFull` and `ops::Range` now implement Default.][73197]
27+
- [`panic::Location` now implements `Copy`, `Clone`, `Eq`, `Hash`, `Ord`,
28+
`PartialEq`, and `PartialOrd`.][73583]
29+
30+
Stabilized APIs
31+
---------------
32+
- [`Ident::new_raw`]
33+
- [`Range::is_empty`]
34+
- [`RangeInclusive::is_empty`]
35+
- [`Result::as_deref`]
36+
- [`Result::as_deref_mut`]
37+
- [`Vec::leak`]
38+
- [`pointer::offset_from`]
39+
- [`f32::TAU`]
40+
- [`f64::TAU`]
41+
42+
The following previously stable APIs have now been made const.
43+
44+
- [The `new` method for all `NonZero` integers.][73858]
45+
- [The `checked_add`,`checked_sub`,`checked_mul`,`checked_neg`, `checked_shl`,
46+
`checked_shr`, `saturating_add`, `saturating_sub`, and `saturating_mul`
47+
methods for all integers.][73858]
48+
- [The `checked_abs`, `saturating_abs`, `saturating_neg`, and `signum` for all
49+
signed integers.][73858]
50+
- [The `is_ascii_alphabetic`, `is_ascii_uppercase`, `is_ascii_lowercase`,
51+
`is_ascii_alphanumeric`, `is_ascii_digit`, `is_ascii_hexdigit`,
52+
`is_ascii_punctuation`, `is_ascii_graphic`, `is_ascii_whitespace`, and
53+
`is_ascii_control` methods for `char` and `u8`.][73858]
54+
55+
Cargo
56+
-----
57+
- [`build-dependencies` are now built with opt-level 0 by default.][cargo/8500]
58+
You can override this by setting the following in your `Cargo.toml`.
59+
```toml
60+
[profile.release.build-override]
61+
opt-level = 3
62+
```
63+
- [`cargo-help` will now display man pages for commands rather just the
64+
`--help` text.][cargo/8456]
65+
- [`cargo-metadata` now emits a `test` field indicating if a target has
66+
tests enabled.][cargo/8478]
67+
- [`workspace.default-members` now respects `workspace.exclude`.][cargo/8485]
68+
- [`cargo-publish` will now use an alternative registry by default if it's the
69+
only registry specified in `package.publish`.][cargo/8571]
70+
71+
Misc
72+
----
73+
- [Added a help button beside Rustdoc's searchbar that explains rustdoc's
74+
type based search.][75366]
75+
- [Added the Ayu theme to rustdoc.][71237]
76+
77+
Compatibility Notes
78+
-------------------
79+
- [Bumped the minimum supported Emscripten version to 1.39.20.][75716]
80+
- [Fixed a regression parsing `{} && false` in tail expressions.][74650]
81+
- [Added changes to how proc-macros are expanded in `macro_rules!` that should
82+
help to preserve more span information.][73084] These changes may cause
83+
compiliation errors if your macro was unhygenic or didn't correctly handle
84+
`Delimiter::None`.
85+
- [Moved support for the CloudABI target to tier 3.][75568]
86+
- [`linux-gnu` targets now require minimum kernel 2.6.32 and glibc 2.11.][74163]
87+
- [Added the `rustc-docs` component.][75560] This allows you to install
88+
and read the documentation for the compiler internal APIs. (Currently only
89+
available for `x86_64-unknown-linux-gnu`.)
90+
91+
Internal Only
92+
--------
93+
- [Improved default settings for bootstrapping in `x.py`.][73964] You can read details about this change in the ["Changes To `x.py` Defaults"](https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html) post on the Inside Rust blog.
94+
95+
[1.47.0-cfg]: https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
96+
[75048]: https://github.com/rust-lang/rust/pull/75048/
97+
[74163]: https://github.com/rust-lang/rust/pull/74163/
98+
[71237]: https://github.com/rust-lang/rust/pull/71237/
99+
[74869]: https://github.com/rust-lang/rust/pull/74869/
100+
[73858]: https://github.com/rust-lang/rust/pull/73858/
101+
[75716]: https://github.com/rust-lang/rust/pull/75716/
102+
[75908]: https://github.com/rust-lang/rust/pull/75908/
103+
[75516]: https://github.com/rust-lang/rust/pull/75516/
104+
[75560]: https://github.com/rust-lang/rust/pull/75560/
105+
[75568]: https://github.com/rust-lang/rust/pull/75568/
106+
[75366]: https://github.com/rust-lang/rust/pull/75366/
107+
[75204]: https://github.com/rust-lang/rust/pull/75204/
108+
[74650]: https://github.com/rust-lang/rust/pull/74650/
109+
[74419]: https://github.com/rust-lang/rust/pull/74419/
110+
[73964]: https://github.com/rust-lang/rust/pull/73964/
111+
[74021]: https://github.com/rust-lang/rust/pull/74021/
112+
[74060]: https://github.com/rust-lang/rust/pull/74060/
113+
[73893]: https://github.com/rust-lang/rust/pull/73893/
114+
[73526]: https://github.com/rust-lang/rust/pull/73526/
115+
[73583]: https://github.com/rust-lang/rust/pull/73583/
116+
[73084]: https://github.com/rust-lang/rust/pull/73084/
117+
[73197]: https://github.com/rust-lang/rust/pull/73197/
118+
[72488]: https://github.com/rust-lang/rust/pull/72488/
119+
[cargo/8456]: https://github.com/rust-lang/cargo/pull/8456/
120+
[cargo/8478]: https://github.com/rust-lang/cargo/pull/8478/
121+
[cargo/8485]: https://github.com/rust-lang/cargo/pull/8485/
122+
[cargo/8500]: https://github.com/rust-lang/cargo/pull/8500/
123+
[cargo/8571]: https://github.com/rust-lang/cargo/pull/8571/
124+
[`Ident::new_raw`]: https://doc.rust-lang.org/nightly/proc_macro/struct.Ident.html#method.new_raw
125+
[`Range::is_empty`]: https://doc.rust-lang.org/nightly/std/ops/struct.Range.html#method.is_empty
126+
[`RangeInclusive::is_empty`]: https://doc.rust-lang.org/nightly/std/ops/struct.RangeInclusive.html#method.is_empty
127+
[`Result::as_deref_mut`]: https://doc.rust-lang.org/nightly/std/result/enum.Result.html#method.as_deref_mut
128+
[`Result::as_deref`]: https://doc.rust-lang.org/nightly/std/result/enum.Result.html#method.as_deref
129+
[`TypeId::of`]: https://doc.rust-lang.org/nightly/std/any/struct.TypeId.html#method.of
130+
[`Vec::leak`]: https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.leak
131+
[`f32::TAU`]: https://doc.rust-lang.org/nightly/std/f32/consts/constant.TAU.html
132+
[`f64::TAU`]: https://doc.rust-lang.org/nightly/std/f64/consts/constant.TAU.html
133+
[`pointer::offset_from`]: https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.offset_from
134+
135+
1136
Version 1.46.0 (2020-08-27)
2137
==========================
3138

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ fn test_debugging_options_tracking_hash() {
568568
tracked!(osx_rpath_install_name, true);
569569
tracked!(panic_abort_tests, true);
570570
tracked!(plt, Some(true));
571+
tracked!(precise_enum_drop_elaboration, false);
571572
tracked!(print_fuel, Some("abc".to_string()));
572573
tracked!(profile, true);
573574
tracked!(profile_emit, Some(PathBuf::from("abc")));

compiler/rustc_mir/src/dataflow/impls/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
358358
discr: &mir::Operand<'tcx>,
359359
edge_effects: &mut impl SwitchIntEdgeEffects<G>,
360360
) {
361+
if !self.tcx.sess.opts.debugging_opts.precise_enum_drop_elaboration {
362+
return;
363+
}
364+
361365
let enum_ = discr.place().and_then(|discr| {
362366
switch_on_enum_discriminant(self.tcx, &self.body, &self.body[block], discr)
363367
});
@@ -469,6 +473,10 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
469473
discr: &mir::Operand<'tcx>,
470474
edge_effects: &mut impl SwitchIntEdgeEffects<G>,
471475
) {
476+
if !self.tcx.sess.opts.debugging_opts.precise_enum_drop_elaboration {
477+
return;
478+
}
479+
472480
if !self.mark_inactive_variants_as_uninit {
473481
return;
474482
}

compiler/rustc_mir/src/transform/check_consts/ops.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ impl NonConstOp for FnPtrCast {
151151
}
152152

153153
#[derive(Debug)]
154-
pub struct Generator;
154+
pub struct Generator(pub hir::GeneratorKind);
155155
impl NonConstOp for Generator {
156156
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
157157
Status::Forbidden
158158
}
159159

160160
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
161-
ccx.tcx.sess.struct_span_err(span, "Generators and `async` functions cannot be `const`")
161+
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
162+
ccx.tcx.sess.struct_span_err(span, &msg)
162163
}
163164
}
164165

compiler/rustc_mir/src/transform/check_consts/validation.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,14 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
770770
return;
771771
}
772772

773+
// `async` blocks get lowered to `std::future::from_generator(/* a closure */)`.
774+
let is_async_block = Some(callee) == tcx.lang_items().from_generator_fn();
775+
if is_async_block {
776+
let kind = hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block);
777+
self.check_op(ops::Generator(kind));
778+
return;
779+
}
780+
773781
// HACK: This is to "unstabilize" the `transmute` intrinsic
774782
// within const fns. `transmute` is allowed in all other const contexts.
775783
// This won't really scale to more intrinsics or functions. Let's allow const
@@ -869,7 +877,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
869877
TerminatorKind::Abort => self.check_op(ops::Abort),
870878

871879
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
872-
self.check_op(ops::Generator)
880+
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
873881
}
874882

875883
TerminatorKind::Assert { .. }

compiler/rustc_parse/src/parser/pat.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ impl<'a> Parser<'a> {
795795
}
796796
self.bump();
797797
let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
798+
e.span_label(path.span, "while parsing the fields for this pattern");
798799
e.emit();
799800
self.recover_stmt();
800801
(vec![], true)
@@ -844,7 +845,7 @@ impl<'a> Parser<'a> {
844845

845846
// check that a comma comes after every field
846847
if !ate_comma {
847-
let err = self.struct_span_err(self.prev_token.span, "expected `,`");
848+
let err = self.struct_span_err(self.token.span, "expected `,`");
848849
if let Some(mut delayed) = delayed_err {
849850
delayed.emit();
850851
}

compiler/rustc_passes/src/check_attr.rs

+27-7
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,42 @@ impl CheckAttrVisitor<'tcx> {
260260
}
261261
}
262262

263+
fn doc_alias_str_error(&self, meta: &NestedMetaItem) {
264+
self.tcx
265+
.sess
266+
.struct_span_err(
267+
meta.span(),
268+
"doc alias attribute expects a string: #[doc(alias = \"0\")]",
269+
)
270+
.emit();
271+
}
272+
263273
fn check_doc_alias(&self, attr: &Attribute, hir_id: HirId, target: Target) -> bool {
264274
if let Some(mi) = attr.meta() {
265275
if let Some(list) = mi.meta_item_list() {
266276
for meta in list {
267277
if meta.has_name(sym::alias) {
268-
if !meta.is_value_str()
269-
|| meta
270-
.value_str()
271-
.map(|s| s.to_string())
272-
.unwrap_or_else(String::new)
273-
.is_empty()
278+
if !meta.is_value_str() {
279+
self.doc_alias_str_error(meta);
280+
return false;
281+
}
282+
let doc_alias =
283+
meta.value_str().map(|s| s.to_string()).unwrap_or_else(String::new);
284+
if doc_alias.is_empty() {
285+
self.doc_alias_str_error(meta);
286+
return false;
287+
}
288+
if let Some(c) =
289+
doc_alias.chars().find(|&c| c == '"' || c == '\'' || c.is_whitespace())
274290
{
275291
self.tcx
276292
.sess
277293
.struct_span_err(
278294
meta.span(),
279-
"doc alias attribute expects a string: #[doc(alias = \"0\")]",
295+
&format!(
296+
"{:?} character isn't allowed in `#[doc(alias = \"...\")]`",
297+
c,
298+
),
280299
)
281300
.emit();
282301
return false;
@@ -312,6 +331,7 @@ impl CheckAttrVisitor<'tcx> {
312331
&format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err),
313332
)
314333
.emit();
334+
return false;
315335
}
316336
}
317337
}

compiler/rustc_resolve/src/late/diagnostics.rs

+29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_hir::def::{self, CtorKind, DefKind};
1616
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
1717
use rustc_hir::PrimTy;
1818
use rustc_session::config::nightly_options;
19+
use rustc_session::parse::feature_err;
1920
use rustc_span::hygiene::MacroKind;
2021
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2122
use rustc_span::{BytePos, Span, DUMMY_SP};
@@ -1599,4 +1600,32 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
15991600
_ => {}
16001601
}
16011602
}
1603+
1604+
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics` so
1605+
/// this function will emit an error if `min_const_generics` is enabled, the body identified by
1606+
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
1607+
crate fn maybe_emit_forbidden_non_static_lifetime_error(
1608+
&self,
1609+
body_id: hir::BodyId,
1610+
lifetime_ref: &'tcx hir::Lifetime,
1611+
) {
1612+
let is_anon_const = matches!(
1613+
self.tcx.def_kind(self.tcx.hir().body_owner_def_id(body_id)),
1614+
hir::def::DefKind::AnonConst
1615+
);
1616+
let is_allowed_lifetime = matches!(
1617+
lifetime_ref.name,
1618+
hir::LifetimeName::Implicit | hir::LifetimeName::Static | hir::LifetimeName::Underscore
1619+
);
1620+
1621+
if self.tcx.features().min_const_generics && is_anon_const && !is_allowed_lifetime {
1622+
feature_err(
1623+
&self.tcx.sess.parse_sess,
1624+
sym::const_generics,
1625+
lifetime_ref.span,
1626+
"a non-static lifetime is not allowed in a `const`",
1627+
)
1628+
.emit();
1629+
}
1630+
}
16021631
}

compiler/rustc_resolve/src/late/lifetimes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
17771777
let result = loop {
17781778
match *scope {
17791779
Scope::Body { id, s } => {
1780+
// Non-static lifetimes are prohibited in anonymous constants under
1781+
// `min_const_generics`.
1782+
self.maybe_emit_forbidden_non_static_lifetime_error(id, lifetime_ref);
1783+
17801784
outermost_body = Some(id);
17811785
scope = s;
17821786
}

compiler/rustc_session/src/options.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10081008
"a single extra argument to prepend the linker invocation (can be used several times)"),
10091009
pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
10101010
"extra arguments to prepend to the linker invocation (space separated)"),
1011+
precise_enum_drop_elaboration: bool = (true, parse_bool, [TRACKED],
1012+
"use a more precise version of drop elaboration for matches on enums (default: yes). \
1013+
This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1014+
See #77382 and #74551."),
10111015
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
10121016
"make rustc print the total optimization fuel used by a crate"),
10131017
print_link_args: bool = (false, parse_bool, [UNTRACKED],

library/core/src/intrinsics.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1901,9 +1901,10 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
19011901
/// ```
19021902
/// use std::ptr;
19031903
///
1904-
/// /// # Safety:
1904+
/// /// # Safety
1905+
/// ///
19051906
/// /// * `ptr` must be correctly aligned for its type and non-zero.
1906-
/// /// * `ptr` must be valid for reads of `elts` contiguous objects of type `T`.
1907+
/// /// * `ptr` must be valid for reads of `elts` contiguous elements of type `T`.
19071908
/// /// * Those elements must not be used after calling this function unless `T: Copy`.
19081909
/// # #[allow(dead_code)]
19091910
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {

library/core/src/iter/adapters/chain.rs

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ use crate::usize;
66
///
77
/// This `struct` is created by [`Iterator::chain`]. See its documentation
88
/// for more.
9+
///
10+
/// # Examples
11+
///
12+
/// ```
13+
/// use std::iter::Chain;
14+
/// use std::slice::Iter;
15+
///
16+
/// let a1 = [1, 2, 3];
17+
/// let a2 = [4, 5, 6];
18+
/// let iter: Chain<Iter<_>, Iter<_>> = a1.iter().chain(a2.iter());
19+
/// ```
920
#[derive(Clone, Debug)]
1021
#[must_use = "iterators are lazy and do nothing unless consumed"]
1122
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/iter/traits/double_ended.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub trait DoubleEndedIterator: Iterator {
123123
/// assert_eq!(iter.advance_back_by(100), Err(1)); // only `&3` was skipped
124124
/// ```
125125
#[inline]
126-
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "none")]
126+
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
127127
fn advance_back_by(&mut self, n: usize) -> Result<(), usize> {
128128
for i in 0..n {
129129
self.next_back().ok_or(i)?;

library/core/src/iter/traits/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub trait Iterator {
314314
/// assert_eq!(iter.advance_by(100), Err(1)); // only `&4` was skipped
315315
/// ```
316316
#[inline]
317-
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "none")]
317+
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
318318
fn advance_by(&mut self, n: usize) -> Result<(), usize> {
319319
for i in 0..n {
320320
self.next().ok_or(i)?;

0 commit comments

Comments
 (0)