Skip to content

Commit d1aed50

Browse files
committed
Auto merge of #81417 - JohnTitor:rollup-yi3q05s, r=JohnTitor
Rollup of 14 pull requests Successful merges: - #80812 (Update RELEASES.md for 1.50.0) - #80876 (Add `unwrap_unchecked()` methods for `Option` and `Result`) - #80900 (Fix ICE with `ReadPointerAsBytes` validation error) - #81191 (BTreeMap: test all borrowing interfaces and test more chaotic order behavior) - #81195 (Account for generics when suggesting bound) - #81299 (Fix some bugs reported by eslint) - #81325 (typeck: Don't suggest converting LHS exprs) - #81353 (Fix spelling in documentation for error E0207) - #81369 (rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry) - #81389 (rustdoc: Document CommonMark extensions.) - #81399 (Update books) - #81401 (tidy: Some code cleanup.) - #81407 (Refine "remove semicolon" suggestion in trait selection) - #81412 (Fix assertion in `MaybeUninit::array_assume_init()` for zero-length arrays) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7907345 + b2f6c2a commit d1aed50

File tree

38 files changed

+747
-186
lines changed

38 files changed

+747
-186
lines changed

Diff for: RELEASES.md

+120
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,123 @@
1+
Version 1.50.0 (2021-02-11)
2+
============================
3+
4+
Language
5+
-----------------------
6+
- [You can now use `const` values for `x` in `[x; N]` array expressions.][79270]
7+
This has been technically possible since 1.38.0, as it was unintentionally stabilized.
8+
- [Assignments to `ManuallyDrop<T>` union fields are now considered safe.][78068]
9+
10+
Compiler
11+
-----------------------
12+
- [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142]
13+
- [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484]
14+
- [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484]
15+
16+
\* Refer to Rust's [platform support page][forge-platform-support] for more
17+
information on Rust's tiered platform support.
18+
19+
Libraries
20+
-----------------------
21+
22+
- [`proc_macro::Punct` now implements `PartialEq<char>`.][78636]
23+
- [`ops::{Index, IndexMut}` are now implemented for fixed sized arrays of any length.][74989]
24+
- [On Unix platforms, the `std::fs::File` type now has a "niche" of `-1`.][74699]
25+
This value cannot be a valid file descriptor, and now means `Option<File>` takes
26+
up the same amount of space as `File`.
27+
28+
Stabilized APIs
29+
---------------
30+
31+
- [`bool::then`]
32+
- [`btree_map::Entry::or_insert_with_key`]
33+
- [`f32::clamp`]
34+
- [`f64::clamp`]
35+
- [`hash_map::Entry::or_insert_with_key`]
36+
- [`Ord::clamp`]
37+
- [`RefCell::take`]
38+
- [`slice::fill`]
39+
- [`UnsafeCell::get_mut`]
40+
41+
The following previously stable methods are now `const`.
42+
43+
- [`IpAddr::is_ipv4`]
44+
- [`IpAddr::is_ipv6`]
45+
- [`Layout::size`]
46+
- [`Layout::align`]
47+
- [`Layout::from_size_align`]
48+
- `pow` for all integer types.
49+
- `checked_pow` for all integer types.
50+
- `saturating_pow` for all integer types.
51+
- `wrapping_pow` for all integer types.
52+
- `next_power_of_two` for all unsigned integer types.
53+
- `checked_power_of_two` for all unsigned integer types.
54+
55+
Cargo
56+
-----------------------
57+
58+
- [Added the `[build.rustc-workspace-wrapper]` option.][cargo/8976]
59+
This option sets a wrapper to execute instead of `rustc`, for workspace members only.
60+
- [`cargo:rerun-if-changed` will now, if provided a directory, scan the entire
61+
contents of that directory for changes.][cargo/8973]
62+
- [Added the `--workspace` flag to the `cargo update` command.][cargo/8725]
63+
64+
Misc
65+
----
66+
67+
- [The search results tab and the help button are focusable with keyboard in rustdoc.][79896]
68+
- [Running tests will now print the total time taken to execute.][75752]
69+
70+
Compatibility Notes
71+
-------------------
72+
73+
- [The `compare_and_swap` method on atomics has been deprecated.][79261] It's
74+
recommended to use the `compare_exchange` and `compare_exchange_weak` methods instead.
75+
- [Changes in how `TokenStream`s are checked have fixed some cases where you could write
76+
unhygenic `macro_rules!` macros.][79472]
77+
- [`#![test]` as an inner attribute is now considered unstable like other inner macro
78+
attributes, and reports an error by default through the `soft_unstable` lint.][79003]
79+
- [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864]
80+
- [Dropped support for all cloudabi targets.][78439]
81+
- [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's
82+
recommended to use the `#[panic_handler]` attribute to provide your own implementation.
83+
- [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296]
84+
85+
[74989]: https://github.com/rust-lang/rust/pull/74989
86+
[79261]: https://github.com/rust-lang/rust/pull/79261
87+
[79896]: https://github.com/rust-lang/rust/pull/79896
88+
[79484]: https://github.com/rust-lang/rust/pull/79484
89+
[79472]: https://github.com/rust-lang/rust/pull/79472
90+
[79270]: https://github.com/rust-lang/rust/pull/79270
91+
[79003]: https://github.com/rust-lang/rust/pull/79003
92+
[78864]: https://github.com/rust-lang/rust/pull/78864
93+
[78636]: https://github.com/rust-lang/rust/pull/78636
94+
[78439]: https://github.com/rust-lang/rust/pull/78439
95+
[78343]: https://github.com/rust-lang/rust/pull/78343
96+
[78296]: https://github.com/rust-lang/rust/pull/78296
97+
[78068]: https://github.com/rust-lang/rust/pull/78068
98+
[75752]: https://github.com/rust-lang/rust/pull/75752
99+
[74699]: https://github.com/rust-lang/rust/pull/74699
100+
[78142]: https://github.com/rust-lang/rust/pull/78142
101+
[77484]: https://github.com/rust-lang/rust/pull/77484
102+
[cargo/8976]: https://github.com/rust-lang/cargo/pull/8976
103+
[cargo/8973]: https://github.com/rust-lang/cargo/pull/8973
104+
[cargo/8725]: https://github.com/rust-lang/cargo/pull/8725
105+
[`IpAddr::is_ipv4`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv4
106+
[`IpAddr::is_ipv6`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv6
107+
[`Layout::align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.align
108+
[`Layout::from_size_align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.from_size_align
109+
[`Layout::size`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.size
110+
[`Ord::clamp`]: https://doc.rust-lang.org/stable/std/cmp/trait.Ord.html#method.clamp
111+
[`RefCell::take`]: https://doc.rust-lang.org/stable/std/cell/struct.RefCell.html#method.take
112+
[`UnsafeCell::get_mut`]: https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.get_mut
113+
[`bool::then`]: https://doc.rust-lang.org/stable/std/primitive.bool.html#method.then
114+
[`btree_map::Entry::or_insert_with_key`]: https://doc.rust-lang.org/stable/std/collections/btree_map/enum.Entry.html#method.or_insert_with_key
115+
[`f32::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.clamp
116+
[`f64::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f64.html#method.clamp
117+
[`hash_map::Entry::or_insert_with_key`]: https://doc.rust-lang.org/stable/std/collections/hash_map/enum.Entry.html#method.or_insert_with_key
118+
[`slice::fill`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.fill
119+
120+
1121
Version 1.49.0 (2020-12-31)
2122
============================
3123

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{CachedModuleCodegen, CrateInfo, MemFlags, ModuleCodegen, ModuleKind}
1313
use rustc_attr as attr;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_data_structures::profiling::print_time_passes_entry;
16-
use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator};
16+
use rustc_data_structures::sync::{par_iter, ParallelIterator};
1717
use rustc_hir as hir;
1818
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
1919
use rustc_hir::lang_items::LangItem;
@@ -554,8 +554,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
554554
codegen_units
555555
};
556556

557-
let total_codegen_time = Lock::new(Duration::new(0, 0));
558-
559557
// The non-parallel compiler can only translate codegen units to LLVM IR
560558
// on a single thread, leading to a staircase effect where the N LLVM
561559
// threads have to wait on the single codegen threads to generate work
@@ -578,23 +576,25 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
578576
.collect();
579577

580578
// Compile the found CGUs in parallel.
581-
par_iter(cgus)
579+
let start_time = Instant::now();
580+
581+
let pre_compiled_cgus = par_iter(cgus)
582582
.map(|(i, _)| {
583-
let start_time = Instant::now();
584583
let module = backend.compile_codegen_unit(tcx, codegen_units[i].name());
585-
let mut time = total_codegen_time.lock();
586-
*time += start_time.elapsed();
587584
(i, module)
588585
})
589-
.collect()
586+
.collect();
587+
588+
(pre_compiled_cgus, start_time.elapsed())
590589
})
591590
} else {
592-
FxHashMap::default()
591+
(FxHashMap::default(), Duration::new(0, 0))
593592
}
594593
};
595594

596595
let mut cgu_reuse = Vec::new();
597596
let mut pre_compiled_cgus: Option<FxHashMap<usize, _>> = None;
597+
let mut total_codegen_time = Duration::new(0, 0);
598598

599599
for (i, cgu) in codegen_units.iter().enumerate() {
600600
ongoing_codegen.wait_for_signal_to_codegen_item();
@@ -607,7 +607,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
607607
codegen_units.iter().map(|cgu| determine_cgu_reuse(tcx, &cgu)).collect()
608608
});
609609
// Pre compile some CGUs
610-
pre_compiled_cgus = Some(pre_compile_cgus(&cgu_reuse));
610+
let (compiled_cgus, codegen_time) = pre_compile_cgus(&cgu_reuse);
611+
pre_compiled_cgus = Some(compiled_cgus);
612+
total_codegen_time += codegen_time;
611613
}
612614

613615
let cgu_reuse = cgu_reuse[i];
@@ -621,8 +623,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
621623
} else {
622624
let start_time = Instant::now();
623625
let module = backend.compile_codegen_unit(tcx, cgu.name());
624-
let mut time = total_codegen_time.lock();
625-
*time += start_time.elapsed();
626+
total_codegen_time += start_time.elapsed();
626627
module
627628
};
628629
submit_codegened_module_to_llvm(
@@ -663,11 +664,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
663664

664665
// Since the main thread is sometimes blocked during codegen, we keep track
665666
// -Ztime-passes output manually.
666-
print_time_passes_entry(
667-
tcx.sess.time_passes(),
668-
"codegen_to_LLVM_IR",
669-
total_codegen_time.into_inner(),
670-
);
667+
print_time_passes_entry(tcx.sess.time_passes(), "codegen_to_LLVM_IR", total_codegen_time);
671668

672669
ongoing_codegen.check_for_errors(tcx.sess);
673670

Diff for: compiler/rustc_error_codes/src/error_codes/E0207.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<T: Default> Foo {
1414
}
1515
```
1616

17-
Any type parameter parameter of an `impl` must meet at least one of
17+
Any type parameter of an `impl` must meet at least one of
1818
the following criteria:
1919

2020
- it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>`

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,17 @@ impl<'hir> Map<'hir> {
566566
)
567567
}
568568

569+
/// Checks if the node is left-hand side of an assignment.
570+
pub fn is_lhs(&self, id: HirId) -> bool {
571+
match self.find(self.get_parent_node(id)) {
572+
Some(Node::Expr(expr)) => match expr.kind {
573+
ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id,
574+
_ => false,
575+
},
576+
_ => false,
577+
}
578+
}
579+
569580
/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
570581
/// Used exclusively for diagnostics, to avoid suggestion function calls.
571582
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool {

Diff for: compiler/rustc_mir/src/interpret/validity.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
515515
Ok(true)
516516
}
517517
ty::Float(_) | ty::Int(_) | ty::Uint(_) => {
518-
let value = self.ecx.read_scalar(value)?;
518+
let value = try_validation!(
519+
self.ecx.read_scalar(value),
520+
self.path,
521+
err_unsup!(ReadPointerAsBytes) => { "read of part of a pointer" },
522+
);
519523
// NOTE: Keep this in sync with the array optimization for int/float
520524
// types below!
521525
if self.ctfe_mode.is_some() {

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+27-14
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,32 @@ fn suggest_restriction(
286286
);
287287
} else {
288288
// Trivial case: `T` needs an extra bound: `T: Bound`.
289-
let (sp, suggestion) = match super_traits {
290-
None => predicate_constraint(
289+
let (sp, suggestion) = match (
290+
generics
291+
.params
292+
.iter()
293+
.filter(
294+
|p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}),
295+
)
296+
.next(),
297+
super_traits,
298+
) {
299+
(_, None) => predicate_constraint(
291300
generics,
292301
trait_ref.without_const().to_predicate(tcx).to_string(),
293302
),
294-
Some((ident, bounds)) => match bounds {
295-
[.., bound] => (
296-
bound.span().shrink_to_hi(),
297-
format!(" + {}", trait_ref.print_only_trait_path().to_string()),
298-
),
299-
[] => (
300-
ident.span.shrink_to_hi(),
301-
format!(": {}", trait_ref.print_only_trait_path().to_string()),
302-
),
303-
},
303+
(None, Some((ident, []))) => (
304+
ident.span.shrink_to_hi(),
305+
format!(": {}", trait_ref.print_only_trait_path().to_string()),
306+
),
307+
(_, Some((_, [.., bounds]))) => (
308+
bounds.span().shrink_to_hi(),
309+
format!(" + {}", trait_ref.print_only_trait_path().to_string()),
310+
),
311+
(Some(_), Some((_, []))) => (
312+
generics.span.shrink_to_hi(),
313+
format!(": {}", trait_ref.print_only_trait_path().to_string()),
314+
),
304315
};
305316

306317
err.span_suggestion_verbose(
@@ -888,8 +899,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
888899
// no return, suggest removal of semicolon on last statement.
889900
// Once that is added, close #54771.
890901
if let Some(ref stmt) = blk.stmts.last() {
891-
let sp = self.tcx.sess.source_map().end_point(stmt.span);
892-
err.span_label(sp, "consider removing this semicolon");
902+
if let hir::StmtKind::Semi(_) = stmt.kind {
903+
let sp = self.tcx.sess.source_map().end_point(stmt.span);
904+
err.span_label(sp, "consider removing this semicolon");
905+
}
893906
}
894907
}
895908
}

Diff for: compiler/rustc_typeck/src/check/demand.rs

+7
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
816816
|err: &mut DiagnosticBuilder<'_>,
817817
found_to_exp_is_fallible: bool,
818818
exp_to_found_is_fallible: bool| {
819+
let exp_is_lhs =
820+
expected_ty_expr.map(|e| self.tcx.hir().is_lhs(e.hir_id)).unwrap_or(false);
821+
822+
if exp_is_lhs {
823+
return;
824+
}
825+
819826
let always_fallible = found_to_exp_is_fallible
820827
&& (exp_to_found_is_fallible || expected_ty_expr.is_none());
821828
let msg = if literal_is_ty_suffixed(expr) {

0 commit comments

Comments
 (0)