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 #66794

Merged
merged 46 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b12e142
alloc: Add new_zeroed() versions like new_uninit().
emilio Nov 5, 2019
75dac38
Add riscv64gc-unknown-linux-gnu target
msizanoen1 Nov 23, 2019
a8430a4
Miri: print leak report even without tracing
RalfJung Nov 23, 2019
9233a54
only print LEAK REPORT if there is a leak
RalfJung Nov 23, 2019
01d01ce
Add hardware floating point features to aarch64-pc-windows-msvc
mattico Nov 24, 2019
28c6ef8
introduce a target to build the kernel HermitCore
stlankes Nov 24, 2019
fdcf854
tidy: Accommodate rustfmt's preferred layout of stability attributes
dtolnay Nov 24, 2019
66dce11
Store ptr_width as u32 on Config
Mark-Simulacrum Nov 24, 2019
1475944
use nicer code style to pass tidy check
stlankes Nov 24, 2019
55ce5c0
disable redzone
stlankes Nov 24, 2019
e5816a7
Fix some rustdoc error capitalization
estebank Nov 25, 2019
bf5c64a
Clean up E0062 long explanation
GuillaumeGomez Nov 25, 2019
7e813c4
Clean up E0063 long explanation
GuillaumeGomez Nov 25, 2019
98e2917
Clean up E0067 long explanation
GuillaumeGomez Nov 25, 2019
ef35980
Clean up E0069 long explanation
GuillaumeGomez Nov 25, 2019
1bd28b1
Clean up E0070 long explanation
GuillaumeGomez Nov 25, 2019
00fe97a
Fix capitalization when mentioning different crate versions in E0308
estebank Nov 25, 2019
9a59541
Tweak multiple allocators error
estebank Nov 25, 2019
9c97d73
Tweak move error due to non-Copy
estebank Nov 25, 2019
1eeed17
Tweak duplicate fmt arg error
estebank Nov 25, 2019
3893d16
Tweak duplicate matcher binding error
estebank Nov 25, 2019
5ef4716
Tweak bad `continue` error
estebank Nov 25, 2019
85fb054
Tweak removed feature error
estebank Nov 25, 2019
5ea922a
Various cleanups
estebank Nov 25, 2019
395408e
Update documentation-tests.md
Parth Nov 26, 2019
37f440f
Add wildcard test for const_if_match
jyn514 Nov 26, 2019
55d7258
follow the same function order in the trait
Nov 26, 2019
f1f83ef
Test multiple variants
jyn514 Nov 26, 2019
2626cfb
Allow `Unreachable` terminators behind `const_if_match`
ecstatic-morse Nov 26, 2019
582affd
Add regression test for #66756
ecstatic-morse Nov 26, 2019
2299586
Move ErrorReported to rustc_errors
Mark-Simulacrum Nov 24, 2019
a626bf6
Remove test for #66758
ecstatic-morse Nov 26, 2019
941d915
Rollup merge of #66128 - emilio:new-zeroed, r=SimonSapin
tmandry Nov 26, 2019
a49f23e
Rollup merge of #66661 - msizanoen1:riscv-gnu, r=alexcrichton
tmandry Nov 26, 2019
a0e756b
Rollup merge of #66663 - RalfJung:miri-leaks, r=oli-obk
tmandry Nov 26, 2019
9e2802b
Rollup merge of #66711 - mattico:aarch-msvc-fp, r=nagisa
tmandry Nov 26, 2019
7ef7005
Rollup merge of #66713 - hermitcore:hermit, r=alexcrichton
tmandry Nov 26, 2019
ac7e604
Rollup merge of #66717 - dtolnay:tidy, r=Mark-Simulacrum
tmandry Nov 26, 2019
f178d35
Rollup merge of #66719 - Mark-Simulacrum:int-normalization, r=Centril
tmandry Nov 26, 2019
bf25f8e
Rollup merge of #66720 - Mark-Simulacrum:error-reported, r=Centril
tmandry Nov 26, 2019
0b3d4a1
Rollup merge of #66737 - GuillaumeGomez:err-codes-cleanup, r=Dylan-DPC
tmandry Nov 26, 2019
bb6236c
Rollup merge of #66754 - estebank:rustdoc-capitalization, r=Dylan-DPC
tmandry Nov 26, 2019
339d717
Rollup merge of #66763 - Parth:patch-2, r=steveklabnik
tmandry Nov 26, 2019
84a2d66
Rollup merge of #66779 - guanqun:reorder-funcs, r=Dylan-DPC
tmandry Nov 26, 2019
7f166e4
Rollup merge of #66786 - jyn514:const-if-match-tests, r=Centril
tmandry Nov 26, 2019
8547ea3
Rollup merge of #66788 - ecstatic-morse:const-fn-unreachable, r=Centril
tmandry Nov 26, 2019
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
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/documentation-tests.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Documentation tests

`rustdoc` supports executing your documentation examples as tests. This makes sure
that your tests are up to date and working.
that examples within your documentation are up to date and working.

The basic idea is this:

Expand Down
27 changes: 27 additions & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ impl<T> Box<T> {
Box(ptr.cast().into())
}

/// Constructs a new `Box` with uninitialized contents, with the memory
/// being filled with `0` bytes.
///
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
/// of this method.
///
/// # Examples
///
/// ```
/// #![feature(new_uninit)]
///
/// let zero = Box::<u32>::new_zeroed();
/// let zero = unsafe { zero.assume_init() };
///
/// assert_eq!(*zero, 0)
/// ```
///
/// [zeroed]: ../../std/mem/union.MaybeUninit.html#method.zeroed
#[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
unsafe {
let mut uninit = Self::new_uninit();
ptr::write_bytes::<T>(uninit.as_mut_ptr(), 0, 1);
uninit
}
}

/// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
/// `x` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
Expand Down
29 changes: 29 additions & 0 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,35 @@ impl<T> Rc<T> {
}
}

/// Constructs a new `Rc` with uninitialized contents, with the memory
/// being filled with `0` bytes.
///
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and
/// incorrect usage of this method.
///
/// # Examples
///
/// ```
/// #![feature(new_uninit)]
///
/// use std::rc::Rc;
///
/// let zero = Rc::<u32>::new_zeroed();
/// let zero = unsafe { zero.assume_init() };
///
/// assert_eq!(*zero, 0)
/// ```
///
/// [zeroed]: ../../std/mem/union.MaybeUninit.html#method.zeroed
#[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> {
unsafe {
let mut uninit = Self::new_uninit();
ptr::write_bytes::<T>(Rc::get_mut_unchecked(&mut uninit).as_mut_ptr(), 0, 1);
uninit
}
}

/// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
/// `value` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
Expand Down
29 changes: 29 additions & 0 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,35 @@ impl<T> Arc<T> {
}
}

/// Constructs a new `Arc` with uninitialized contents, with the memory
/// being filled with `0` bytes.
///
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
/// of this method.
///
/// # Examples
///
/// ```
/// #![feature(new_uninit)]
///
/// use std::sync::Arc;
///
/// let zero = Arc::<u32>::new_zeroed();
/// let zero = unsafe { zero.assume_init() };
///
/// assert_eq!(*zero, 0)
/// ```
///
/// [zeroed]: ../../std/mem/union.MaybeUninit.html#method.zeroed
#[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> {
unsafe {
let mut uninit = Self::new_uninit();
ptr::write_bytes::<T>(Arc::get_mut_unchecked(&mut uninit).as_mut_ptr(), 0, 1);
uninit
}
}

/// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
/// `data` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ impl<T: PartialOrd> PartialOrd for Reverse<T> {
#[inline]
fn le(&self, other: &Self) -> bool { other.0 <= self.0 }
#[inline]
fn ge(&self, other: &Self) -> bool { other.0 >= self.0 }
#[inline]
fn gt(&self, other: &Self) -> bool { other.0 > self.0 }
#[inline]
fn ge(&self, other: &Self) -> bool { other.0 >= self.0 }
}

#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
Expand Down Expand Up @@ -1176,9 +1176,9 @@ mod impls {
#[inline]
fn le(&self, other: & &B) -> bool { PartialOrd::le(*self, *other) }
#[inline]
fn ge(&self, other: & &B) -> bool { PartialOrd::ge(*self, *other) }
#[inline]
fn gt(&self, other: & &B) -> bool { PartialOrd::gt(*self, *other) }
#[inline]
fn ge(&self, other: & &B) -> bool { PartialOrd::ge(*self, *other) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: ?Sized> Ord for &A where A: Ord {
Expand Down Expand Up @@ -1208,9 +1208,9 @@ mod impls {
#[inline]
fn le(&self, other: &&mut B) -> bool { PartialOrd::le(*self, *other) }
#[inline]
fn ge(&self, other: &&mut B) -> bool { PartialOrd::ge(*self, *other) }
#[inline]
fn gt(&self, other: &&mut B) -> bool { PartialOrd::gt(*self, *other) }
#[inline]
fn ge(&self, other: &&mut B) -> bool { PartialOrd::ge(*self, *other) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: ?Sized> Ord for &mut A where A: Ord {
Expand Down
15 changes: 5 additions & 10 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
&self,
err: &mut DiagnosticBuilder<'_>,
terr: &TypeError<'tcx>,
sp: Span,
) {
use hir::def_id::CrateNum;
use hir::map::DisambiguatedDefPathData;
Expand Down Expand Up @@ -577,14 +576,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
};
if same_path().unwrap_or(false) {
let crate_name = self.tcx.crate_name(did1.krate);
err.span_note(
sp,
&format!(
"Perhaps two different versions \
of crate `{}` are being used?",
crate_name
),
);
err.note(&format!(
"perhaps two different versions of crate `{}` are being used?",
crate_name
));
}
}
};
Expand Down Expand Up @@ -1434,7 +1429,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.unwrap_or_else(|| {
self.tcx.hir().body_owner_def_id(hir::BodyId { hir_id: cause.body_id })
});
self.check_and_note_conflicting_crates(diag, terr, span);
self.check_and_note_conflicting_crates(diag, terr);
self.tcx.note_and_explain_type_err(diag, terr, span, body_owner_def_id);

// It reads better to have the error origin as the final
Expand Down
16 changes: 7 additions & 9 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel
use rustc_target::spec::{Target, TargetTriple};

use syntax;
use syntax::ast::{self, IntTy, UintTy};
use syntax::ast;
use syntax::source_map::{FileName, FilePathMapping};
use syntax::edition::{Edition, EDITION_NAME_LIST, DEFAULT_EDITION};
use syntax::symbol::{sym, Symbol};
Expand All @@ -36,8 +36,7 @@ use std::path::{Path, PathBuf};

pub struct Config {
pub target: Target,
pub isize_ty: IntTy,
pub usize_ty: UintTy,
pub ptr_width: u32,
}

#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -1621,10 +1620,10 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
FatalError.raise();
});

let (isize_ty, usize_ty) = match &target.target_pointer_width[..] {
"16" => (ast::IntTy::I16, ast::UintTy::U16),
"32" => (ast::IntTy::I32, ast::UintTy::U32),
"64" => (ast::IntTy::I64, ast::UintTy::U64),
let ptr_width = match &target.target_pointer_width[..] {
"16" => 16,
"32" => 32,
"64" => 64,
w => sp.fatal(&format!(
"target specification was invalid: \
unrecognized target-pointer-width {}",
Expand All @@ -1634,8 +1633,7 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {

Config {
target,
isize_ty,
usize_ty,
ptr_width,
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::fmt::Debug;
use std::time::{Duration, Instant};

use syntax::symbol::{Symbol, sym};
use rustc_macros::HashStable;
use crate::session::Session;

#[cfg(test)]
Expand All @@ -16,10 +15,7 @@ mod tests;
// The name of the associated type for `Fn` return types.
pub const FN_OUTPUT_NAME: Symbol = sym::Output;

// Useful type to use with `Result<>` indicate that an error has already
// been reported to the user, so no need to continue checking.
#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct ErrorReported;
pub use errors::ErrorReported;

thread_local!(static TIME_DEPTH: Cell<usize> = Cell::new(0));

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
use rustc::ty::{Int, Uint};

let new_kind = match ty.kind {
Int(Isize) => Int(self.tcx.sess.target.isize_ty),
Uint(Usize) => Uint(self.tcx.sess.target.usize_ty),
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.ptr_width)),
Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.ptr_width)),
ref t @ Uint(_) | ref t @ Int(_) => t.clone(),
_ => panic!("tried to get overflow intrinsic for op applied to non-int type")
};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1926,15 +1926,15 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> {
match ty.kind {
ty::Int(t) => Some((match t {
ast::IntTy::Isize => cx.tcx.sess.target.isize_ty.bit_width().unwrap() as u64,
ast::IntTy::Isize => cx.tcx.sess.target.ptr_width as u64,
ast::IntTy::I8 => 8,
ast::IntTy::I16 => 16,
ast::IntTy::I32 => 32,
ast::IntTy::I64 => 64,
ast::IntTy::I128 => 128,
}, true)),
ty::Uint(t) => Some((match t {
ast::UintTy::Usize => cx.tcx.sess.target.usize_ty.bit_width().unwrap() as u64,
ast::UintTy::Usize => cx.tcx.sess.target.ptr_width as u64,
ast::UintTy::U8 => 8,
ast::UintTy::U16 => 16,
ast::UintTy::U32 => 32,
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_error_codes/error_codes/E0062.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This error indicates that during an attempt to build a struct or struct-like
enum variant, one of the fields was specified more than once. Erroneous code
example:
A struct's or struct-like enum variant's field was specified more than once.

Erroneous code example:

```compile_fail,E0062
struct Foo {
Expand All @@ -15,7 +15,9 @@ fn main() {
}
```

Each field should be specified exactly one time. Example:
This error indicates that during an attempt to build a struct or struct-like
enum variant, one of the fields was specified more than once. Each field should
be specified exactly one time. Example:

```
struct Foo {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_error_codes/error_codes/E0063.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
This error indicates that during an attempt to build a struct or struct-like
enum variant, one of the fields was not provided. Erroneous code example:
A struct's or struct-like enum variant's field was not provided.

Erroneous code example:

```compile_fail,E0063
struct Foo {
Expand Down
32 changes: 7 additions & 25 deletions src/librustc_error_codes/error_codes/E0067.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
The left-hand side of a compound assignment expression must be a place
expression. A place expression represents a memory location and includes
item paths (ie, namespaced variables), dereferences, indexing expressions,
and field references.
An invalid left-hand side expression was used on an assignment operation.

Let's start with some erroneous code examples:
Erroneous code example:

```compile_fail,E0067
use std::collections::LinkedList;

// Bad: assignment to non-place expression
LinkedList::new() += 1;

// ...

fn some_func(i: &mut i32) {
i += 12; // Error : '+=' operation cannot be applied on a reference !
}
12 += 1; // error!
```

And now some working examples:
You need to have a place expression to be able to assign it something. For
example:

```
let mut i : i32 = 0;

i += 12; // Good !

// ...

fn some_func(i: &mut i32) {
*i += 12; // Good !
}
let mut x: i8 = 12;
x += 1; // ok!
```
4 changes: 3 additions & 1 deletion src/librustc_error_codes/error_codes/E0069.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
The compiler found a function whose body contains a `return;` statement but
whose return type is not `()`. An example of this is:
whose return type is not `()`.

Erroneous code example:

```compile_fail,E0069
// error
Expand Down
Loading