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 13 pull requests #82138

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5fe8490
Add match pattern diagnostics regression test
vandenheuvel Feb 8, 2021
dd9db23
Fix typos in BTreeSet::{first, last} docs
taiki-e Feb 13, 2021
a3e0795
Heat up the ICE-y error reporting
BoxyUwU Feb 13, 2021
ee9709f
Fixed minor typo in catch_unwind docs
Feb 13, 2021
1c3841e
Edit `rustc_arena::DropArena` docs
pierwill Feb 13, 2021
d1a541e
Add tests for Atomic*::fetch_{min,max}
bjorn3 Feb 14, 2021
ba72bc9
fix typo
TaKO8Ki Feb 14, 2021
c583860
Remove unnecessary `Option` in `default_doc`
jyn514 Feb 14, 2021
34f30bc
Move some tests to more reasonable directories
c410-f3r Feb 14, 2021
dee5424
Add missing env!-decl variant
lukaslueg Feb 14, 2021
1aa9651
Fix typo in link to CreateSymbolicLinkW documentation.
m-ou-se Feb 14, 2021
3d7fcff
Update library/core/src/macros/mod.rs
lukaslueg Feb 14, 2021
4613b37
Stabilize Arguments::as_str
sfackler Feb 14, 2021
63806cc
Remove redundant bool_to_option feature gate
est31 Feb 15, 2021
377a3ef
Rollup merge of #81897 - vandenheuvel:match_exhaustive_diagnostics_re…
JohnTitor Feb 15, 2021
c27dad5
Rollup merge of #81941 - c410-f3r:tests-tests-tests, r=petrochenkov
JohnTitor Feb 15, 2021
4d4a680
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
JohnTitor Feb 15, 2021
0a4f934
Rollup merge of #82060 - taiki-e:typo, r=m-ou-se
JohnTitor Feb 15, 2021
923dd8a
Rollup merge of #82063 - NULLx76:fix-minor-typo, r=jonas-schievink
JohnTitor Feb 15, 2021
6da1890
Rollup merge of #82077 - pierwill:edit-droparena, r=lcnr
JohnTitor Feb 15, 2021
21ffc87
Rollup merge of #82093 - bjorn3:more_atomic_tests, r=kennytm
JohnTitor Feb 15, 2021
ec2fc5a
Rollup merge of #82096 - TaKO8Ki:fix-typo, r=GuillaumeGomez
JohnTitor Feb 15, 2021
f0fd778
Rollup merge of #82106 - jyn514:cleanup-bootstrap, r=Mark-Simulacrum
JohnTitor Feb 15, 2021
ebaba22
Rollup merge of #82118 - lukaslueg:env_decl, r=m-ou-se
JohnTitor Feb 15, 2021
8095310
Rollup merge of #82119 - m-ou-se:typo, r=dtolnay
JohnTitor Feb 15, 2021
cb9f6b1
Rollup merge of #82120 - sfackler:arguments-as-str, r=dtolnay
JohnTitor Feb 15, 2021
abdfa39
Rollup merge of #82129 - est31:master, r=jyn514
JohnTitor Feb 15, 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
15 changes: 9 additions & 6 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,13 @@ impl Drop for DropType {
}

/// An arena which can be used to allocate any type.
///
/// # Safety
///
/// Allocating in this arena is unsafe since the type system
/// doesn't know which types it contains. In order to
/// allocate safely, you must store a PhantomData<T>
/// alongside this arena for each type T you allocate.
/// allocate safely, you must store a `PhantomData<T>`
/// alongside this arena for each type `T` you allocate.
#[derive(Default)]
pub struct DropArena {
/// A list of destructors to run when the arena drops.
Expand All @@ -589,7 +592,7 @@ impl DropArena {
ptr::write(mem, object);
let result = &mut *mem;
// Record the destructor after doing the allocation as that may panic
// and would cause `object`'s destructor to run twice if it was recorded before
// and would cause `object`'s destructor to run twice if it was recorded before.
self.destructors
.borrow_mut()
.push(DropType { drop_fn: drop_for_type::<T>, obj: result as *mut T as *mut u8 });
Expand All @@ -607,16 +610,16 @@ impl DropArena {
let start_ptr = self.arena.alloc_raw(Layout::array::<T>(len).unwrap()) as *mut T;

let mut destructors = self.destructors.borrow_mut();
// Reserve space for the destructors so we can't panic while adding them
// Reserve space for the destructors so we can't panic while adding them.
destructors.reserve(len);

// Move the content to the arena by copying it and then forgetting
// the content of the SmallVec
// the content of the SmallVec.
vec.as_ptr().copy_to_nonoverlapping(start_ptr, len);
mem::forget(vec.drain(..));

// Record the destructors after doing the allocation as that may panic
// and would cause `object`'s destructor to run twice if it was recorded before
// and would cause `object`'s destructor to run twice if it was recorded before.
for i in 0..len {
destructors
.push(DropType { drop_fn: drop_for_type::<T>, obj: start_ptr.add(i) as *mut u8 });
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(bool_to_option)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(or_patterns)]
Expand Down
13 changes: 9 additions & 4 deletions compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,17 @@ impl<'tcx> ty::TyS<'tcx> {
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(),
ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(),
ty::Array(t, n) => {
if t.is_simple_ty() {
return format!("array `{}`", self).into();
}

let n = tcx.lift(n).unwrap();
match n.try_eval_usize(tcx, ty::ParamEnv::empty()) {
_ if t.is_simple_ty() => format!("array `{}`", self).into(),
Some(n) => format!("array of {} element{}", n, pluralize!(n)).into(),
None => "array".into(),
if let ty::ConstKind::Value(v) = n.val {
if let Some(n) = v.try_to_machine_usize(tcx) {
return format!("array of {} element{}", n, pluralize!(n)).into();
}
}
"array".into()
}
ty::Slice(ty) if ty.is_simple_ty() => format!("slice `{}`", self).into(),
ty::Slice(_) => "slice".into(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
// see comment in const_eval_raw_provider for what we're doing here
// see comment in eval_to_allocation_raw_provider for what we're doing here
if key.param_env.reveal() == Reveal::All {
let mut key = key;
key.param_env = key.param_env.with_user_facing();
Expand Down
24 changes: 12 additions & 12 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,12 @@ impl<T> BTreeSet<T> {
/// #![feature(map_first_last)]
/// use std::collections::BTreeSet;
///
/// let mut map = BTreeSet::new();
/// assert_eq!(map.first(), None);
/// map.insert(1);
/// assert_eq!(map.first(), Some(&1));
/// map.insert(2);
/// assert_eq!(map.first(), Some(&1));
/// let mut set = BTreeSet::new();
/// assert_eq!(set.first(), None);
/// set.insert(1);
/// assert_eq!(set.first(), Some(&1));
/// set.insert(2);
/// assert_eq!(set.first(), Some(&1));
/// ```
#[unstable(feature = "map_first_last", issue = "62924")]
pub fn first(&self) -> Option<&T>
Expand All @@ -675,12 +675,12 @@ impl<T> BTreeSet<T> {
/// #![feature(map_first_last)]
/// use std::collections::BTreeSet;
///
/// let mut map = BTreeSet::new();
/// assert_eq!(map.last(), None);
/// map.insert(1);
/// assert_eq!(map.last(), Some(&1));
/// map.insert(2);
/// assert_eq!(map.last(), Some(&2));
/// let mut set = BTreeSet::new();
/// assert_eq!(set.last(), None);
/// set.insert(1);
/// assert_eq!(set.last(), Some(&1));
/// set.insert(2);
/// assert_eq!(set.last(), Some(&2));
/// ```
#[unstable(feature = "map_first_last", issue = "62924")]
pub fn last(&self) -> Option<&T>
Expand Down
6 changes: 1 addition & 5 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ impl<'a> Arguments<'a> {
/// # Examples
///
/// ```rust
/// #![feature(fmt_as_str)]
///
/// use std::fmt::Arguments;
///
/// fn write_str(_: &str) { /* ... */ }
Expand All @@ -417,13 +415,11 @@ impl<'a> Arguments<'a> {
/// ```
///
/// ```rust
/// #![feature(fmt_as_str)]
///
/// assert_eq!(format_args!("hello").as_str(), Some("hello"));
/// assert_eq!(format_args!("").as_str(), Some(""));
/// assert_eq!(format_args!("{}", 1).as_str(), None);
/// ```
#[unstable(feature = "fmt_as_str", issue = "74442")]
#[stable(feature = "fmt_as_str", since = "1.52.0")]
#[inline]
pub fn as_str(&self) -> Option<&'static str> {
match (self.pieces, self.args) {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ pub(crate) mod builtin {
#[macro_export]
macro_rules! env {
($name:expr $(,)?) => {{ /* compiler built-in */ }};
($name:expr, $error_msg:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Optionally inspects an environment variable at compile time.
Expand Down
36 changes: 36 additions & 0 deletions library/core/tests/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ fn uint_xor() {
assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
}

#[test]
fn uint_min() {
let x = AtomicUsize::new(0xf731);
assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731);
assert_eq!(x.load(SeqCst), 0x137f);
assert_eq!(x.fetch_min(0xf731, SeqCst), 0x137f);
assert_eq!(x.load(SeqCst), 0x137f);
}

#[test]
fn uint_max() {
let x = AtomicUsize::new(0x137f);
assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f);
assert_eq!(x.load(SeqCst), 0xf731);
assert_eq!(x.fetch_max(0x137f, SeqCst), 0xf731);
assert_eq!(x.load(SeqCst), 0xf731);
}

#[test]
fn int_and() {
let x = AtomicIsize::new(0xf731);
Expand Down Expand Up @@ -87,6 +105,24 @@ fn int_xor() {
assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
}

#[test]
fn int_min() {
let x = AtomicIsize::new(0xf731);
assert_eq!(x.fetch_min(0x137f, SeqCst), 0xf731);
assert_eq!(x.load(SeqCst), 0x137f);
assert_eq!(x.fetch_min(0xf731, SeqCst), 0x137f);
assert_eq!(x.load(SeqCst), 0x137f);
}

#[test]
fn int_max() {
let x = AtomicIsize::new(0x137f);
assert_eq!(x.fetch_max(0xf731, SeqCst), 0x137f);
assert_eq!(x.load(SeqCst), 0xf731);
assert_eq!(x.fetch_max(0x137f, SeqCst), 0xf731);
assert_eq!(x.load(SeqCst), 0xf731);
}

static S_FALSE: AtomicBool = AtomicBool::new(false);
static S_TRUE: AtomicBool = AtomicBool::new(true);
static S_INT: AtomicIsize = AtomicIsize::new(0);
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@
#![feature(exhaustive_patterns)]
#![feature(extend_one)]
#![feature(external_doc)]
#![feature(fmt_as_str)]
#![feature(fn_traits)]
#![feature(format_args_nl)]
#![feature(gen_future)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl<S: Stream> Stream for AssertUnwindSafe<S> {
/// aborting the process as well. This function *only* catches unwinding panics,
/// not those that abort the process.
///
/// Also note that unwinding into Rust code with a foreign exception (e.g. a
/// Also note that unwinding into Rust code with a foreign exception (e.g.
/// an exception thrown from C++ code) is undefined behavior.
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ extern "system" {
pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;

// >= Vista / Server 2008
// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinka
// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
pub fn CreateSymbolicLinkW(
lpSymlinkFileName: LPCWSTR,
lpTargetFileName: LPCWSTR,
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ impl<'a> Builder<'a> {
self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths);
}

pub fn default_doc(&self, paths: Option<&[PathBuf]>) {
let paths = paths.unwrap_or(&[]);
pub fn default_doc(&self, paths: &[PathBuf]) {
self.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), paths);
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Step for Docs {
if !builder.config.docs {
return None;
}
builder.default_doc(None);
builder.default_doc(&[]);

let dest = "share/doc/rust/html";

Expand Down Expand Up @@ -103,7 +103,7 @@ impl Step for RustcDocs {
if !builder.config.compiler_docs {
return None;
}
builder.default_doc(None);
builder.default_doc(&[]);

let mut tarball = Tarball::new(builder, "rustc-docs", &host.triple);
tarball.set_product_name("Rustc Documentation");
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Step for Linkcheck {

builder.info(&format!("Linkcheck ({})", host));

builder.default_doc(None);
builder.default_doc(&[]);

let _time = util::timeit(&builder);
try_run(
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ impl Clean<Item> for ty::AssocItem {

AssocTypeItem(bounds, ty.clean(cx))
} else {
// FIXME: when could this happen? ASsociated items in inherent impls?
// FIXME: when could this happen? Associated items in inherent impls?
let type_ = cx.tcx.type_of(self.def_id).clean(cx);
TypedefItem(
Typedef {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]

// This test is a minimized reproduction for #79518 where
// during error handling for the type mismatch we would try
// to evaluate std::mem::size_of::<Self::Assoc> causing an ICE

trait Foo {
type Assoc: PartialEq;
const AssocInstance: Self::Assoc;

fn foo()
where
[(); std::mem::size_of::<Self::Assoc>()]: ,
{
Self::AssocInstance == [(); std::mem::size_of::<Self::Assoc>()];
//~^ Error: mismatched types
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-79518-default_trait_method_normalization.rs:16:32
|
LL | Self::AssocInstance == [(); std::mem::size_of::<Self::Assoc>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); _]`
|
= note: expected associated type `<Self as Foo>::Assoc`
found array `[(); _]`
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); _]` or calling a method that returns `<Self as Foo>::Assoc`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/test/ui/emit-artifact-notifications.stderr

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/test/ui/pattern/usefulness/issue-72377.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#[derive(PartialEq, Eq)]
enum X { A, B, C, }

fn main() {
let x = X::A;
let y = Some(X::A);

match (x, y) {
//~^ ERROR non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2
//~| more not covered
(_, None) => false,
(v, Some(w)) if v == w => true,
(X::B, Some(X::C)) => false,
(X::B, Some(X::A)) => false,
(X::A, Some(X::C)) | (X::C, Some(X::A)) => false,
};
}
12 changes: 12 additions & 0 deletions src/test/ui/pattern/usefulness/issue-72377.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0004]: non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered
--> $DIR/issue-72377.rs:8:11
|
LL | match (x, y) {
| ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `(X, Option<X>)`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0004`.
14 changes: 0 additions & 14 deletions src/test/ui/range_inclusive_gate.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/test/ui/rmeta/emit-artifact-notifications.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::path::Path;

const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 1459;
const ISSUES_ENTRY_LIMIT: usize = 2615;
const ROOT_ENTRY_LIMIT: usize = 1418;
const ISSUES_ENTRY_LIMIT: usize = 2576;

fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))
Expand Down