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

Merged
merged 41 commits into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 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
ddff2ed
Remove unnecessary adapter
sinkuu Jan 6, 2019
f671242
Derive Clone for ArgumentV1
sinkuu Jan 6, 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
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
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
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
6aa7856
resolve: Mark extern crate items as used in more cases
petrochenkov Jan 12, 2019
805099c
hygiene: Do not treat `Self` ctor as a local variable
petrochenkov Jan 12, 2019
1e4a8a0
Update the const fn tracking issue to the new metabug
varkor Jan 13, 2019
035eff1
Rollup merge of #57351 - oli-obk:cheap_const_ops, r=RalfJung
Centril Jan 13, 2019
5560d4d
Rollup merge of #57353 - huonw:faster-finiteness-checks, r=KodrAus
Centril Jan 13, 2019
d3cb51c
Rollup merge of #57412 - JohnTitor:improve-the-wording-1, r=varkor
Centril Jan 13, 2019
8e3980b
Rollup merge of #57436 - Xanewok:save-analysis-access-ice-fix, r=niko…
Centril Jan 13, 2019
36c7cde
Rollup merge of #57453 - cuviper:python3-thread, r=nikomatsakis
Centril Jan 13, 2019
b7093e5
Rollup merge of #57454 - sinkuu:fmt_cleanup, r=joshtriplett
Centril Jan 13, 2019
0c53b45
Rollup merge of #57461 - nnethercote:ParseResult-Failure-static-str, …
Centril Jan 13, 2019
b3290fd
Rollup merge of #57473 - alexcrichton:hex-display-on-windows, r=Kimundi
Centril Jan 13, 2019
edec838
Rollup merge of #57474 - emilio:save-analysis-path, r=nrc
Centril Jan 13, 2019
4d6fd9c
Rollup merge of #57494 - dotdash:expand, r=nikomatsakis
Centril Jan 13, 2019
ce448f3
Rollup merge of #57496 - steveklabnik:gh32934, r=Centril
Centril Jan 13, 2019
8f11da4
Rollup merge of #57508 - DebugSteven:inline-extern, r=GuillaumeGomez
Centril Jan 13, 2019
8c1813d
Rollup merge of #57547 - Xanewok:ptr-eq, r=petrochenkov
Centril Jan 13, 2019
c04d6fa
Rollup merge of #57557 - petrochenkov:ecused, r=varkor
Centril Jan 13, 2019
33c5874
Rollup merge of #57560 - petrochenkov:selfinmac, r=alexreg
Centril Jan 13, 2019
3e2dcf9
Rollup merge of #57564 - varkor:update-const_fn-tracking-issue, r=Cen…
Centril Jan 13, 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
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/language-features/const-fn.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `const_fn`

The tracking issue for this feature is: [#24111]
The tracking issue for this feature is: [#57563]

[#24111]: https://github.com/rust-lang/rust/issues/24111
[#57563]: https://github.com/rust-lang/rust/issues/57563

------------------------

Expand Down
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
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
17 changes: 7 additions & 10 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use std::hash::{Hash, Hasher};
use std::fmt;
use std::mem;
use std::ops::{Deref, Bound};
use std::ptr;
use std::iter;
use std::sync::mpsc;
use std::sync::Arc;
Expand Down Expand Up @@ -168,7 +169,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {

// Make sure we don't end up with inference
// types/regions in the global interner
if local as *const _ as usize == global as *const _ as usize {
if ptr::eq(local, global) {
bug!("Attempted to intern `{:?}` which contains \
inference types/regions in the global type context",
&ty_struct);
Expand Down Expand Up @@ -1135,9 +1136,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

/// Returns true if self is the same as self.global_tcx().
fn is_global(self) -> bool {
let local = self.interners as *const _;
let global = &self.global_interners as *const _;
local as usize == global as usize
ptr::eq(self.interners, &self.global_interners)
}

/// Create a type context and call the closure with a `TyCtxt` reference
Expand Down Expand Up @@ -1787,6 +1786,7 @@ pub mod tls {
use std::fmt;
use std::mem;
use std::marker::PhantomData;
use std::ptr;
use syntax_pos;
use ty::query;
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
Expand Down Expand Up @@ -2021,8 +2021,7 @@ pub mod tls {
{
with_context(|context| {
unsafe {
let gcx = tcx.gcx as *const _ as usize;
assert!(context.tcx.gcx as *const _ as usize == gcx);
assert!(ptr::eq(context.tcx.gcx, tcx.gcx));
let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context);
f(context)
}
Expand All @@ -2040,10 +2039,8 @@ pub mod tls {
{
with_context(|context| {
unsafe {
let gcx = tcx.gcx as *const _ as usize;
let interners = tcx.interners as *const _ as usize;
assert!(context.tcx.gcx as *const _ as usize == gcx);
assert!(context.tcx.interners as *const _ as usize == interners);
assert!(ptr::eq(context.tcx.gcx, tcx.gcx));
assert!(ptr::eq(context.tcx.interners, tcx.interners));
let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context);
f(context)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use syntax_pos::{self, Span, FileName};

impl PartialEq for llvm::Metadata {
fn eq(&self, other: &Self) -> bool {
self as *const _ == other as *const _
ptr::eq(self, other)
}
}

Expand Down
Loading