Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #81417

Merged
merged 35 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
679f6f3
Add `unwrap_unchecked()` methods for `Option` and `Result`
ojeda Jan 10, 2021
76299b3
Add `SAFETY` annotations
ojeda Jan 10, 2021
def0e9b
Fix ICE with `ReadPointerAsBytes` validation error
camelid Jan 11, 2021
a7b7a43
Move test to `src/test/ui/consts/`
camelid Jan 11, 2021
495f7cc
BTreeMap: compile-test all borrowing interfaces and test more chaotic…
ssomers Jan 19, 2021
1d03648
Fix spelling in documentation for error E0207
jockbert Jan 24, 2021
2be1993
Ignore test on 32-bit architectures
camelid Jan 25, 2021
59195a2
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes e…
tgnottingham Jan 25, 2021
088c89d
Account for generics when suggesting bound
estebank Jan 19, 2021
042facb
Fix some bugs reported by eslint
GuillaumeGomez Jan 23, 2021
0140dac
Link the reference about undefined behavior
ojeda Jan 25, 2021
01250fc
Add tracking issue
ojeda Jan 25, 2021
1c0a52d
rustdoc: Document CommonMark extensions.
ehuss Jan 25, 2021
3eebf9b
tidy: Remove cargo check.
ehuss Jan 25, 2021
d980715
tidy: Remove edition filter exceptions.
ehuss Jan 25, 2021
6f22f51
tidy: Remove unnecessary trailing semicolon.
ehuss Jan 25, 2021
fdd592a
Update books
ehuss Jan 25, 2021
d035be8
typeck: Don't suggest converting LHS exprs
osa1 Jan 24, 2021
8ddc1c8
Refine "remove semicolon" suggestion in trait selection
osa1 Jan 26, 2021
39e24f7
Update RELEASES.md for 1.50.0
XAMPPRocky Jan 8, 2021
f520667
Fix assertion in `MaybeUninit::array_assume_init()` for zero-length a…
Jan 26, 2021
f85fd81
Rollup merge of #80812 - rust-lang:relnotes-1.50.0, r=Mark-Simulacrum
JohnTitor Jan 26, 2021
fe6b3a9
Rollup merge of #80876 - ojeda:option-result-unwrap_unchecked, r=m-ou-se
JohnTitor Jan 26, 2021
c2c90bf
Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obk
JohnTitor Jan 26, 2021
8299105
Rollup merge of #81191 - ssomers:btree_more_order_chaos, r=Mark-Simul…
JohnTitor Jan 26, 2021
644df2f
Rollup merge of #81195 - estebank:suggest-bound-on-trait-with-params,…
JohnTitor Jan 26, 2021
1308c14
Rollup merge of #81299 - GuillaumeGomez:fix-eslint-detected-bugs, r=N…
JohnTitor Jan 26, 2021
71f13fb
Rollup merge of #81325 - osa1:issue81293, r=estebank
JohnTitor Jan 26, 2021
3741844
Rollup merge of #81353 - jockbert:spelling_in_e0207, r=petrochenkov
JohnTitor Jan 26, 2021
acbd101
Rollup merge of #81369 - tgnottingham:codegen-to-llvm-ir-wall-time, r…
JohnTitor Jan 26, 2021
ebe28f7
Rollup merge of #81389 - ehuss:rustdoc-cmark-extensions, r=GuillaumeG…
JohnTitor Jan 26, 2021
9da3608
Rollup merge of #81399 - ehuss:update-books, r=ehuss
JohnTitor Jan 26, 2021
24a1081
Rollup merge of #81401 - ehuss:tidy-cleanup, r=Mark-Simulacrum
JohnTitor Jan 26, 2021
d68570c
Rollup merge of #81407 - osa1:issue81098, r=estebank
JohnTitor Jan 26, 2021
b2f6c2a
Rollup merge of #81412 - hyd-dev:array-assume-init-wrong-assertion, r…
JohnTitor Jan 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
Version 1.50.0 (2021-02-11)
============================

Language
-----------------------
- [You can now use `const` values for `x` in `[x; N]` array expressions.][79270]
This has been technically possible since 1.38.0, as it was unintentionally stabilized.
- [Assignments to `ManuallyDrop<T>` union fields are now considered safe.][78068]

Compiler
-----------------------
- [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142]
- [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484]
- [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
-----------------------

- [`proc_macro::Punct` now implements `PartialEq<char>`.][78636]
- [`ops::{Index, IndexMut}` are now implemented for fixed sized arrays of any length.][74989]
- [On Unix platforms, the `std::fs::File` type now has a "niche" of `-1`.][74699]
This value cannot be a valid file descriptor, and now means `Option<File>` takes
up the same amount of space as `File`.

Stabilized APIs
---------------

- [`bool::then`]
- [`btree_map::Entry::or_insert_with_key`]
- [`f32::clamp`]
- [`f64::clamp`]
- [`hash_map::Entry::or_insert_with_key`]
- [`Ord::clamp`]
- [`RefCell::take`]
- [`slice::fill`]
- [`UnsafeCell::get_mut`]

The following previously stable methods are now `const`.

- [`IpAddr::is_ipv4`]
- [`IpAddr::is_ipv6`]
- [`Layout::size`]
- [`Layout::align`]
- [`Layout::from_size_align`]
- `pow` for all integer types.
- `checked_pow` for all integer types.
- `saturating_pow` for all integer types.
- `wrapping_pow` for all integer types.
- `next_power_of_two` for all unsigned integer types.
- `checked_power_of_two` for all unsigned integer types.

Cargo
-----------------------

- [Added the `[build.rustc-workspace-wrapper]` option.][cargo/8976]
This option sets a wrapper to execute instead of `rustc`, for workspace members only.
- [`cargo:rerun-if-changed` will now, if provided a directory, scan the entire
contents of that directory for changes.][cargo/8973]
- [Added the `--workspace` flag to the `cargo update` command.][cargo/8725]

Misc
----

- [The search results tab and the help button are focusable with keyboard in rustdoc.][79896]
- [Running tests will now print the total time taken to execute.][75752]

Compatibility Notes
-------------------

- [The `compare_and_swap` method on atomics has been deprecated.][79261] It's
recommended to use the `compare_exchange` and `compare_exchange_weak` methods instead.
- [Changes in how `TokenStream`s are checked have fixed some cases where you could write
unhygenic `macro_rules!` macros.][79472]
- [`#![test]` as an inner attribute is now considered unstable like other inner macro
attributes, and reports an error by default through the `soft_unstable` lint.][79003]
- [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864]
- [Dropped support for all cloudabi targets.][78439]
- [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's
recommended to use the `#[panic_handler]` attribute to provide your own implementation.
- [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296]

[74989]: https://github.com/rust-lang/rust/pull/74989
[79261]: https://github.com/rust-lang/rust/pull/79261
[79896]: https://github.com/rust-lang/rust/pull/79896
[79484]: https://github.com/rust-lang/rust/pull/79484
[79472]: https://github.com/rust-lang/rust/pull/79472
[79270]: https://github.com/rust-lang/rust/pull/79270
[79003]: https://github.com/rust-lang/rust/pull/79003
[78864]: https://github.com/rust-lang/rust/pull/78864
[78636]: https://github.com/rust-lang/rust/pull/78636
[78439]: https://github.com/rust-lang/rust/pull/78439
[78343]: https://github.com/rust-lang/rust/pull/78343
[78296]: https://github.com/rust-lang/rust/pull/78296
[78068]: https://github.com/rust-lang/rust/pull/78068
[75752]: https://github.com/rust-lang/rust/pull/75752
[74699]: https://github.com/rust-lang/rust/pull/74699
[78142]: https://github.com/rust-lang/rust/pull/78142
[77484]: https://github.com/rust-lang/rust/pull/77484
[cargo/8976]: https://github.com/rust-lang/cargo/pull/8976
[cargo/8973]: https://github.com/rust-lang/cargo/pull/8973
[cargo/8725]: https://github.com/rust-lang/cargo/pull/8725
[`IpAddr::is_ipv4`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv4
[`IpAddr::is_ipv6`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv6
[`Layout::align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.align
[`Layout::from_size_align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.from_size_align
[`Layout::size`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.size
[`Ord::clamp`]: https://doc.rust-lang.org/stable/std/cmp/trait.Ord.html#method.clamp
[`RefCell::take`]: https://doc.rust-lang.org/stable/std/cell/struct.RefCell.html#method.take
[`UnsafeCell::get_mut`]: https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.get_mut
[`bool::then`]: https://doc.rust-lang.org/stable/std/primitive.bool.html#method.then
[`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
[`f32::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.clamp
[`f64::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f64.html#method.clamp
[`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
[`slice::fill`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.fill


Version 1.49.0 (2020-12-31)
============================

Expand Down
31 changes: 14 additions & 17 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{CachedModuleCodegen, CrateInfo, MemFlags, ModuleCodegen, ModuleKind}
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::profiling::print_time_passes_entry;
use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator};
use rustc_data_structures::sync::{par_iter, ParallelIterator};
use rustc_hir as hir;
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
use rustc_hir::lang_items::LangItem;
Expand Down Expand Up @@ -554,8 +554,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
codegen_units
};

let total_codegen_time = Lock::new(Duration::new(0, 0));

// The non-parallel compiler can only translate codegen units to LLVM IR
// on a single thread, leading to a staircase effect where the N LLVM
// threads have to wait on the single codegen threads to generate work
Expand All @@ -578,23 +576,25 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
.collect();

// Compile the found CGUs in parallel.
par_iter(cgus)
let start_time = Instant::now();

let pre_compiled_cgus = par_iter(cgus)
.map(|(i, _)| {
let start_time = Instant::now();
let module = backend.compile_codegen_unit(tcx, codegen_units[i].name());
let mut time = total_codegen_time.lock();
*time += start_time.elapsed();
(i, module)
})
.collect()
.collect();

(pre_compiled_cgus, start_time.elapsed())
})
} else {
FxHashMap::default()
(FxHashMap::default(), Duration::new(0, 0))
}
};

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

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

let cgu_reuse = cgu_reuse[i];
Expand All @@ -621,8 +623,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
} else {
let start_time = Instant::now();
let module = backend.compile_codegen_unit(tcx, cgu.name());
let mut time = total_codegen_time.lock();
*time += start_time.elapsed();
total_codegen_time += start_time.elapsed();
module
};
submit_codegened_module_to_llvm(
Expand Down Expand Up @@ -663,11 +664,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(

// Since the main thread is sometimes blocked during codegen, we keep track
// -Ztime-passes output manually.
print_time_passes_entry(
tcx.sess.time_passes(),
"codegen_to_LLVM_IR",
total_codegen_time.into_inner(),
);
print_time_passes_entry(tcx.sess.time_passes(), "codegen_to_LLVM_IR", total_codegen_time);

ongoing_codegen.check_for_errors(tcx.sess);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0207.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<T: Default> Foo {
}
```

Any type parameter parameter of an `impl` must meet at least one of
Any type parameter of an `impl` must meet at least one of
the following criteria:

- it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>`
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ impl<'hir> Map<'hir> {
)
}

/// Checks if the node is left-hand side of an assignment.
pub fn is_lhs(&self, id: HirId) -> bool {
match self.find(self.get_parent_node(id)) {
Some(Node::Expr(expr)) => match expr.kind {
ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id,
_ => false,
},
_ => false,
}
}

/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
/// Used exclusively for diagnostics, to avoid suggestion function calls.
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_mir/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
Ok(true)
}
ty::Float(_) | ty::Int(_) | ty::Uint(_) => {
let value = self.ecx.read_scalar(value)?;
let value = try_validation!(
self.ecx.read_scalar(value),
self.path,
err_unsup!(ReadPointerAsBytes) => { "read of part of a pointer" },
);
// NOTE: Keep this in sync with the array optimization for int/float
// types below!
if self.ctfe_mode.is_some() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,32 @@ fn suggest_restriction(
);
} else {
// Trivial case: `T` needs an extra bound: `T: Bound`.
let (sp, suggestion) = match super_traits {
None => predicate_constraint(
let (sp, suggestion) = match (
generics
.params
.iter()
.filter(
|p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}),
)
.next(),
super_traits,
) {
(_, None) => predicate_constraint(
generics,
trait_ref.without_const().to_predicate(tcx).to_string(),
),
Some((ident, bounds)) => match bounds {
[.., bound] => (
bound.span().shrink_to_hi(),
format!(" + {}", trait_ref.print_only_trait_path().to_string()),
),
[] => (
ident.span.shrink_to_hi(),
format!(": {}", trait_ref.print_only_trait_path().to_string()),
),
},
(None, Some((ident, []))) => (
ident.span.shrink_to_hi(),
format!(": {}", trait_ref.print_only_trait_path().to_string()),
),
(_, Some((_, [.., bounds]))) => (
bounds.span().shrink_to_hi(),
format!(" + {}", trait_ref.print_only_trait_path().to_string()),
),
(Some(_), Some((_, []))) => (
generics.span.shrink_to_hi(),
format!(": {}", trait_ref.print_only_trait_path().to_string()),
),
};

err.span_suggestion_verbose(
Expand Down Expand Up @@ -888,8 +899,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// no return, suggest removal of semicolon on last statement.
// Once that is added, close #54771.
if let Some(ref stmt) = blk.stmts.last() {
let sp = self.tcx.sess.source_map().end_point(stmt.span);
err.span_label(sp, "consider removing this semicolon");
if let hir::StmtKind::Semi(_) = stmt.kind {
let sp = self.tcx.sess.source_map().end_point(stmt.span);
err.span_label(sp, "consider removing this semicolon");
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_typeck/src/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|err: &mut DiagnosticBuilder<'_>,
found_to_exp_is_fallible: bool,
exp_to_found_is_fallible: bool| {
let exp_is_lhs =
expected_ty_expr.map(|e| self.tcx.hir().is_lhs(e.hir_id)).unwrap_or(false);

if exp_is_lhs {
return;
}

let always_fallible = found_to_exp_is_fallible
&& (exp_to_found_is_fallible || expected_ty_expr.is_none());
let msg = if literal_is_ty_suffixed(expr) {
Expand Down
Loading