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 16 pull requests #58664

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
eb5b096
RangeInclusive internal iteration performance improvement.
matthieu-m Feb 3, 2019
a15916b
[WIP] add better error message for partial move
clintfred Feb 5, 2019
d4c52bf
error output updated by ./x.py test --stage 1 src/test/ui --increment…
clintfred Feb 6, 2019
bc9bfc7
Implement ffi_returns_twice attribute
gnzlbg Feb 9, 2019
4fed67f
Fix exhaustion of inclusive range try_fold and try_rfold
matthieu-m Feb 9, 2019
19ee98f
Correct error message
gnzlbg Feb 9, 2019
bf2c5d3
Use pattern to match attributes
gnzlbg Feb 10, 2019
d0fddd3
Fix attribute check
gnzlbg Feb 10, 2019
4e5eda3
compute is_partial_move outside of the move_site loop for clarity
clintfred Feb 13, 2019
96fd218
check if `used_place` and `moved_place` are equal when determining if…
clintfred Feb 13, 2019
755b320
simplified conditional
clintfred Feb 13, 2019
283ffcf
Check the self-type of inherent associated constants
matthewjasper Feb 11, 2019
347a42e
SGX target: fix panic = abort
Feb 14, 2019
503e74e
Fix SECURITY_SQOS_PRESENT missing
pitdicker Feb 6, 2019
9295f49
Correct OpenOptions::security_qos_flags documentation
pitdicker Feb 6, 2019
235a6b7
Expose const -> op functions that don't allow violiting const eval in…
oli-obk Feb 16, 2019
bd18cc5
Remove an intermediate value from discriminant reading
oli-obk Feb 16, 2019
b2bf37a
Burn some invariants we keep up into code
oli-obk Feb 16, 2019
f7c4931
Reuse the `Pointer` type instead of passing reassembling it at many u…
oli-obk Feb 16, 2019
7db96a3
Reintroduce the invariant comment for clarity
oli-obk Feb 16, 2019
bee3c67
Update src/librustc_mir/interpret/operand.rs
RalfJung Feb 16, 2019
525983a
Make validity checking use `MPlaceTy` instead of `OpTy`
oli-obk Feb 15, 2019
27e438a
Make `may_normalize` explicit in the type system
oli-obk Feb 16, 2019
4fdeb2d
Add `eval` prefix to clarify what the function does
oli-obk Feb 16, 2019
4b08533
Update docs and visibilities of const to op methods
oli-obk Feb 16, 2019
1fe7eb0
Limit the visibility further and expand on a comment
oli-obk Feb 16, 2019
d26bf74
Change `Token::interpolated_to_tokenstream()`.
nnethercote Feb 14, 2019
f8801f3
Remove `LazyTokenStream`.
nnethercote Feb 14, 2019
f0d8fbd
Avoid a `clone()` in `transcribe()`.
nnethercote Feb 15, 2019
82ad4f1
Make `interpolated_to_tokenstream` a method on `Nonterminal`.
nnethercote Feb 17, 2019
895a794
Remove some unnecessary `into()` calls.
nnethercote Feb 17, 2019
de05548
re-blessing error output: ./x.py test src/test/ui --stage 1 --bless
clintfred Feb 18, 2019
0651157
Remove sys::*::Stderr Write implementation
pitdicker Feb 11, 2019
cc20ed6
Remove unused Read implementation on sys::Windows::Stdin
pitdicker Feb 14, 2019
f411852
Refactor Windows stdio and remove stdin double buffering
pitdicker Feb 14, 2019
8e219e7
Turn duration consts into associated consts
Feb 20, 2019
02fe6a7
./x.py test src/test/ui --stage 1 --bless -i --compare-mode=nll
clintfred Feb 20, 2019
b09803e
Address review comments
pitdicker Feb 19, 2019
6464e32
Use standard Read/Write traits in sys::stdio
pitdicker Feb 20, 2019
f223c03
Add examples for duration constants
Feb 20, 2019
36f18f2
Allow Self::Module to be mutated.
gabi-250 Feb 20, 2019
c6d24cd
Enable feature duration_constants in examples
Feb 21, 2019
e5d1fa5
codegen and write_metadata can mutate ModuleLLvm.
gabi-250 Feb 21, 2019
9f58c5f
Optimise vec![false; N] to zero-alloc
RReverser Feb 21, 2019
bba0ea2
rustdoc: support methods on primitives in intra-doc links
tspiteri Feb 22, 2019
b5ae4d5
Don't generate minification variable if minification disabled
GuillaumeGomez Feb 22, 2019
e555854
Make target pointer-width specific variants of (very old) huge-array-…
pnkfelix Feb 22, 2019
b72ba05
Switch from error patterns to `//~ ERROR` markers.
pnkfelix Feb 22, 2019
cc1cd83
Do not underflow after resetting unmatched braces count
estebank Feb 22, 2019
b4c8dc0
Rollup merge of #58122 - matthieu-m:range_incl_perf, r=dtolnay
Centril Feb 23, 2019
a34730d
Rollup merge of #58199 - clintfred:partial-move-err-msg, r=estebank
Centril Feb 23, 2019
8c66221
Rollup merge of #58216 - pitdicker:sqos_flags, r=alexcrichton
Centril Feb 23, 2019
63be1a6
Rollup merge of #58315 - gnzlbg:returns_twice, r=alexcrichton
Centril Feb 23, 2019
decd787
Rollup merge of #58353 - matthewjasper:typeck-pattern-constants, r=ar…
Centril Feb 23, 2019
949ff12
Rollup merge of #58453 - jethrogb:jb/sgx-panic-abort, r=nagisa
Centril Feb 23, 2019
1000776
Rollup merge of #58454 - pitdicker:windows_stdio, r=alexcrichton
Centril Feb 23, 2019
b440487
Rollup merge of #58476 - nnethercote:rm-LazyTokenStream, r=petrochenkov
Centril Feb 23, 2019
89c4253
Rollup merge of #58511 - oli-obk:const_to_op, r=RalfJung
Centril Feb 23, 2019
70f97c9
Rollup merge of #58595 - stjepang:make-duration-consts-associated, r=…
Centril Feb 23, 2019
f4b182d
Rollup merge of #58609 - gabi-250:mutable-refs, r=oli-obk
Centril Feb 23, 2019
89ac6cc
Rollup merge of #58628 - RReverser:optimise-vec-false, r=oli-obk
Centril Feb 23, 2019
c85de5c
Rollup merge of #58642 - tspiteri:intra-rustdoc-prim-method, r=Guilla…
Centril Feb 23, 2019
80ab575
Rollup merge of #58643 - GuillaumeGomez:extra-variables, r=Manishearth
Centril Feb 23, 2019
b019549
Rollup merge of #58648 - pnkfelix:issue-23926-update-tests, r=nikomat…
Centril Feb 23, 2019
de703e7
Rollup merge of #58654 - estebank:underflow, r=nikomatsakis
Centril Feb 23, 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
1 change: 1 addition & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ impl_is_zero!(u64, |x| x == 0);
impl_is_zero!(u128, |x| x == 0);
impl_is_zero!(usize, |x| x == 0);

impl_is_zero!(bool, |x| x == false);
impl_is_zero!(char, |x| x == '\0');

impl_is_zero!(f32, |x: f32| x.to_bits() == 0);
Expand Down
61 changes: 58 additions & 3 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use convert::TryFrom;
use mem;
use ops::{self, Add, Sub};
use ops::{self, Add, Sub, Try};
use usize;

use super::{FusedIterator, TrustedLen};
Expand Down Expand Up @@ -368,11 +368,11 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
Some(Less) => {
self.is_empty = Some(false);
self.start = plus_n.add_one();
return Some(plus_n)
return Some(plus_n);
}
Some(Equal) => {
self.is_empty = Some(true);
return Some(plus_n)
return Some(plus_n);
}
_ => {}
}
Expand All @@ -382,6 +382,34 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
None
}

#[inline]
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
self.compute_is_empty();

if self.is_empty() {
return Try::from_ok(init);
}

let mut accum = init;

while self.start < self.end {
let n = self.start.add_one();
let n = mem::replace(&mut self.start, n);
accum = f(accum, n)?;
}

self.is_empty = Some(true);

if self.start == self.end {
accum = f(accum, self.start.clone())?;
}

Try::from_ok(accum)
}

#[inline]
fn last(mut self) -> Option<A> {
self.next_back()
Expand Down Expand Up @@ -415,6 +443,33 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
self.end.clone()
})
}

#[inline]
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
self.compute_is_empty();

if self.is_empty() {
return Try::from_ok(init);
}

let mut accum = init;

while self.start < self.end {
let n = self.end.sub_one();
let n = mem::replace(&mut self.end, n);
accum = f(accum, n)?;
}

self.is_empty = Some(true);

if self.start == self.end {
accum = f(accum, self.start.clone())?;
}

Try::from_ok(accum)
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,14 @@ pub struct RangeInclusive<Idx> {
trait RangeInclusiveEquality: Sized {
fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool;
}

impl<T> RangeInclusiveEquality for T {
#[inline]
default fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool {
range.is_empty.unwrap_or_default()
}
}

impl<T: PartialOrd> RangeInclusiveEquality for T {
#[inline]
fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool {
Expand Down
24 changes: 21 additions & 3 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,19 +1741,37 @@ fn test_range_inclusive_folds() {
assert_eq!((1..=10).sum::<i32>(), 55);
assert_eq!((1..=10).rev().sum::<i32>(), 55);

let mut it = 40..=50;
let mut it = 44..=50;
assert_eq!(it.try_fold(0, i8::checked_add), None);
assert_eq!(it, 44..=50);
assert_eq!(it, 47..=50);
assert_eq!(it.try_fold(0, i8::checked_add), None);
assert_eq!(it, 50..=50);
assert_eq!(it.try_fold(0, i8::checked_add), Some(50));
assert!(it.is_empty());
assert_eq!(it.try_fold(0, i8::checked_add), Some(0));
assert!(it.is_empty());

let mut it = 40..=47;
assert_eq!(it.try_rfold(0, i8::checked_add), None);
assert_eq!(it, 40..=44);
assert_eq!(it.try_rfold(0, i8::checked_add), None);
assert_eq!(it, 44..=47);
assert_eq!(it, 40..=41);
assert_eq!(it.try_rfold(0, i8::checked_add), Some(81));
assert!(it.is_empty());
assert_eq!(it.try_rfold(0, i8::checked_add), Some(0));
assert!(it.is_empty());

let mut it = 10..=20;
assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(165));
assert!(it.is_empty());
assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(0));
assert!(it.is_empty());

let mut it = 10..=20;
assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(165));
assert!(it.is_empty());
assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(0));
assert!(it.is_empty());
}

#[test]
Expand Down
68 changes: 52 additions & 16 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ const MILLIS_PER_SEC: u64 = 1_000;
const MICROS_PER_SEC: u64 = 1_000_000;
const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;

/// The duration of one second.
#[unstable(feature = "duration_constants", issue = "57391")]
pub const SECOND: Duration = Duration::from_secs(1);

/// The duration of one millisecond.
#[unstable(feature = "duration_constants", issue = "57391")]
pub const MILLISECOND: Duration = Duration::from_millis(1);

/// The duration of one microsecond.
#[unstable(feature = "duration_constants", issue = "57391")]
pub const MICROSECOND: Duration = Duration::from_micros(1);

/// The duration of one nanosecond.
#[unstable(feature = "duration_constants", issue = "57391")]
pub const NANOSECOND: Duration = Duration::from_nanos(1);

/// A `Duration` type to represent a span of time, typically used for system
/// timeouts.
///
Expand Down Expand Up @@ -75,6 +59,58 @@ pub struct Duration {
}

impl Duration {
/// The duration of one second.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::SECOND, Duration::from_secs(1));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
pub const SECOND: Duration = Duration::from_secs(1);

/// The duration of one millisecond.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::MILLISECOND, Duration::from_millis(1));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
pub const MILLISECOND: Duration = Duration::from_millis(1);

/// The duration of one microsecond.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::MICROSECOND, Duration::from_micros(1));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
pub const MICROSECOND: Duration = Duration::from_micros(1);

/// The duration of one nanosecond.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::NANOSECOND, Duration::from_nanos(1));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
pub const NANOSECOND: Duration = Duration::from_nanos(1);

/// Creates a new `Duration` from the specified number of whole seconds and
/// additional nanoseconds.
///
Expand Down
5 changes: 3 additions & 2 deletions src/libpanic_abort/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 {

#[cfg(all(target_vendor="fortanix", target_env="sgx"))]
unsafe fn abort() -> ! {
extern "C" { pub fn panic_exit() -> !; }
panic_exit();
// call std::sys::abort_internal
extern "C" { pub fn __rust_abort() -> !; }
__rust_abort();
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,19 +1124,19 @@ impl<'a> LoweringContext<'a> {
TokenTree::Delimited(span, delim, tts) => TokenTree::Delimited(
span,
delim,
self.lower_token_stream(tts.into()).into(),
self.lower_token_stream(tts),
).into(),
}
}

fn lower_token(&mut self, token: Token, span: Span) -> TokenStream {
match token {
Token::Interpolated(_) => {}
other => return TokenTree::Token(span, other).into(),
Token::Interpolated(nt) => {
let tts = nt.to_tokenstream(&self.sess.parse_sess, span);
self.lower_token_stream(tts)
}
other => TokenTree::Token(span, other).into(),
}

let tts = token.interpolated_to_tokenstream(&self.sess.parse_sess, span);
self.lower_token_stream(tts)
}

fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {

fn visit_token(&mut self, t: Token) {
if let Token::Interpolated(nt) = t {
if let token::NtExpr(ref expr) = nt.0 {
if let token::NtExpr(ref expr) = *nt {
if let ExprKind::Mac(..) = expr.node {
self.visit_macro_invoc(expr.id);
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,9 @@ bitflags! {
/// `#[used]`: indicates that LLVM can't eliminate this function (but the
/// linker can!).
const USED = 1 << 9;
/// #[ffi_returns_twice], indicates that an extern function can return
/// multiple times
const FFI_RETURNS_TWICE = 1 << 10;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl_stable_hash_for!(
impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] {
Scalar(val),
Slice(a, b),
ByRef(id, alloc, offset),
ByRef(ptr, alloc),
}
);
impl_stable_hash_for!(struct crate::mir::interpret::RawConst<'tcx> {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub enum ConstValue<'tcx> {
/// it.
Slice(Scalar, u64),

/// An allocation together with an offset into the allocation.
/// Invariant: the `AllocId` matches the allocation.
ByRef(AllocId, &'tcx Allocation, Size),
/// An allocation together with a pointer into the allocation.
/// Invariant: the pointer's `AllocId` resolves to the allocation.
ByRef(Pointer, &'tcx Allocation),
}

#[cfg(target_arch = "x86_64")]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
match *self {
ConstValue::Scalar(x) => Some(ConstValue::Scalar(x)),
ConstValue::Slice(x, y) => Some(ConstValue::Slice(x, y)),
ConstValue::ByRef(x, alloc, z) => Some(ConstValue::ByRef(
x, alloc.lift_to_tcx(tcx)?, z,
ConstValue::ByRef(ptr, alloc) => Some(ConstValue::ByRef(
ptr, alloc.lift_to_tcx(tcx)?,
)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
use crate::ModuleLlvm;
use crate::llvm::{self, False, True};

pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) {
pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) {
let llcx = &*mods.llcx;
let llmod = mods.llmod();
let usize = match &tcx.sess.target.target.target_pointer_width[..] {
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ pub fn from_fn_attrs(
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
Attribute::Cold.apply_llfn(Function, llfn);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
Attribute::ReturnsTwice.apply_llfn(Function, llfn);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
naked(llfn, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use crate::value::Value;

pub fn write_metadata<'a, 'gcx>(
tcx: TyCtxt<'a, 'gcx, 'gcx>,
llvm_module: &ModuleLlvm
llvm_module: &mut ModuleLlvm
) -> EncodedMetadata {
use std::io::Write;
use flate2::Compression;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn codegen_static_initializer(
let static_ = cx.tcx.const_eval(param_env.and(cid))?;

let alloc = match static_.val {
ConstValue::ByRef(_, alloc, n) if n.bytes() == 0 => alloc,
ConstValue::ByRef(ptr, alloc) if ptr.offset.bytes() == 0 => alloc,
_ => bug!("static const eval returned {:#?}", static_),
};
Ok((const_alloc_to_llvm(cx, alloc), alloc))
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
fn write_metadata<'b, 'gcx>(
&self,
tcx: TyCtxt<'b, 'gcx, 'gcx>,
metadata: &ModuleLlvm
metadata: &mut ModuleLlvm
) -> EncodedMetadata {
base::write_metadata(tcx, metadata)
}
fn codegen_allocator(&self, tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) {
fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) {
unsafe { allocator::codegen(tcx, mods, kind) }
}
fn compile_codegen_unit<'a, 'tcx: 'a>(
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub enum Attribute {
SanitizeMemory = 22,
NonLazyBind = 23,
OptimizeNone = 24,
ReturnsTwice = 25,
}

/// LLVMIntPredicate
Expand Down
Loading