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

Merged
merged 49 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c24fb12
duration div mul extras
newpavlov Jul 29, 2018
12d8f27
review update
newpavlov Jul 29, 2018
3e07236
add MAX_NANOS_F64 constant
newpavlov Jul 29, 2018
2c300fa
change negativity check
newpavlov Jul 30, 2018
2cab0de
don't duplicate impls
newpavlov Jul 31, 2018
d48a649
1.29.0 -> 1.30.0
newpavlov Aug 3, 2018
0673417
Move float ops to unstable inherent methods
newpavlov Sep 12, 2018
36dff2a
Remove tests
newpavlov Sep 12, 2018
206ca68
remove newline
newpavlov Sep 12, 2018
07c15ea
more explicit impl
newpavlov Sep 12, 2018
c5cbea6
fix doctests
newpavlov Sep 12, 2018
de49681
Warn about metadata loader errors
bjorn3 Aug 18, 2018
533c0f0
fix tests
newpavlov Sep 12, 2018
c11281f
fix tests
newpavlov Sep 12, 2018
37972ae
add as_float_secs and from_float_secs methods, refactor float methods
newpavlov Sep 13, 2018
8a0aa9f
remove trailing spaces
newpavlov Sep 13, 2018
9e78cb2
move checks to from_float_secs
newpavlov Sep 13, 2018
2aca697
add panics section to method docs
newpavlov Sep 13, 2018
40e7667
Remove LLVM 3.9 workaround.
irinagpopa Sep 14, 2018
b74215a
Switch wasm math symbols to their original names
alexcrichton Sep 15, 2018
4265256
Enable fatal warnings for the wasm32 linker
alexcrichton Sep 15, 2018
ad8053f
Update LLVM to fix "bool" arguments on PPC32
LionNatsu Sep 15, 2018
73b3c28
Switch linker for aarch64-pc-windows-msvc from LLD to MSVC, since tha…
michaelwoerister Sep 17, 2018
30556d5
Suggest array indexing when tuple indexing on an array.
memoryruins Sep 17, 2018
56c1519
miri: correctly compute expected alignment for field
RalfJung Sep 17, 2018
a8ec8e5
A few cleanups and minor improvements to rustc/traits
ljedrz Sep 12, 2018
dff1bc1
Set diagnostic applicability based on array length
memoryruins Sep 18, 2018
73fdc81
Use expr's span
memoryruins Sep 18, 2018
e3d0d0f
Update The Book to latest
steveklabnik Sep 18, 2018
3d66263
Remove unneeded clone() from tests
ericho Sep 18, 2018
046482e
rustc: future-proof error reporting for polymorphic constants in types.
eddyb Sep 19, 2018
fd7565b
Added tracking issue, fixed check, 1.30 -> 1.31
newpavlov Sep 19, 2018
e2ff97a
Pass --batch to gdb
tromey Sep 19, 2018
ae42e53
Add regression test for thread local static mut borrows
spastorino Sep 19, 2018
a791919
Rollup merge of #52813 - newpavlov:duration_mul_div_extras, r=alexcri…
kennytm Sep 20, 2018
c24d78f
Rollup merge of #53470 - bjorn3:warn_metadata_errors, r=alexcrichton
kennytm Sep 20, 2018
6f7602d
Rollup merge of #54233 - irinagpopa:llvm-3.9, r=tromey
kennytm Sep 20, 2018
a135005
Rollup merge of #54257 - alexcrichton:wasm-math-symbols, r=TimNN
kennytm Sep 20, 2018
13cea8e
Rollup merge of #54258 - alexcrichton:lld-fatal-warnings, r=eddyb
kennytm Sep 20, 2018
9c2dfb4
Rollup merge of #54266 - LionNatsu:master, r=nikomatsakis
kennytm Sep 20, 2018
ea6cfe3
Rollup merge of #54290 - michaelwoerister:aarch64-back-to-msvc, r=ale…
kennytm Sep 20, 2018
cf06e03
Rollup merge of #54292 - memoryruins:issue-53712, r=estebank
kennytm Sep 20, 2018
2d0262e
Rollup merge of #54295 - ljedrz:cleanups_rustc_traits, r=nikomatsakis
kennytm Sep 20, 2018
eb1ec73
Rollup merge of #54298 - RalfJung:miri-field-align, r=eddyb
kennytm Sep 20, 2018
3bfa947
Rollup merge of #54333 - steveklabnik:update-book, r=frewsxcv
kennytm Sep 20, 2018
f5b8c7f
Rollup merge of #54337 - ericho:remove_clone_tests, r=Mark-Simulacrum
kennytm Sep 20, 2018
f2aabb7
Rollup merge of #54346 - eddyb:constant-horror, r=nikomatsakis
kennytm Sep 20, 2018
e76ca54
Rollup merge of #54362 - tromey:travis-gdb-batch-mode, r=nikomatsakis
kennytm Sep 20, 2018
ec08596
Rollup merge of #54367 - spastorino:add-thread-local-static-borrow-te…
kennytm Sep 20, 2018
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ after_failure:
EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|');
if [ -f "$EXE" ]; then
printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE";
gdb -q -c "$CORE" "$EXE"
gdb --batch -q -c "$CORE" "$EXE"
-iex 'set auto-load off'
-iex 'dir src/'
-iex 'set sysroot .'
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 58 files
+4 −0 2018-edition/book.toml
+33 −0 2018-edition/ferris.css
+51 −0 2018-edition/ferris.js
+13 −2 2018-edition/src/ch00-00-introduction.md
+1 −1 2018-edition/src/ch02-00-guessing-game-tutorial.md
+2 −2 2018-edition/src/ch03-01-variables-and-mutability.md
+1 −1 2018-edition/src/ch03-02-data-types.md
+2 −2 2018-edition/src/ch03-03-how-functions-work.md
+2 −2 2018-edition/src/ch03-05-control-flow.md
+1 −1 2018-edition/src/ch04-01-what-is-ownership.md
+4 −4 2018-edition/src/ch04-02-references-and-borrowing.md
+1 −1 2018-edition/src/ch04-03-slices.md
+1 −1 2018-edition/src/ch05-01-defining-structs.md
+1 −1 2018-edition/src/ch05-02-example-structs.md
+1 −1 2018-edition/src/ch06-01-defining-an-enum.md
+1 −1 2018-edition/src/ch06-02-match.md
+1 −1 2018-edition/src/ch07-01-mod-and-the-filesystem.md
+1 −1 2018-edition/src/ch07-02-controlling-visibility-with-pub.md
+1 −1 2018-edition/src/ch07-03-importing-names-with-use.md
+2 −2 2018-edition/src/ch08-01-vectors.md
+2 −2 2018-edition/src/ch08-02-strings.md
+3 −1 2018-edition/src/ch08-03-hash-maps.md
+2 −2 2018-edition/src/ch09-01-unrecoverable-errors-with-panic.md
+0 −1 2018-edition/src/ch09-02-recoverable-errors-with-result.md
+1 −1 2018-edition/src/ch09-03-to-panic-or-not-to-panic.md
+2 −2 2018-edition/src/ch10-01-syntax.md
+1 −1 2018-edition/src/ch10-02-traits.md
+5 −5 2018-edition/src/ch10-03-lifetime-syntax.md
+6 −6 2018-edition/src/ch11-01-writing-tests.md
+1 −1 2018-edition/src/ch11-02-running-tests.md
+1 −1 2018-edition/src/ch12-02-reading-a-file.md
+4 −4 2018-edition/src/ch13-01-closures.md
+1 −1 2018-edition/src/ch13-02-iterators.md
+1 −1 2018-edition/src/ch15-01-box.md
+1 −1 2018-edition/src/ch15-02-deref.md
+1 −1 2018-edition/src/ch15-03-drop.md
+1 −1 2018-edition/src/ch15-04-rc.md
+3 −3 2018-edition/src/ch15-05-interior-mutability.md
+2 −2 2018-edition/src/ch16-01-threads.md
+1 −1 2018-edition/src/ch16-02-message-passing.md
+3 −3 2018-edition/src/ch16-03-shared-state.md
+2 −2 2018-edition/src/ch17-02-trait-objects.md
+1 −1 2018-edition/src/ch18-01-all-the-places-for-patterns.md
+2 −2 2018-edition/src/ch18-02-refutability.md
+2 −2 2018-edition/src/ch18-03-pattern-syntax.md
+8 −8 2018-edition/src/ch19-01-unsafe-rust.md
+4 −4 2018-edition/src/ch19-02-advanced-lifetimes.md
+1 −1 2018-edition/src/ch19-03-advanced-traits.md
+2 −2 2018-edition/src/ch19-04-advanced-types.md
+1 −1 2018-edition/src/ch19-05-advanced-functions-and-closures.md
+13 −13 2018-edition/src/ch20-02-multithreaded.md
+2 −2 2018-edition/src/ch20-03-graceful-shutdown-and-cleanup.md
+72 −0 2018-edition/src/img/ferris/does_not_compile.svg
+75 −0 2018-edition/src/img/ferris/not_desired_behavior.svg
+70 −0 2018-edition/src/img/ferris/panics.svg
+291 −0 2018-edition/src/img/ferris/unsafe.svg
+18 −18 second-edition/src/ch11-01-writing-tests.md
+1 −1 second-edition/src/ch20-03-graceful-shutdown-and-cleanup.md
121 changes: 120 additions & 1 deletion src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
//! ```

use fmt;
use {fmt, u64};
use iter::Sum;
use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign};

Expand All @@ -30,6 +30,7 @@ const NANOS_PER_MILLI: u32 = 1_000_000;
const NANOS_PER_MICRO: u32 = 1_000;
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;

/// A `Duration` type to represent a span of time, typically used for system
/// timeouts.
Expand Down Expand Up @@ -458,6 +459,115 @@ impl Duration {
None
}
}

/// Returns the number of seconds contained by this `Duration` as `f64`.
///
/// The returned value does include the fractional (nanosecond) part of the duration.
///
/// # Examples
/// ```
/// #![feature(duration_float)]
/// use std::time::Duration;
///
/// let dur = Duration::new(2, 700_000_000);
/// assert_eq!(dur.as_float_secs(), 2.7);
/// ```
#[unstable(feature = "duration_float", issue = "54361")]
#[inline]
pub fn as_float_secs(&self) -> f64 {
(self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64)
}

/// Creates a new `Duration` from the specified number of seconds.
///
/// # Panics
/// This constructor will panic if `secs` is not finite, negative or overflows `Duration`.
///
/// # Examples
/// ```
/// #![feature(duration_float)]
/// use std::time::Duration;
///
/// let dur = Duration::from_float_secs(2.7);
/// assert_eq!(dur, Duration::new(2, 700_000_000));
/// ```
#[unstable(feature = "duration_float", issue = "54361")]
#[inline]
pub fn from_float_secs(secs: f64) -> Duration {
let nanos = secs * (NANOS_PER_SEC as f64);
if !nanos.is_finite() {
panic!("got non-finite value when converting float to duration");
}
if nanos >= MAX_NANOS_F64 {
panic!("overflow when converting float to duration");
}
if nanos < 0.0 {
panic!("underflow when converting float to duration");
}
let nanos = nanos as u128;
Duration {
secs: (nanos / (NANOS_PER_SEC as u128)) as u64,
nanos: (nanos % (NANOS_PER_SEC as u128)) as u32,
}
}

/// Multiply `Duration` by `f64`.
///
/// # Panics
/// This method will panic if result is not finite, negative or overflows `Duration`.
///
/// # Examples
/// ```
/// #![feature(duration_float)]
/// use std::time::Duration;
///
/// let dur = Duration::new(2, 700_000_000);
/// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000));
/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0));
/// ```
#[unstable(feature = "duration_float", issue = "54361")]
#[inline]
pub fn mul_f64(self, rhs: f64) -> Duration {
Duration::from_float_secs(rhs * self.as_float_secs())
}

/// Divide `Duration` by `f64`.
///
/// # Panics
/// This method will panic if result is not finite, negative or overflows `Duration`.
///
/// # Examples
/// ```
/// #![feature(duration_float)]
/// use std::time::Duration;
///
/// let dur = Duration::new(2, 700_000_000);
/// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611));
/// // note that truncation is used, not rounding
/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598));
/// ```
#[unstable(feature = "duration_float", issue = "54361")]
#[inline]
pub fn div_f64(self, rhs: f64) -> Duration {
Duration::from_float_secs(self.as_float_secs() / rhs)
}

/// Divide `Duration` by `Duration` and return `f64`.
///
/// # Examples
/// ```
/// #![feature(duration_float)]
/// use std::time::Duration;
///
/// let dur1 = Duration::new(2, 700_000_000);
/// let dur2 = Duration::new(5, 400_000_000);
/// assert_eq!(dur1.div_duration(dur2), 0.5);
/// ```
#[unstable(feature = "duration_float", issue = "54361")]
#[inline]
pub fn div_duration(self, rhs: Duration) -> f64 {
self.as_float_secs() / rhs.as_float_secs()
}
}

#[stable(feature = "duration", since = "1.3.0")]
Expand Down Expand Up @@ -501,6 +611,15 @@ impl Mul<u32> for Duration {
}
}

#[stable(feature = "symmetric_u32_duration_mul", since = "1.31.0")]
impl Mul<Duration> for u32 {
type Output = Duration;

fn mul(self, rhs: Duration) -> Duration {
rhs * self
}
}

#[stable(feature = "time_augmented_assignment", since = "1.9.0")]
impl MulAssign<u32> for Duration {
fn mul_assign(&mut self, rhs: u32) {
Expand Down
18 changes: 10 additions & 8 deletions src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,18 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
orig_params,
trait_pred.to_poly_trait_predicate(),
));

match result {
Ok(Some(Vtable::VtableImpl(_))) => {
debug!(
"find_auto_trait_generics(did={:?}, trait_did={:?}, generics={:?}): \
manual impl found, bailing out",
did, trait_did, generics
);
return true;
true
}
_ => return false,
};
_ => false
}
});

// If an explicit impl exists, it always takes priority over an auto impl
Expand Down Expand Up @@ -426,6 +427,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
if new_trait.def_id() == old_trait.def_id() {
let new_substs = new_trait.skip_binder().trait_ref.substs;
let old_substs = old_trait.skip_binder().trait_ref.substs;

if !new_substs.types().eq(old_substs.types()) {
// We can't compare lifetimes if the types are different,
// so skip checking old_pred
Expand Down Expand Up @@ -489,12 +491,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {

pub fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, String>) -> String {
self.region_name(region)
.map(|name| {
names_map.get(&name).unwrap_or_else(|| {
.map(|name|
names_map.get(&name).unwrap_or_else(||
panic!("Missing lifetime with name {:?} for {:?}", name, region)
})
})
.unwrap_or(&"'static".to_string())
)
)
.unwrap_or(&"'static".to_owned())
.clone()
}

Expand Down
31 changes: 12 additions & 19 deletions src/librustc/traits/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>,
let trait_ref = ty.erase_regions(&trait_ref);

debug!("codegen_fulfill_obligation(trait_ref={:?}, def_id={:?})",
(param_env, trait_ref), trait_ref.def_id());
(param_env, trait_ref), trait_ref.def_id());

// Do the initial selection for the obligation. This yields the
// shallow result we are looking for -- that is, what specific impl.
Expand All @@ -48,8 +48,8 @@ pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>,

let obligation_cause = ObligationCause::dummy();
let obligation = Obligation::new(obligation_cause,
param_env,
trait_ref.to_poly_trait_predicate());
param_env,
trait_ref.to_poly_trait_predicate());

let selection = match selcx.select(&obligation) {
Ok(Some(selection)) => selection,
Expand All @@ -61,12 +61,11 @@ pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>,
// overflow bug, since I believe this is the only case
// where ambiguity can result.
bug!("Encountered ambiguity selecting `{:?}` during codegen, \
presuming due to overflow",
trait_ref)
presuming due to overflow",
trait_ref)
}
Err(e) => {
bug!("Encountered error `{:?}` selecting `{:?}` during codegen",
e, trait_ref)
bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref)
}
};

Expand Down Expand Up @@ -163,22 +162,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// In principle, we only need to do this so long as `result`
// contains unbound type parameters. It could be a slight
// optimization to stop iterating early.
match fulfill_cx.select_all_or_error(self) {
Ok(()) => { }
Err(errors) => {
span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking",
errors);
}
if let Err(errors) = fulfill_cx.select_all_or_error(self) {
span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking",
errors);
}

let result = self.resolve_type_vars_if_possible(result);
let result = self.tcx.erase_regions(&result);

match self.tcx.lift_to_global(&result) {
Some(result) => result,
None => {
span_bug!(span, "Uninferred types/regions in `{:?}`", result);
}
}
self.tcx.lift_to_global(&result).unwrap_or_else(||
span_bug!(span, "Uninferred types/regions in `{:?}`", result)
)
}
}
21 changes: 8 additions & 13 deletions src/librustc/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
b_def_id: DefId)
-> Option<OverlapResult<'tcx>>
{
debug!("overlap(a_def_id={:?}, b_def_id={:?})",
a_def_id,
b_def_id);
debug!("overlap(a_def_id={:?}, b_def_id={:?})", a_def_id, b_def_id);

// For the purposes of this check, we don't bring any skolemized
// types into scope; instead, we replace the generic types with
Expand All @@ -133,10 +131,9 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,

// Do `a` and `b` unify? If not, no overlap.
let obligations = match selcx.infcx().at(&ObligationCause::dummy(), param_env)
.eq_impl_headers(&a_impl_header, &b_impl_header) {
Ok(InferOk { obligations, value: () }) => {
obligations
}
.eq_impl_headers(&a_impl_header, &b_impl_header)
{
Ok(InferOk { obligations, value: () }) => obligations,
Err(_) => return None
};

Expand Down Expand Up @@ -164,7 +161,7 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
return None
}

let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header);
let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header);
let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();
debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes);
Some(OverlapResult { impl_header, intercrate_ambiguity_causes })
Expand Down Expand Up @@ -471,14 +468,12 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
ty::Foreign(did) => def_id_is_local(did, in_crate),

ty::Dynamic(ref tt, ..) => {
tt.principal().map_or(false, |p| {
tt.principal().map_or(false, |p|
def_id_is_local(p.def_id(), in_crate)
})
)
}

ty::Error => {
true
}
ty::Error => true,

ty::Closure(..) |
ty::Generator(..) |
Expand Down
Loading