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 15 pull requests #57554

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c0f0f45
Don't actually create a full MIR stack frame when not needed
oli-obk Jan 5, 2019
0a82177
Always calculate glob map but only for glob uses
Xanewok Jan 6, 2019
ddff2ed
Remove unnecessary adapter
sinkuu Jan 6, 2019
f671242
Derive Clone for ArgumentV1
sinkuu Jan 6, 2019
71c6402
Account for 2 removed lines in src/librustdoc/test.rs
Xanewok Jan 7, 2019
6e742db
Optimise floating point `is_finite` (2x) and `is_infinite` (1.6x).
huonw Jan 5, 2019
6a790d3
Improve the wording
JohnTitor Jan 7, 2019
eed163e
save-analysis: use a fallback when access levels couldn't be computed
Xanewok Jan 7, 2019
7e30123
Fix indentation
oli-obk Jan 8, 2019
14e662d
Manually push a stack frame where no valid frame is needed
oli-obk Jan 8, 2019
cea282b
Make `mk_eval_cx` private to const eval
oli-obk Jan 8, 2019
b8139a7
Add some size assertions for const eval types
oli-obk Jan 8, 2019
e0ba421
`ConstValue::ScalarPair` only needs to represent slices
oli-obk Jan 8, 2019
d9ddc39
lldb_batchmode.py: try `import _thread` for Python 3
cuviper Jan 8, 2019
12ae365
Misc cleanups
sinkuu Jan 6, 2019
46fa818
Change `String` to `&'static str` in `ParseResult::Failure`.
nnethercote Jan 9, 2019
f174b73
Document the `mk_*_eval_cx` functions
oli-obk Jan 9, 2019
3fba811
Update comment to match the changed code below
oli-obk Jan 9, 2019
3177a6f
Explain why we are using a `Scalar` and not a `Pointer`
oli-obk Jan 9, 2019
cd5a9e0
Explain the arguments of the `mk_*_eval_cx` functions
oli-obk Jan 9, 2019
dec79e4
Not seeing the forest because there are too many trees in the way
oli-obk Jan 9, 2019
c47ed14
save-analysis: Get path def from parent in case there's no def for th…
emilio Jan 9, 2019
bbb5448
std: Render large exit codes as hex on Windows
alexcrichton Jan 9, 2019
07600c9
Drop "solved" constraints during region expansion
dotdash Jan 9, 2019
5f402b8
Add a fast path for identical regions in lub_concrete_regions
dotdash Jan 10, 2019
3f03297
inline pub extern crate statements
DebugSteven Jan 11, 2019
ca47808
add test for pub extern crate
DebugSteven Jan 11, 2019
186d5d7
re-do docs for core::cmp
steveklabnik Jan 10, 2019
7948b18
Use `ptr::eq` where applicable
Xanewok Jan 12, 2019
5ed7c37
Rollup merge of #57351 - oli-obk:cheap_const_ops, r=RalfJung
pietroalbini Jan 12, 2019
f052a1b
Rollup merge of #57353 - huonw:faster-finiteness-checks, r=KodrAus
pietroalbini Jan 12, 2019
13df6cd
Rollup merge of #57392 - Xanewok:always-calc-glob-map, r=petrochenkov
pietroalbini Jan 12, 2019
1fa2932
Rollup merge of #57412 - JohnTitor:improve-the-wording-1, r=varkor
pietroalbini Jan 12, 2019
f014b94
Rollup merge of #57436 - Xanewok:save-analysis-access-ice-fix, r=niko…
pietroalbini Jan 12, 2019
bff32fc
Rollup merge of #57442 - oli-obk:lazy_const, r=RalfJung
pietroalbini Jan 12, 2019
519b0f0
Rollup merge of #57453 - cuviper:python3-thread, r=nikomatsakis
pietroalbini Jan 12, 2019
33f3772
Rollup merge of #57454 - sinkuu:fmt_cleanup, r=joshtriplett
pietroalbini Jan 12, 2019
eaaf295
Rollup merge of #57461 - nnethercote:ParseResult-Failure-static-str, …
pietroalbini Jan 12, 2019
7349a12
Rollup merge of #57473 - alexcrichton:hex-display-on-windows, r=Kimundi
pietroalbini Jan 12, 2019
21ed69d
Rollup merge of #57474 - emilio:save-analysis-path, r=nrc
pietroalbini Jan 12, 2019
085d06c
Rollup merge of #57494 - dotdash:expand, r=nikomatsakis
pietroalbini Jan 12, 2019
461244a
Rollup merge of #57496 - steveklabnik:gh32934, r=Centril
pietroalbini Jan 12, 2019
11549df
Rollup merge of #57508 - DebugSteven:inline-extern, r=GuillaumeGomez
pietroalbini Jan 12, 2019
156c35f
Rollup merge of #57547 - Xanewok:ptr-eq, r=petrochenkov
pietroalbini Jan 12, 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
7 changes: 6 additions & 1 deletion src/etc/lldb_batchmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import os
import sys
import threading
import thread
import re
import time

try:
import thread
except ModuleNotFoundError:
# The `thread` module was renamed to `_thread` in Python 3.
import _thread as thread

# Set this to True for additional output
DEBUG_OUTPUT = False

Expand Down
35 changes: 15 additions & 20 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
//! Functionality for ordering and comparison.
//!
//! This module defines both [`PartialOrd`] and [`PartialEq`] traits which are used
//! by the compiler to implement comparison operators. Rust programs may
//! implement [`PartialOrd`] to overload the `<`, `<=`, `>`, and `>=` operators,
//! and may implement [`PartialEq`] to overload the `==` and `!=` operators.
//! This module contains various tools for ordering and comparing values. In
//! summary:
//!
//! [`PartialOrd`]: trait.PartialOrd.html
//! [`PartialEq`]: trait.PartialEq.html
//! * [`Eq`] and [`PartialEq`] are traits that allow you to define total and
//! partial equality between values, respectively. Implementing them overloads
//! the `==` and `!=` operators.
//! * [`Ord`] and [`PartialOrd`] are traits that allow you to define total and
//! partial orderings between values, respectively. Implementing them overloads
//! the `<`, `<=`, `>`, and `>=` operators.
//! * [`Ordering`][cmp::Ordering] is an enum returned by the
//! main functions of [`Ord`] and [`PartialOrd`], and describes an ordering.
//! * [`Reverse`][cmp::Reverse] is a struct that allows you to easily reverse
//! an ordering.
//! * [`max`][cmp::max] and [`min`][cmp::min] are functions that build off of
//! [`Ord`] and allow you to find the maximum or minimum of two values.
//!
//! # Examples
//!
//! ```
//! let x: u32 = 0;
//! let y: u32 = 1;
//!
//! // these two lines are equivalent
//! assert_eq!(x < y, true);
//! assert_eq!(x.lt(&y), true);
//!
//! // these two lines are also equivalent
//! assert_eq!(x == y, false);
//! assert_eq!(x.eq(&y), false);
//! ```
//! For more details, see the respective documentation of each item in the list.

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
47 changes: 9 additions & 38 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,8 @@ pub trait Write {
/// assert_eq!(&buf, "world");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn write_fmt(&mut self, args: Arguments) -> Result {
// This Adapter is needed to allow `self` (of type `&mut
// Self`) to be cast to a Write (below) without
// requiring a `Sized` bound.
struct Adapter<'a,T: ?Sized +'a>(&'a mut T);

impl<T: ?Sized> Write for Adapter<'_, T>
where T: Write
{
fn write_str(&mut self, s: &str) -> Result {
self.0.write_str(s)
}

fn write_char(&mut self, c: char) -> Result {
self.0.write_char(c)
}

fn write_fmt(&mut self, args: Arguments) -> Result {
self.0.write_fmt(args)
}
}

write(&mut Adapter(self), args)
fn write_fmt(mut self: &mut Self, args: Arguments) -> Result {
write(&mut self, args)
}
}

Expand Down Expand Up @@ -268,7 +247,7 @@ struct Void {
/// family of functions. It contains a function to format the given value. At
/// compile time it is ensured that the function and the value have the correct
/// types, and then this struct is used to canonicalize arguments to one type.
#[derive(Copy)]
#[derive(Copy, Clone)]
#[allow(missing_debug_implementations)]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
issue = "0")]
Expand All @@ -278,14 +257,6 @@ pub struct ArgumentV1<'a> {
formatter: fn(&Void, &mut Formatter) -> Result,
}

#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
issue = "0")]
impl Clone for ArgumentV1<'_> {
fn clone(&self) -> Self {
*self
}
}

impl<'a> ArgumentV1<'a> {
#[inline(never)]
fn show_usize(x: &usize, f: &mut Formatter) -> Result {
Expand Down Expand Up @@ -1105,7 +1076,7 @@ impl<'a> Formatter<'a> {
self.args[i].as_usize()
}
rt::v1::Count::NextParam => {
self.curarg.next().and_then(|arg| arg.as_usize())
self.curarg.next()?.as_usize()
}
}
}
Expand Down Expand Up @@ -1171,15 +1142,15 @@ impl<'a> Formatter<'a> {
sign = Some('+'); width += 1;
}

let mut prefixed = false;
if self.alternate() {
prefixed = true; width += prefix.chars().count();
let prefixed = self.alternate();
if prefixed {
width += prefix.chars().count();
}

// Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |f: &mut Formatter| {
if let Some(c) = sign {
f.buf.write_str(c.encode_utf8(&mut [0; 4]))?;
f.buf.write_char(c)?;
}
if prefixed { f.buf.write_str(prefix) }
else { Ok(()) }
Expand Down Expand Up @@ -1341,7 +1312,7 @@ impl<'a> Formatter<'a> {

// remove the sign from the formatted parts
formatted.sign = b"";
width = if width < sign.len() { 0 } else { width - sign.len() };
width = width.saturating_sub(sign.len());
align = rt::v1::Alignment::Right;
self.fill = '0';
self.align = rt::v1::Alignment::Right;
Expand Down
14 changes: 12 additions & 2 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ impl f32 {
self != self
}

// FIXME(#50145): `abs` is publicly unavailable in libcore due to
// concerns about portability, so this implementation is for
// private use internally.
#[inline]
fn abs_private(self) -> f32 {
f32::from_bits(self.to_bits() & 0x7fff_ffff)
}

/// Returns `true` if this value is positive infinity or negative infinity and
/// false otherwise.
///
Expand All @@ -181,7 +189,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_infinite(self) -> bool {
self == INFINITY || self == NEG_INFINITY
self.abs_private() == INFINITY
}

/// Returns `true` if this number is neither infinite nor `NaN`.
Expand All @@ -203,7 +211,9 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_finite(self) -> bool {
!(self.is_nan() || self.is_infinite())
// There's no need to handle NaN separately: if self is NaN,
// the comparison is not true, exactly as desired.
self.abs_private() < INFINITY
}

/// Returns `true` if the number is neither zero, infinite,
Expand Down
14 changes: 12 additions & 2 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ impl f64 {
self != self
}

// FIXME(#50145): `abs` is publicly unavailable in libcore due to
// concerns about portability, so this implementation is for
// private use internally.
#[inline]
fn abs_private(self) -> f64 {
f64::from_bits(self.to_bits() & 0x7fff_ffff_ffff_ffff)
}

/// Returns `true` if this value is positive infinity or negative infinity and
/// false otherwise.
///
Expand All @@ -181,7 +189,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_infinite(self) -> bool {
self == INFINITY || self == NEG_INFINITY
self.abs_private() == INFINITY
}

/// Returns `true` if this number is neither infinite nor `NaN`.
Expand All @@ -203,7 +211,9 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_finite(self) -> bool {
!(self.is_nan() || self.is_infinite())
// There's no need to handle NaN separately: if self is NaN,
// the comparison is not true, exactly as desired.
self.abs_private() < INFINITY
}

/// Returns `true` if the number is neither zero, infinite,
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ impl<'a> Pattern<'a> for char {
#[inline]
fn into_searcher(self, haystack: &'a str) -> Self::Searcher {
let mut utf8_encoded = [0; 4];
self.encode_utf8(&mut utf8_encoded);
let utf8_size = self.len_utf8();
let utf8_size = self.encode_utf8(&mut utf8_encoded).len();
CharSearcher {
haystack,
finger: 0,
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 @@ -302,7 +302,7 @@ impl_stable_hash_for!(struct ty::FieldDef {
impl_stable_hash_for!(
impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] {
Scalar(val),
ScalarPair(a, b),
Slice(a, b),
ByRef(id, alloc, offset),
}
);
Expand Down
31 changes: 23 additions & 8 deletions src/librustc/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use rustc_data_structures::graph::implementation::{
Direction, Graph, NodeIndex, INCOMING, OUTGOING,
};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use smallvec::SmallVec;
use std::fmt;
use std::u32;
use ty::fold::TypeFoldable;
Expand Down Expand Up @@ -190,19 +191,24 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
match *constraint {
Constraint::RegSubVar(a_region, b_vid) => {
let b_data = var_values.value_mut(b_vid);
self.expand_node(a_region, b_vid, b_data)
(self.expand_node(a_region, b_vid, b_data), false)
}
Constraint::VarSubVar(a_vid, b_vid) => match *var_values.value(a_vid) {
VarValue::ErrorValue => false,
VarValue::ErrorValue => (false, false),
VarValue::Value(a_region) => {
let b_node = var_values.value_mut(b_vid);
self.expand_node(a_region, b_vid, b_node)
let changed = self.expand_node(a_region, b_vid, b_node);
let retain = match *b_node {
VarValue::Value(ReStatic) | VarValue::ErrorValue => false,
_ => true
};
(changed, retain)
}
},
Constraint::RegSubReg(..) | Constraint::VarSubReg(..) => {
// These constraints are checked after expansion
// is done, in `collect_errors`.
false
(false, false)
}
}
})
Expand Down Expand Up @@ -268,6 +274,13 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {

fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
let tcx = self.tcx();

// Equal scopes can show up quite often, if the fixed point
// iteration converges slowly, skip them
if a == b {
return a;
}

match (a, b) {
(&ty::ReClosureBound(..), _)
| (_, &ty::ReClosureBound(..))
Expand Down Expand Up @@ -710,21 +723,23 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {

fn iterate_until_fixed_point<F>(&self, tag: &str, mut body: F)
where
F: FnMut(&Constraint<'tcx>, &SubregionOrigin<'tcx>) -> bool,
F: FnMut(&Constraint<'tcx>, &SubregionOrigin<'tcx>) -> (bool, bool),
{
let mut constraints: SmallVec<[_; 16]> = self.data.constraints.iter().collect();
let mut iteration = 0;
let mut changed = true;
while changed {
changed = false;
iteration += 1;
debug!("---- {} Iteration {}{}", "#", tag, iteration);
for (constraint, origin) in &self.data.constraints {
let edge_changed = body(constraint, origin);
constraints.retain(|(constraint, origin)| {
let (edge_changed, retain) = body(constraint, origin);
if edge_changed {
debug!("Updated due to constraint {:?}", constraint);
changed = true;
}
}
retain
});
}
debug!("---- {} Complete after {} iteration(s)", tag, iteration);
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pub struct Pointer<Tag=(),Id=AllocId> {
pub tag: Tag,
}

static_assert!(POINTER_SIZE: ::std::mem::size_of::<Pointer>() == 16);

/// Produces a `Pointer` which points to the beginning of the Allocation
impl From<AllocId> for Pointer {
#[inline(always)]
Expand Down
27 changes: 13 additions & 14 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@ pub enum ConstValue<'tcx> {
/// Not using the enum `Value` to encode that this must not be `Undef`
Scalar(Scalar),

/// Used only for *fat pointers* with layout::abi::ScalarPair
/// Used only for slices and strings (`&[T]`, `&str`, `*const [T]`, `*mut str`, `Box<str>`, ...)
///
/// Needed for pattern matching code related to slices and strings.
ScalarPair(Scalar, Scalar),
/// Empty slices don't necessarily have an address backed by an `AllocId`, thus we also need to
/// enable integer pointers. The `Scalar` type covers exactly those two cases. While we could
/// create dummy-`AllocId`s, the additional code effort for the conversions doesn't seem worth
/// it.
Slice(Scalar, u64),

/// An allocation + offset into the allocation.
/// Invariant: The AllocId matches the allocation.
ByRef(AllocId, &'tcx Allocation, Size),
}

#[cfg(target_arch = "x86_64")]
static_assert!(CONST_SIZE: ::std::mem::size_of::<ConstValue<'static>>() == 40);

impl<'tcx> ConstValue<'tcx> {
#[inline]
pub fn try_to_scalar(&self) -> Option<Scalar> {
match *self {
ConstValue::ByRef(..) |
ConstValue::ScalarPair(..) => None,
ConstValue::Slice(..) => None,
ConstValue::Scalar(val) => Some(val),
}
}
Expand All @@ -56,17 +62,8 @@ impl<'tcx> ConstValue<'tcx> {
pub fn new_slice(
val: Scalar,
len: u64,
cx: &impl HasDataLayout
) -> Self {
ConstValue::ScalarPair(val, Scalar::Bits {
bits: len as u128,
size: cx.data_layout().pointer_size.bytes() as u8,
})
}

#[inline]
pub fn new_dyn_trait(val: Scalar, vtable: Pointer) -> Self {
ConstValue::ScalarPair(val, Scalar::Ptr(vtable))
ConstValue::Slice(val, len)
}
}

Expand All @@ -90,6 +87,8 @@ pub enum Scalar<Tag=(), Id=AllocId> {
Ptr(Pointer<Tag, Id>),
}

static_assert!(SCALAR_SIZE: ::std::mem::size_of::<Scalar>() == 24);

impl<Tag> fmt::Display for Scalar<Tag> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expand Down
Loading