Skip to content

Commit 0e41c62

Browse files
committed
Auto merge of rust-lang#88094 - m-ou-se:rollup-2fxss0q, r=m-ou-se
Rollup of 10 pull requests Successful merges: - rust-lang#87178 ([rustdoc] Copy only item path to clipboard rather than full `use` statement.) - rust-lang#87677 (Adding explicit notice of lack of documentation for Tier 2 Platforms) - rust-lang#87958 (Closure migration multispan suggestions) - rust-lang#87967 (Detect fake spans in non_fmt_panic lint.) - rust-lang#88011 (Enable `--all-targets` for `x.py check` unconditionally) - rust-lang#88030 (Assign FIXMEs to me and remove obsolete ones) - rust-lang#88052 (Update redox_syscall) - rust-lang#88055 (Update RELEASES.md for 1.55.0) - rust-lang#88080 (Skip assert ICE with default_method_body_is_const) - rust-lang#88089 (Rustdoc font test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0035d9d + d5ec5aa commit 0e41c62

File tree

28 files changed

+352
-261
lines changed

28 files changed

+352
-261
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2955,9 +2955,9 @@ dependencies = [
29552955

29562956
[[package]]
29572957
name = "redox_syscall"
2958-
version = "0.2.5"
2958+
version = "0.2.10"
29592959
source = "registry+https://github.com/rust-lang/crates.io-index"
2960-
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
2960+
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
29612961
dependencies = [
29622962
"bitflags",
29632963
]

RELEASES.md

+142
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,145 @@
1+
Version 1.55.0 (2021-09-09)
2+
============================
3+
4+
Language
5+
--------
6+
- [You can now write open "from" range patterns (`X..`), which will start at `X` and
7+
will end at the maximum value of the integer.][83918]
8+
- [You can now explicitly import the prelude of different editions
9+
through `std::prelude` (e.g. `use std::prelude::rust_2021::*;`).][86294]
10+
11+
Compiler
12+
--------
13+
- [Added tier 3\* support for `powerpc-unknown-freebsd`.][87370]
14+
- [Added tier 3 support for `powerpc64le-unknown-freebsd`.][83572]
15+
16+
\* Refer to Rust's [platform support page][platform-support-doc] for more
17+
information on Rust's tiered platform support.
18+
19+
Libraries
20+
---------
21+
22+
- [Updated std's float parsing to use the Eisel-Lemire algorithm.][86761]
23+
These improvements should in general provide faster string parsing of floats,
24+
no longer reject certain valid floating point values, and reduce
25+
the produced code size for non-stripped artifacts.
26+
- [`string::Drain` now implements `AsRef<str>` and `AsRef<[u8]>`.][86858]
27+
- [`collections::{BinaryHeap, BTreeSet, HashSet, LinkedList, VecDeque}` now
28+
implement `From<[T; N]>`.][84111]
29+
- [`collections::{BTreeMap, HashMap}` now implement `From<[(K, V); N]>`.][84111]
30+
This allows you to write the following;
31+
```rust
32+
let highscores = std::collections::HashMap::from([
33+
("Alice", 9000u32),
34+
("Bob", 7250),
35+
("Charlie", 5500),
36+
]);
37+
```
38+
39+
Stabilised APIs
40+
---------------
41+
42+
- [`Bound::cloned`]
43+
- [`Drain::as_str`]
44+
- [`IntoInnerError::into_error`]
45+
- [`IntoInnerError::into_parts`]
46+
- [`MaybeUninit::assume_init_mut`]
47+
- [`MaybeUninit::assume_init_ref`]
48+
- [`MaybeUninit::write`]
49+
- [`array::map`]
50+
- [`ops::ControlFlow`]
51+
- [`x86::_bittest`]
52+
- [`x86::_bittestandcomplement`]
53+
- [`x86::_bittestandreset`]
54+
- [`x86::_bittestandset`]
55+
- [`x86_64::_bittest64`]
56+
- [`x86_64::_bittestandcomplement64`]
57+
- [`x86_64::_bittestandreset64`]
58+
- [`x86_64::_bittestandset64`]
59+
60+
The following previously stable functions are now `const`.
61+
62+
- [`str::from_utf8_unchecked`]
63+
- [`mem::transmute`]
64+
65+
66+
Cargo
67+
-----
68+
- [Cargo will now deduplicate compiler diagnostics to the terminal when invoking
69+
rustc in parallel such as when using `cargo test`.][cargo/9675]
70+
- [The package definition in `cargo metadata` now includes the `"default_run"`
71+
field from the manifest.][cargo/9550]
72+
- [Added `cargo d` as an alias for `cargo doc`.][cargo/9680]
73+
74+
Rustdoc
75+
-------
76+
- [Added "Go to item on exact match" search option.][85876]
77+
- [The "Implementors" section on traits no longer shows redundant
78+
method definitions.][85970]
79+
- [Trait implementations are toggled open by default.][86260] This should make the
80+
implementations more searchable by tools like `CTRL+F` in your browser.
81+
- [Intra-doc links should now correctly resolve associated items (e.g. methods)
82+
through type aliases.][86334]
83+
- [Traits which are marked with `#[doc(hidden)]` will no longer appear in the
84+
"Trait Implementations" section.][86513]
85+
86+
87+
Compatibility Notes
88+
-------------------
89+
- [std functions that return an `io::Error` will no longer use the
90+
`ErrorKind::Other` variant.][85746] This is to better reflect that these
91+
kinds of errors could be categorised [into newer more specific `ErrorKind`
92+
variants][79965], and that they do not represent a user error.
93+
- [Using environment variable names with `process::Command` on Windows now
94+
behaves as expected.][85270] Previously using envionment variables with
95+
`Command` would cause them to be ASCII-uppercased.
96+
- [Rustdoc will now warn on using rustdoc lints that aren't prefixed
97+
with `rustdoc::`][86849]
98+
99+
[86849]: https://github.com/rust-lang/rust/pull/86849
100+
[86513]: https://github.com/rust-lang/rust/pull/86513
101+
[86334]: https://github.com/rust-lang/rust/pull/86334
102+
[86260]: https://github.com/rust-lang/rust/pull/86260
103+
[85970]: https://github.com/rust-lang/rust/pull/85970
104+
[85876]: https://github.com/rust-lang/rust/pull/85876
105+
[83572]: https://github.com/rust-lang/rust/pull/83572
106+
[86294]: https://github.com/rust-lang/rust/pull/86294
107+
[86858]: https://github.com/rust-lang/rust/pull/86858
108+
[86761]: https://github.com/rust-lang/rust/pull/86761
109+
[85769]: https://github.com/rust-lang/rust/pull/85769
110+
[85746]: https://github.com/rust-lang/rust/pull/85746
111+
[85305]: https://github.com/rust-lang/rust/pull/85305
112+
[85270]: https://github.com/rust-lang/rust/pull/85270
113+
[84111]: https://github.com/rust-lang/rust/pull/84111
114+
[83918]: https://github.com/rust-lang/rust/pull/83918
115+
[79965]: https://github.com/rust-lang/rust/pull/79965
116+
[87370]: https://github.com/rust-lang/rust/pull/87370
117+
[87298]: https://github.com/rust-lang/rust/pull/87298
118+
[cargo/9675]: https://github.com/rust-lang/cargo/pull/9675
119+
[cargo/9550]: https://github.com/rust-lang/cargo/pull/9550
120+
[cargo/9680]: https://github.com/rust-lang/cargo/pull/9680
121+
[`array::map`]: https://doc.rust-lang.org/stable/std/primitive.array.html#method.map
122+
[`Bound::cloned`]: https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.cloned
123+
[`Drain::as_str`]: https://doc.rust-lang.org/stable/std/string/struct.Drain.html#method.as_str
124+
[`IntoInnerError::into_error`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_error
125+
[`IntoInnerError::into_parts`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_parts
126+
[`MaybeUninit::assume_init_mut`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_mut
127+
[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref
128+
[`MaybeUninit::write`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.write
129+
[`Seek::rewind`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html#method.rewind
130+
[`mem::transmute`]: https://doc.rust-lang.org/stable/std/mem/fn.transmute.html
131+
[`ops::ControlFlow`]: https://doc.rust-lang.org/stable/std/ops/enum.ControlFlow.html
132+
[`str::from_utf8_unchecked`]: https://doc.rust-lang.org/stable/std/str/fn.from_utf8_unchecked.html
133+
[`x86::_bittest`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittest.html
134+
[`x86::_bittestandcomplement`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandcomplement.html
135+
[`x86::_bittestandreset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandreset.html
136+
[`x86::_bittestandset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandset.html
137+
[`x86_64::_bittest64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittest64.html
138+
[`x86_64::_bittestandcomplement64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandcomplement64.html
139+
[`x86_64::_bittestandreset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandreset64.html
140+
[`x86_64::_bittestandset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandset64.html
141+
142+
1143
Version 1.54.0 (2021-07-29)
2144
============================
3145

compiler/rustc_infer/src/traits/engine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
6363
infcx: &InferCtxt<'_, 'tcx>,
6464
) -> Result<(), Vec<FulfillmentError<'tcx>>>;
6565

66-
// FIXME this should not provide a default body for chalk as chalk should be updated
66+
// FIXME(fee1-dead) this should not provide a default body for chalk as chalk should be updated
6767
fn select_with_constness_where_possible(
6868
&mut self,
6969
infcx: &InferCtxt<'_, 'tcx>,

compiler/rustc_lint/src/non_fmt_panic.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
101101
let mut l = lint.build("panic message is not a string literal");
102102
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
103103
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
104-
if !span.contains(arg_span) {
104+
if !is_arg_inside_call(arg_span, span) {
105105
// No clue where this argument is coming from.
106106
l.emit();
107107
return;
@@ -204,7 +204,7 @@ fn check_panic_str<'tcx>(
204204
_ => "panic message contains unused formatting placeholders",
205205
});
206206
l.note("this message is not used as a format string when given without arguments, but will be in Rust 2021");
207-
if span.contains(arg.span) {
207+
if is_arg_inside_call(arg.span, span) {
208208
l.span_suggestion(
209209
arg.span.shrink_to_hi(),
210210
&format!("add the missing argument{}", pluralize!(n_arguments)),
@@ -235,7 +235,7 @@ fn check_panic_str<'tcx>(
235235
cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
236236
let mut l = lint.build(msg);
237237
l.note("this message is not used as a format string, but will be in Rust 2021");
238-
if span.contains(arg.span) {
238+
if is_arg_inside_call(arg.span, span) {
239239
l.span_suggestion(
240240
arg.span.shrink_to_lo(),
241241
"add a \"{}\" format string to use the message literally",
@@ -283,3 +283,11 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span,
283283
if let hygiene::ExpnKind::Macro(_, symbol) = expn.kind { symbol } else { sym::panic };
284284
(expn.call_site, panic_macro, macro_symbol.as_str())
285285
}
286+
287+
fn is_arg_inside_call(arg: Span, call: Span) -> bool {
288+
// We only add suggestions if the argument we're looking at appears inside the
289+
// panic call in the source file, to avoid invalid suggestions when macros are involved.
290+
// We specifically check for the spans to not be identical, as that happens sometimes when
291+
// proc_macros lie about spans and apply the same span to all the tokens they produce.
292+
call.contains(arg) && !call.source_equal(&arg)
293+
}

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir as hir;
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_middle::mir;
1111
use rustc_middle::ty::{self, TyCtxt};
12-
use rustc_span::Symbol;
12+
use rustc_span::{sym, Symbol};
1313

1414
pub use self::qualifs::Qualif;
1515

@@ -104,6 +104,13 @@ pub fn rustc_allow_const_fn_unstable(
104104
pub fn is_const_stable_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
105105
use attr::{ConstStability, Stability, StabilityLevel};
106106

107+
// A default body marked const is not const-stable because const
108+
// trait fns currently cannot be const-stable. We shouldn't
109+
// restrict default bodies to only call const-stable functions.
110+
if tcx.has_attr(def_id, sym::default_method_body_is_const) {
111+
return false;
112+
}
113+
107114
// Const-stability is only relevant for `const fn`.
108115
assert!(tcx.is_const_fn_raw(def_id));
109116

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
316316
self.infcx.tcx
317317
}
318318

319-
/// returns `true` if the predicate is considered `const` to
319+
/// Returns `true` if the predicate is considered `const` to
320320
/// this selection context.
321321
pub fn is_predicate_const(&self, pred: ty::Predicate<'_>) -> bool {
322322
match pred.kind().skip_binder() {

compiler/rustc_traits/src/type_op.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
66
use rustc_infer::traits::TraitEngineExt as _;
77
use rustc_middle::ty::query::Providers;
88
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
9-
use rustc_middle::ty::{
10-
self, FnSig, Lift, PolyFnSig, PredicateKind, Ty, TyCtxt, TypeFoldable, Variance,
11-
};
9+
use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance};
1210
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate};
1311
use rustc_span::DUMMY_SP;
1412
use rustc_trait_selection::infer::InferCtxtBuilderExt;
@@ -87,16 +85,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
8785
Ok(())
8886
}
8987

90-
fn prove_predicate(&mut self, mut predicate: Predicate<'tcx>) {
91-
if let PredicateKind::Trait(mut tr) = predicate.kind().skip_binder() {
92-
if let hir::Constness::Const = tr.constness {
93-
// FIXME check if we actually want to prove const predicates inside AscribeUserType
94-
tr.constness = hir::Constness::NotConst;
95-
predicate =
96-
predicate.kind().rebind(PredicateKind::Trait(tr)).to_predicate(self.tcx());
97-
}
98-
}
99-
88+
fn prove_predicate(&mut self, predicate: Predicate<'tcx>) {
10089
self.fulfill_cx.register_predicate_obligation(
10190
self.infcx,
10291
Obligation::new(ObligationCause::dummy(), self.param_env, predicate),

compiler/rustc_typeck/src/check/upvar.rs

+53-37
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_middle::ty::{
4747
};
4848
use rustc_session::lint;
4949
use rustc_span::sym;
50-
use rustc_span::{MultiSpan, Span, Symbol, DUMMY_SP};
50+
use rustc_span::{BytePos, MultiSpan, Pos, Span, Symbol, DUMMY_SP};
5151
use rustc_trait_selection::infer::InferCtxtExt;
5252

5353
use rustc_data_structures::stable_map::FxHashMap;
@@ -645,6 +645,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
645645
}
646646
diagnostics_builder.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>");
647647

648+
let diagnostic_msg = format!(
649+
"add a dummy let to cause {} to be fully captured",
650+
migrated_variables_concat
651+
);
652+
648653
let mut closure_body_span = self.tcx.hir().span(body_id.hir_id);
649654

650655
// If the body was entirely expanded from a macro
@@ -655,43 +660,54 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
655660
closure_body_span = closure_body_span.parent().unwrap_or(DUMMY_SP);
656661
}
657662

658-
let (span, sugg, app) =
659-
match self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
660-
Ok(s) => {
661-
let trimmed = s.trim_start();
662-
let mut lines = trimmed.lines();
663-
let line1 = lines.next().unwrap_or_default();
664-
665-
// If the closure contains a block then replace the opening brace
666-
// with "{ let _ = (..); "
667-
let sugg = if line1.trim_end() == "{" {
668-
// This is a multi-line closure with just a `{` on the first line,
669-
// so we put the `let` on its own line.
670-
// We take the indentation from the next non-empty line.
671-
let line2 = lines.filter(|line| !line.is_empty()).next().unwrap_or_default();
672-
let indent = line2.split_once(|c: char| !c.is_whitespace()).unwrap_or_default().0;
673-
format!("{{\n{}{};{}", indent, migration_string, &trimmed[line1.len()..])
674-
} else if line1.starts_with('{') {
675-
format!("{{ {}; {}", migration_string, &trimmed[1..].trim_start())
676-
} else {
677-
format!("{{ {}; {} }}", migration_string, s)
678-
};
679-
(closure_body_span, sugg, Applicability::MachineApplicable)
680-
}
681-
Err(_) => (closure_span, migration_string.clone(), Applicability::HasPlaceholders),
682-
};
683-
684-
let diagnostic_msg = format!(
685-
"add a dummy let to cause {} to be fully captured",
686-
migrated_variables_concat
687-
);
663+
if let Ok(s) = self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
664+
let mut lines = s.lines();
665+
let line1 = lines.next().unwrap_or_default();
666+
667+
if line1.trim_end() == "{" {
668+
// This is a multi-line closure with just a `{` on the first line,
669+
// so we put the `let` on its own line.
670+
// We take the indentation from the next non-empty line.
671+
let line2 = lines.filter(|line| !line.is_empty()).next().unwrap_or_default();
672+
let indent = line2.split_once(|c: char| !c.is_whitespace()).unwrap_or_default().0;
673+
diagnostics_builder.span_suggestion(
674+
closure_body_span.with_lo(closure_body_span.lo() + BytePos::from_usize(line1.len())).shrink_to_lo(),
675+
&diagnostic_msg,
676+
format!("\n{}{};", indent, migration_string),
677+
Applicability::MachineApplicable,
678+
);
679+
} else if line1.starts_with('{') {
680+
// This is a closure with its body wrapped in
681+
// braces, but with more than just the opening
682+
// brace on the first line. We put the `let`
683+
// directly after the `{`.
684+
diagnostics_builder.span_suggestion(
685+
closure_body_span.with_lo(closure_body_span.lo() + BytePos(1)).shrink_to_lo(),
686+
&diagnostic_msg,
687+
format!(" {};", migration_string),
688+
Applicability::MachineApplicable,
689+
);
690+
} else {
691+
// This is a closure without braces around the body.
692+
// We add braces to add the `let` before the body.
693+
diagnostics_builder.multipart_suggestion(
694+
&diagnostic_msg,
695+
vec![
696+
(closure_body_span.shrink_to_lo(), format!("{{ {}; ", migration_string)),
697+
(closure_body_span.shrink_to_hi(), " }".to_string()),
698+
],
699+
Applicability::MachineApplicable
700+
);
701+
}
702+
} else {
703+
diagnostics_builder.span_suggestion(
704+
closure_span,
705+
&diagnostic_msg,
706+
migration_string,
707+
Applicability::HasPlaceholders
708+
);
709+
}
688710

689-
diagnostics_builder.span_suggestion(
690-
span,
691-
&diagnostic_msg,
692-
sugg,
693-
app,
694-
);
695711
diagnostics_builder.emit();
696712
},
697713
);

library/alloc/tests/const_fns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub const MY_VEC: Vec<usize> = Vec::new();
1010
#[allow(dead_code)]
1111
pub const MY_STRING: String = String::new();
1212

13-
// FIXME remove this struct once we put `K: ?const Ord` on BTreeMap::new.
13+
// FIXME(fee1-dead) remove this struct once we put `K: ?const Ord` on BTreeMap::new.
1414
#[derive(PartialEq, Eq, PartialOrd)]
1515
pub struct MyType;
1616

library/alloc/tests/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#![feature(string_remove_matches)]
2626
#![feature(const_btree_new)]
2727
#![feature(const_trait_impl)]
28-
// FIXME remove this when const_trait_impl is not incomplete anymore
29-
#![allow(incomplete_features)]
3028

3129
use std::collections::hash_map::DefaultHasher;
3230
use std::hash::{Hash, Hasher};

0 commit comments

Comments
 (0)