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 7 pull requests #69543

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
81e4027
Update RELEASES.md for 1.42.0
XAMPPRocky Feb 9, 2020
26fdcbb
Update RELEASES.md
XAMPPRocky Feb 9, 2020
7ab01b2
Update RELEASES.md
XAMPPRocky Feb 10, 2020
32daa2a
Update RELEASES.md
XAMPPRocky Feb 10, 2020
b030280
Blacklist powerpc-unknown-linux-gnu as having non-ignored GNU C ZSTs.
anyska Feb 18, 2020
9fa8d87
Add more context to E0599 errors
estebank Feb 18, 2020
24bfa16
Reduce vebosity of E0599
estebank Feb 18, 2020
70255ef
On single local candidate, use span label
estebank Feb 18, 2020
2e8399d
Deduplicate information in E0599
estebank Feb 18, 2020
1b4c5b5
Track all predicates in errors, not just trait obligations
estebank Feb 19, 2020
9a7345b
Show information of chain of bound obligations
estebank Feb 19, 2020
615542a
Point at closure definitions
estebank Feb 19, 2020
9245415
Mention the full path of the implementing trait
estebank Feb 19, 2020
cfbb746
Tweak wording
estebank Feb 19, 2020
7818a1d
Suggest constraining type parameters
estebank Feb 19, 2020
3a58953
Account for arbitrary self types in E0599
estebank Feb 19, 2020
529b891
Review comments: split requirement text to multiple lines for readabi…
estebank Feb 21, 2020
5da3939
miri/machine: add canonical_alloc_id hook to replace find_foreign_static
RalfJung Feb 23, 2020
e7a344f
Update RELEASES.md
XAMPPRocky Feb 23, 2020
01d9329
canonicalize alloc ID before calling tag_static_base_pointer
RalfJung Feb 23, 2020
9b62d60
fmt
RalfJung Feb 23, 2020
162d727
Also blacklist powerpc-unknown-linux-musl.
anyska Feb 24, 2020
a66599f
keep predicate order and tweak output
estebank Feb 25, 2020
c02de78
Reduce verbosity when suggesting restricting type params
estebank Feb 25, 2020
0173490
Reword message
estebank Feb 25, 2020
c02e56a
Do not suggest implementing traits if present in predicates
estebank Feb 25, 2020
526280a
Merge branch 'master' into relnotes-1.42.0
XAMPPRocky Feb 26, 2020
e6c8596
Revert "Backport only: avoid ICE on bad placeholder type"
estebank Feb 27, 2020
a7b727d
Account for bounds when denying `_` in type parameters
estebank Feb 13, 2020
c6cfcf9
Account for associated items when denying `_`
estebank Feb 17, 2020
4e0bea3
Stabilize `boxed_slice_try_from`
JohnTitor Feb 28, 2020
85b585d
late resolve, visit_fn: bail early if there's no body.
Centril Feb 28, 2020
35d64ee
Rollup merge of #68989 - XAMPPRocky:relnotes-1.42.0, r=Mark-Simulacrum
Dylan-DPC Feb 28, 2020
0c3a8cd
Rollup merge of #69148 - estebank:cold-as-ice, r=oli-obk
Dylan-DPC Feb 28, 2020
88f66f1
Rollup merge of #69255 - estebank:e0599-details, r=varkor
Dylan-DPC Feb 28, 2020
e5da563
Rollup merge of #69263 - anyska:blacklist-powerpc-zst, r=nagisa
Dylan-DPC Feb 28, 2020
04f5aae
Rollup merge of #69408 - RalfJung:canonical-alloc-id, r=oli-obk
Dylan-DPC Feb 28, 2020
bad53f3
Rollup merge of #69538 - JohnTitor:boxed-slice-try-from, r=Centril
Dylan-DPC Feb 28, 2020
a1b918a
Rollup merge of #69539 - Centril:fix-69401, r=petrochenkov
Dylan-DPC Feb 28, 2020
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
98 changes: 98 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
Version 1.42.0 (2020-03-12)
==========================

Language
--------
- [You can now use the slice pattern syntax with subslices.][67712] e.g.
```rust
fn foo(words: &[&str]) {
match words {
["Hello", "World", "!", ..] => println!("Hello World!"),
["Foo", "Bar", ..] => println!("Baz"),
rest => println!("{:?}", rest),
}
}
```
- [You can now use `#[repr(transparent)]` on univariant `enum`s.][68122] Meaning
that you can create an enum that has the exact layout and ABI of the type
it contains.
- [There are some *syntax-only* changes:][67131]
- `default` is syntactically allowed before items in `trait` definitions.
- Items in `impl`s (i.e. `const`s, `type`s, and `fn`s) may syntactically
leave out their bodies in favor of `;`.
- Bounds on associated types in `impl`s are now syntactically allowed
(e.g. `type Foo: Ord;`).
- `...` (the C-variadic type) may occur syntactically directly as the type of
any function parameter.

These are still rejected *semantically*, so you will likely receive an error
but these changes can be seen and parsed by procedural macros and
conditional compilation.

Compiler
--------
- [Added tier 2\* support for `armv7a-none-eabi`.][68253]
- [Added tier 2 support for `riscv64gc-unknown-linux-gnu`.][68339]
- [`Option::{expect,unwrap}` and
`Result::{expect, expect_err, unwrap, unwrap_err}` now produce panic messages
pointing to the location where they were called, rather than
`core`'s internals. ][67887]

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

Libraries
---------
- [`iter::Empty<T>` now implements `Send` and `Sync` for any `T`.][68348]
- [`Pin::{map_unchecked, map_unchecked_mut}` no longer require the return type
to implement `Sized`.][67935]
- [`io::Cursor` now derives `PartialEq` and `Eq`.][67233]
- [`Layout::new` is now `const`.][66254]
- [Added Standard Library support for `riscv64gc-unknown-linux-gnu`.][66899]


Stabilized APIs
---------------
- [`CondVar::wait_while`]
- [`CondVar::wait_timeout_while`]
- [`DebugMap::key`]
- [`DebugMap::value`]
- [`ManuallyDrop::take`]
- [`matches!`]
- [`ptr::slice_from_raw_parts_mut`]
- [`ptr::slice_from_raw_parts`]

Cargo
-----
- [You no longer need to include `extern crate proc_macro;` to be able to
`use proc_macro;` in the `2018` edition.][cargo/7700]

Compatibility Notes
-------------------
- [`Error::description` has been deprecated, and its use will now produce a
warning.][66919] It's recommended to use `Display`/`to_string` instead.

[68253]: https://github.com/rust-lang/rust/pull/68253/
[68348]: https://github.com/rust-lang/rust/pull/68348/
[67935]: https://github.com/rust-lang/rust/pull/67935/
[68339]: https://github.com/rust-lang/rust/pull/68339/
[68122]: https://github.com/rust-lang/rust/pull/68122/
[67712]: https://github.com/rust-lang/rust/pull/67712/
[67887]: https://github.com/rust-lang/rust/pull/67887/
[67131]: https://github.com/rust-lang/rust/pull/67131/
[67233]: https://github.com/rust-lang/rust/pull/67233/
[66899]: https://github.com/rust-lang/rust/pull/66899/
[66919]: https://github.com/rust-lang/rust/pull/66919/
[66254]: https://github.com/rust-lang/rust/pull/66254/
[cargo/7700]: https://github.com/rust-lang/cargo/pull/7700
[`DebugMap::key`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.key
[`DebugMap::value`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.value
[`ManuallyDrop::take`]: https://doc.rust-lang.org/stable/std/mem/struct.ManuallyDrop.html#method.take
[`matches!`]: https://doc.rust-lang.org/stable/std/macro.matches.html
[`ptr::slice_from_raw_parts_mut`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts_mut.html
[`ptr::slice_from_raw_parts`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts.html
[`CondVar::wait_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_while
[`CondVar::wait_timeout_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_timeout_while


Version 1.41.1 (2020-02-27)
===========================

Expand All @@ -8,6 +105,7 @@ Version 1.41.1 (2020-02-27)
[69225]: https://github.com/rust-lang/rust/issues/69225
[69145]: https://github.com/rust-lang/rust/pull/69145


Version 1.41.0 (2020-01-30)
===========================

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ impl From<Box<str>> for Box<[u8]> {
}
}

#[unstable(feature = "boxed_slice_try_from", issue = "none")]
#[stable(feature = "boxed_slice_try_from", since = "1.43.0")]
impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]>
where
[T; N]: LengthAtMost32,
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ impl<T> From<Vec<T>> for Rc<[T]> {
}
}

#[unstable(feature = "boxed_slice_try_from", issue = "none")]
#[stable(feature = "boxed_slice_try_from", since = "1.43.0")]
impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]>
where
[T; N]: LengthAtMost32,
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ impl<T> From<Vec<T>> for Arc<[T]> {
}
}

#[unstable(feature = "boxed_slice_try_from", issue = "none")]
#[stable(feature = "boxed_slice_try_from", since = "1.43.0")]
impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]>
where
[T; N]: LengthAtMost32,
Expand Down
14 changes: 14 additions & 0 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,20 @@ impl<'tcx, N> Vtable<'tcx, N> {
}
}

pub fn borrow_nested_obligations(&self) -> &[N] {
match &self {
VtableImpl(i) => &i.nested[..],
VtableParam(n) => &n[..],
VtableBuiltin(i) => &i.nested[..],
VtableAutoImpl(d) => &d.nested[..],
VtableClosure(c) => &c.nested[..],
VtableGenerator(c) => &c.nested[..],
VtableObject(d) => &d.nested[..],
VtableFnPointer(d) => &d.nested[..],
VtableTraitAlias(d) => &d.nested[..],
}
}

pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M>
where
F: FnMut(N) -> M,
Expand Down
22 changes: 15 additions & 7 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2541,12 +2541,15 @@ where
};

let target = &cx.tcx().sess.target.target;
let target_env_gnu_like = matches!(&target.target_env[..], "gnu" | "musl");
let win_x64_gnu =
target.target_os == "windows" && target.arch == "x86_64" && target.target_env == "gnu";
let linux_s390x =
target.target_os == "linux" && target.arch == "s390x" && target.target_env == "gnu";
let linux_sparc64 =
target.target_os == "linux" && target.arch == "sparc64" && target.target_env == "gnu";
let linux_s390x_gnu_like =
target.target_os == "linux" && target.arch == "s390x" && target_env_gnu_like;
let linux_sparc64_gnu_like =
target.target_os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
let linux_powerpc_gnu_like =
target.target_os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
let rust_abi = match sig.abi {
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true,
_ => false,
Expand Down Expand Up @@ -2617,9 +2620,14 @@ where
if arg.layout.is_zst() {
// For some forsaken reason, x86_64-pc-windows-gnu
// doesn't ignore zero-sized struct arguments.
// The same is true for s390x-unknown-linux-gnu
// and sparc64-unknown-linux-gnu.
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
// The same is true for {s390x,sparc64,powerpc}-unknown-linux-{gnu,musl}.
if is_return
|| rust_abi
|| (!win_x64_gnu
&& !linux_s390x_gnu_like
&& !linux_sparc64_gnu_like
&& !linux_powerpc_gnu_like)
{
arg.mode = PassMode::Ignore;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_infer/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.tcx.sess,
span,
E0491,
"in type `{}`, reference has a longer lifetime \
than the data it references",
"in type `{}`, reference has a longer lifetime than the data it references",
self.ty_to_string(ty)
);
note_and_explain_region(
Expand Down
10 changes: 1 addition & 9 deletions src/librustc_mir/const_eval/machine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use rustc::mir;
use rustc::ty::layout::HasTyCtxt;
use rustc::ty::{self, Ty, TyCtxt};
use rustc_hir::def_id::DefId;
use rustc::ty::{self, Ty};
use std::borrow::{Borrow, Cow};
use std::collections::hash_map::Entry;
use std::hash::Hash;
Expand Down Expand Up @@ -320,13 +319,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
Err(ConstEvalErrKind::NeedsRfc("pointer arithmetic or comparison".to_string()).into())
}

fn find_foreign_static(
_tcx: TyCtxt<'tcx>,
_def_id: DefId,
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> {
throw_unsup!(ReadForeignStatic)
}

#[inline(always)]
fn init_allocation_extra<'b>(
_memory_extra: &MemoryExtra,
Expand Down
43 changes: 24 additions & 19 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::borrow::{Borrow, Cow};
use std::hash::Hash;

use rustc::mir;
use rustc::ty::{self, Ty, TyCtxt};
use rustc_hir::def_id::DefId;
use rustc::ty::{self, Ty};
use rustc_span::Span;

use super::{
Expand Down Expand Up @@ -123,10 +122,6 @@ pub trait Machine<'mir, 'tcx>: Sized {
/// Whether to enforce the validity invariant
fn enforce_validity(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;

/// Called before a basic block terminator is executed.
/// You can use this to detect endlessly running programs.
fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx>;

/// Entry point to all function calls.
///
/// Returns either the mir to use for the call, or `None` if execution should
Expand Down Expand Up @@ -175,18 +170,6 @@ pub trait Machine<'mir, 'tcx>: Sized {
unwind: Option<mir::BasicBlock>,
) -> InterpResult<'tcx>;

/// Called for read access to a foreign static item.
///
/// This will only be called once per static and machine; the result is cached in
/// the machine memory. (This relies on `AllocMap::get_or` being able to add the
/// owned allocation to the map even when the map is shared.)
///
/// This allocation will then be fed to `tag_allocation` to initialize the "extra" state.
fn find_foreign_static(
tcx: TyCtxt<'tcx>,
def_id: DefId,
) -> InterpResult<'tcx, Cow<'tcx, Allocation>>;

/// Called for all binary operations where the LHS has pointer type.
///
/// Returns a (value, overflowed) pair if the operation succeeded
Expand All @@ -204,6 +187,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
) -> InterpResult<'tcx>;

/// Called to read the specified `local` from the `frame`.
#[inline]
fn access_local(
_ecx: &InterpCx<'mir, 'tcx, Self>,
frame: &Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>,
Expand All @@ -212,14 +196,33 @@ pub trait Machine<'mir, 'tcx>: Sized {
frame.locals[local].access()
}

/// Called before a basic block terminator is executed.
/// You can use this to detect endlessly running programs.
#[inline]
fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
Ok(())
}

/// Called before a `Static` value is accessed.
#[inline]
fn before_access_static(
_memory_extra: &Self::MemoryExtra,
_allocation: &Allocation,
) -> InterpResult<'tcx> {
Ok(())
}

/// Called for *every* memory access to determine the real ID of the given allocation.
/// This provides a way for the machine to "redirect" certain allocations as it sees fit.
///
/// This is used by Miri to redirect extern statics to real allocations.
///
/// This function must be idempotent.
#[inline]
fn canonical_alloc_id(_mem: &Memory<'mir, 'tcx, Self>, id: AllocId) -> AllocId {
id
}

/// Called to initialize the "extra" state of an allocation and make the pointers
/// it contains (in relocations) tagged. The way we construct allocations is
/// to always first construct it without extra and then add the extra.
Expand Down Expand Up @@ -247,6 +250,8 @@ pub trait Machine<'mir, 'tcx>: Sized {
/// Return the "base" tag for the given *static* allocation: the one that is used for direct
/// accesses to this static/const/fn allocation. If `id` is not a static allocation,
/// this will return an unusable tag (i.e., accesses will be UB)!
///
/// Expects `id` to be already canonical, if needed.
fn tag_static_base_pointer(memory_extra: &Self::MemoryExtra, id: AllocId) -> Self::PointerTag;

/// Executes a retagging operation
Expand All @@ -259,7 +264,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
Ok(())
}

/// Called immediately before a new stack frame got pushed
/// Called immediately before a new stack frame got pushed.
fn stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, Self::FrameExtra>;

/// Called immediately after a stack frame gets popped
Expand Down
Loading