Auto merge of #46874 - kennytm:rollup, r=kennytm

Rollup of 14 pull requests

- Successful merges: #46359, #46517, #46671, #46751, #46760, #46787, #46794, #46828, #46831, #46835, #46851, #46852, #46856, #46870
- Failed merges:
This commit is contained in:
bors 2017-12-20 14:47:21 +00:00
commit 81622c6b02
45 changed files with 255 additions and 143 deletions

View file

@ -504,6 +504,7 @@ impl Step for DebuggerScripts {
install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"),
0o755);
cp_debugger_script("natvis/intrinsic.natvis");
cp_debugger_script("natvis/liballoc.natvis");
cp_debugger_script("natvis/libcore.natvis");
} else {

View file

@ -15,4 +15,4 @@ for /f "delims=" %%i in ('rustc --print=sysroot') do set rustc_sysroot=%%i
set rust_etc=%rustc_sysroot%\lib\rustlib\etc
windbg -c ".nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*
windbg -c ".nvload %rust_etc%\intrinsic.natvis; .nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*

View file

@ -584,7 +584,6 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let cell = RefCell::new(5);
/// let old_value = cell.replace(6);
@ -592,7 +591,7 @@ impl<T> RefCell<T> {
/// assert_eq!(cell, RefCell::new(6));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_replace", since="1.24.0")]
pub fn replace(&self, t: T) -> T {
mem::replace(&mut *self.borrow_mut(), t)
}
@ -636,7 +635,6 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let c = RefCell::new(5);
/// let d = RefCell::new(6);
@ -645,7 +643,7 @@ impl<T> RefCell<T> {
/// assert_eq!(d, RefCell::new(5));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_swap", since="1.24.0")]
pub fn swap(&self, other: &Self) {
mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut())
}

View file

@ -32,22 +32,23 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
// Don't inline this so callers that call both this and the above won't wind
// up using the combined stack space of both functions in some cases.
#[inline(never)]
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter,
num: &T, sign: flt2dec::Sign) -> Result
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter, num: &T,
sign: flt2dec::Sign, precision: usize) -> Result
where T: flt2dec::DecodableFloat
{
unsafe {
// enough for f32 and f64
let mut buf: [u8; flt2dec::MAX_SIG_DIGITS] = mem::uninitialized();
let mut parts: [flt2dec::Part; 4] = mem::uninitialized();
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest,
*num, sign, 0, false, &mut buf, &mut parts);
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num,
sign, precision, false, &mut buf, &mut parts);
fmt.pad_formatted_parts(&formatted)
}
}
// Common code of floating point Debug and Display.
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T,
negative_zero: bool, min_precision: usize) -> Result
where T: flt2dec::DecodableFloat
{
let force_sign = fmt.sign_plus();
@ -61,7 +62,7 @@ fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool)
if let Some(precision) = fmt.precision {
float_to_decimal_common_exact(fmt, num, sign, precision)
} else {
float_to_decimal_common_shortest(fmt, num, sign)
float_to_decimal_common_shortest(fmt, num, sign, min_precision)
}
}
@ -125,14 +126,14 @@ macro_rules! floating {
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
float_to_decimal_common(fmt, self, true)
float_to_decimal_common(fmt, self, true, 1)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
float_to_decimal_common(fmt, self, false)
float_to_decimal_common(fmt, self, false, 0)
}
}

View file

@ -400,7 +400,7 @@ impl<T> SliceExt for [T] {
while size > 1 {
let half = size / 2;
let mid = base + half;
// mid is always in [0, size).
// mid is always in [0, size), that means mid is >= 0 and < size.
// mid >= 0: by definition
// mid < size: mid = size / 2 + size / 4 + size / 8 ...
let cmp = f(unsafe { s.get_unchecked(mid) });

View file

@ -20,6 +20,8 @@ fn test_format_f64() {
assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64));
assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64));
assert_eq!("1.23456789E3", format!("{:E}", 1234.56789f64));
assert_eq!("0.0", format!("{:?}", 0.0f64));
assert_eq!("1.01", format!("{:?}", 1.01f64));
}
#[test]
@ -34,4 +36,6 @@ fn test_format_f32() {
assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32));
assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32));
assert_eq!("1.2345679E3", format!("{:E}", 1234.56789f32));
assert_eq!("0.0", format!("{:?}", 0.0f32));
assert_eq!("1.01", format!("{:?}", 1.01f32));
}

@ -1 +1 @@
Subproject commit 1a2f9639f8d293cefbe050053a574decbfe863f7
Subproject commit ef9eefb6df3f3a2cb989e8050519661faa7d7118

View file

@ -408,15 +408,16 @@ impl<'a> State<'a> {
hir::TyTraitObject(ref bounds, ref lifetime) => {
let mut first = true;
for bound in bounds {
self.nbsp()?;
if first {
first = false;
} else {
self.nbsp()?;
self.word_space("+")?;
}
self.print_poly_trait_ref(bound)?;
}
if !lifetime.is_elided() {
self.nbsp()?;
self.word_space("+")?;
self.print_lifetime(lifetime)?;
}
@ -764,7 +765,8 @@ impl<'a> State<'a> {
real_bounds.push(b.clone());
}
}
self.print_bounds(" = ", &real_bounds[..])?;
self.nbsp()?;
self.print_bounds("=", &real_bounds[..])?;
self.print_where_clause(&generics.where_clause)?;
self.s.word(";")?;
}
@ -788,6 +790,7 @@ impl<'a> State<'a> {
comma = true;
}
self.s.word(">")?;
self.nbsp()?;
}
Ok(())
}
@ -2016,30 +2019,29 @@ impl<'a> State<'a> {
self.s.word(prefix)?;
let mut first = true;
for bound in bounds {
self.nbsp()?;
if !(first && prefix.is_empty()) {
self.nbsp()?;
}
if first {
first = false;
} else {
self.word_space("+")?;
}
match *bound {
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
self.print_poly_trait_ref(tref)
match bound {
TraitTyParamBound(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
self.print_poly_trait_ref(tref)?;
}
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
self.s.word("?")?;
self.print_poly_trait_ref(tref)
RegionTyParamBound(lt) => {
self.print_lifetime(lt)?;
}
RegionTyParamBound(ref lt) => {
self.print_lifetime(lt)
}
}?
}
}
Ok(())
} else {
Ok(())
}
Ok(())
}
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {

View file

@ -376,7 +376,7 @@ macro_rules! make_mir_visitor {
ref $($mutability)* inputs,
asm: _ } => {
for output in & $($mutability)* outputs[..] {
self.visit_place(output, PlaceContext::Store, location);
self.visit_place(output, PlaceContext::AsmOutput, location);
}
for input in & $($mutability)* inputs[..] {
self.visit_operand(input, location);
@ -835,6 +835,11 @@ pub enum PlaceContext<'tcx> {
// Appears as LHS of an assignment
Store,
// Can often be treated as a Store, but needs to be separate because
// ASM is allowed to read outputs as well, so a Store-AsmOutput sequence
// cannot be simplified the way a Store-Store can be.
AsmOutput,
// Dest of a call
Call,
@ -910,7 +915,7 @@ impl<'tcx> PlaceContext<'tcx> {
/// Returns true if this place context represents a use that potentially changes the value.
pub fn is_mutating_use(&self) -> bool {
match *self {
PlaceContext::Store | PlaceContext::Call |
PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call |
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } |
PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop => true,
@ -932,6 +937,7 @@ impl<'tcx> PlaceContext<'tcx> {
PlaceContext::Projection(Mutability::Not) |
PlaceContext::Copy | PlaceContext::Move => true,
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead |
PlaceContext::Validate => false,

View file

@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"set the threshold for inlining a function (default: 225)"),
panic: Option<PanicStrategy> = (None, parse_panic_strategy,
[TRACKED], "panic strategy to compile crate with"),
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation"),
}
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
}
if cg.lto && debugging_opts.incremental.is_some() {
let incremental = match (&debugging_opts.incremental, &cg.incremental) {
(&Some(ref path1), &Some(ref path2)) => {
if path1 != path2 {
early_error(error_format,
&format!("conflicting paths for `-Z incremental` and \
`-C incremental` specified: {} versus {}",
path1,
path2));
} else {
Some(path1)
}
}
(&Some(ref path), &None) => Some(path),
(&None, &Some(ref path)) => Some(path),
(&None, &None) => None,
}.map(|m| PathBuf::from(m));
if cg.lto && incremental.is_some() {
early_error(error_format, "can't perform LTO when compiling incrementally");
}
@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
let crate_name = matches.opt_str("crate-name");
let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
(Options {
crate_types,
optimize: opt_level,
@ -2581,6 +2598,9 @@ mod tests {
opts.cg.save_temps = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.cg.incremental = Some(String::from("abc"));
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
// Make sure changing a [TRACKED] option changes the hash
opts = reference.clone();

View file

@ -540,6 +540,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
// "deep" does validation go?
PlaceContext::Validate => false,
// FIXME: This is here to not change behaviour from before
// AsmOutput existed, but it's not necessarily a pure overwrite.
// so it's possible this should activate the place.
PlaceContext::AsmOutput |
// pure overwrites of an place do not activate it. (note
// PlaceContext::Call is solely about dest place)
PlaceContext::Store | PlaceContext::Call => false,

View file

@ -173,6 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
ty::TyAdt(adt, _) => {
if adt.is_union() {
if context == PlaceContext::Store ||
context == PlaceContext::AsmOutput ||
context == PlaceContext::Drop
{
let elem_ty = match elem {

View file

@ -103,6 +103,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
if *temp == TempState::Undefined {
match context {
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call => {
*temp = TempState::Defined {
location,

View file

@ -273,6 +273,9 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor {
PlaceContext::Store |
// This is potentially both a def and a use...
PlaceContext::AsmOutput |
// We let Call define the result in both the success and
// unwind cases. This is not really correct, however it
// does not seem to be observable due to the way that we

View file

@ -1024,7 +1024,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
assert_symbols_are_distinct(tcx, items.iter());
let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() {
let strategy = if tcx.sess.opts.incremental.is_some() {
PartitioningStrategy::PerModule
} else {
PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units())

View file

@ -193,6 +193,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
PlaceContext::Inspect |
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Borrow { .. } |
PlaceContext::Projection(..) => {
self.mark_as_memory(index);

View file

@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_id: DefId,
impl_trait_ref: ty::TraitRef<'tcx>,
impl_item_refs: &[hir::ImplItemRef]) {
let impl_span = tcx.sess.codemap().def_span(impl_span);
// If the trait reference itself is erroneous (so the compilation is going
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
// isn't populated for such impls.

View file

@ -129,6 +129,9 @@ pub struct SharedContext {
/// The directories that have already been created in this doc run. Used to reduce the number
/// of spurious `create_dir_all` calls.
pub created_dirs: RefCell<FxHashSet<PathBuf>>,
/// This flag indicates whether listings of modules (in the side bar and documentation itself)
/// should be ordered alphabetically or in order of appearance (in the source code).
pub sort_modules_alphabetically: bool,
}
impl SharedContext {
@ -491,7 +494,8 @@ pub fn run(mut krate: clean::Crate,
passes: FxHashSet<String>,
css_file_extension: Option<PathBuf>,
renderinfo: RenderInfo,
render_type: RenderType) -> Result<(), Error> {
render_type: RenderType,
sort_modules_alphabetically: bool) -> Result<(), Error> {
let src_root = match krate.src {
FileName::Real(ref p) => match p.parent() {
Some(p) => p.to_path_buf(),
@ -514,6 +518,7 @@ pub fn run(mut krate: clean::Crate,
css_file_extension: css_file_extension.clone(),
markdown_warnings: RefCell::new(vec![]),
created_dirs: RefCell::new(FxHashSet()),
sort_modules_alphabetically,
};
// If user passed in `--playground-url` arg, we fill in crate name here
@ -1654,8 +1659,10 @@ impl Context {
.push((myname, Some(plain_summary_line(item.doc_value()))));
}
for (_, items) in &mut map {
items.sort();
if self.shared.sort_modules_alphabetically {
for (_, items) in &mut map {
items.sort();
}
}
map
}
@ -2013,7 +2020,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
name_key(lhs).cmp(&name_key(rhs))
}
indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2));
if cx.shared.sort_modules_alphabetically {
indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2));
}
// This call is to remove reexport duplicates in cases such as:
//
// ```

View file

@ -253,6 +253,10 @@ pub fn opts() -> Vec<RustcOptGroup> {
unstable("linker", |o| {
o.optopt("", "linker", "linker used for building executable test code", "PATH")
}),
unstable("sort-modules-by-appearance", |o| {
o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \
program, rather than alphabetically")
}),
]
}
@ -369,6 +373,7 @@ pub fn main_args(args: &[String]) -> isize {
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
let display_warnings = matches.opt_present("display-warnings");
let linker = matches.opt_str("linker").map(PathBuf::from);
let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
match (should_test, markdown_input) {
(true, true) => {
@ -398,7 +403,8 @@ pub fn main_args(args: &[String]) -> isize {
passes.into_iter().collect(),
css_file_extension,
renderinfo,
render_type)
render_type,
sort_modules_alphabetically)
.expect("failed to generate documentation");
0
}

View file

@ -1451,6 +1451,9 @@ mod tests {
// two double colons
let none: Option<Ipv6Addr> = "1:2::6::8".parse().ok();
assert_eq!(None, none);
// `::` indicating zero groups of zeros
let none: Option<Ipv6Addr> = "1:2:3:4::5:6:7:8".parse().ok();
assert_eq!(None, none);
}
#[test]

View file

@ -246,7 +246,9 @@ impl<'a> Parser<'a> {
}
let mut tail = [0; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
// `::` indicates one or more groups of 16 bits of zeros
let limit = 8 - (head_size + 1);
let (tail_size, _) = read_groups(self, &mut tail, limit);
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
}

View file

@ -22,6 +22,7 @@ use fmt;
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
all(target_os = "openbsd", target_arch = "aarch64"),
all(target_os = "fuchsia", target_arch = "aarch64")))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
@ -32,6 +33,7 @@ use fmt;
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
all(target_os = "openbsd", target_arch = "aarch64"),
all(target_os = "fuchsia", target_arch = "aarch64"))))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;

View file

@ -13,6 +13,7 @@ use fmt;
use sys::{cvt, syscall};
use time::Duration;
use convert::TryInto;
use core::hash::{Hash, Hasher};
const NSEC_PER_SEC: u64 = 1_000_000_000;
@ -110,12 +111,19 @@ impl Ord for Timespec {
}
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
impl Hash for Timespec {
fn hash<H : Hasher>(&self, state: &mut H) {
self.t.tv_sec.hash(state);
self.t.tv_nsec.hash(state);
}
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Instant {
t: Timespec,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime {
t: Timespec,
}

View file

@ -11,6 +11,7 @@
use cmp::Ordering;
use libc;
use time::Duration;
use core::hash::{Hash, Hasher};
pub use self::inner::{Instant, SystemTime, UNIX_EPOCH};
use convert::TryInto;
@ -111,6 +112,13 @@ impl Ord for Timespec {
}
}
impl Hash for Timespec {
fn hash<H : Hasher>(&self, state: &mut H) {
self.t.tv_sec.hash(state);
self.t.tv_nsec.hash(state);
}
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod inner {
use fmt;
@ -123,12 +131,12 @@ mod inner {
use super::NSEC_PER_SEC;
use super::Timespec;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct Instant {
t: u64
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime {
t: Timespec,
}
@ -255,12 +263,12 @@ mod inner {
use super::Timespec;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Instant {
t: Timespec,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime {
t: Timespec,
}

View file

@ -11,10 +11,10 @@
use fmt;
use time::Duration;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct Instant;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime;
pub const UNIX_EPOCH: SystemTime = SystemTime;

View file

@ -17,11 +17,12 @@ use sys::cvt;
use sys_common::mul_div_u64;
use time::Duration;
use convert::TryInto;
use core::hash::{Hash, Hasher};
const NANOS_PER_SEC: u64 = 1_000_000_000;
const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub struct Instant {
t: c::LARGE_INTEGER,
}
@ -173,6 +174,12 @@ impl From<c::FILETIME> for SystemTime {
}
}
impl Hash for SystemTime {
fn hash<H : Hasher>(&self, state: &mut H) {
self.intervals().hash(state)
}
}
fn dur2intervals(d: &Duration) -> i64 {
d.as_secs()
.checked_mul(INTERVALS_PER_SEC)

View file

@ -66,7 +66,7 @@ mod duration;
/// println!("{}", now.elapsed().as_secs());
/// }
/// ```
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[stable(feature = "time2", since = "1.8.0")]
pub struct Instant(time::Instant);
@ -118,7 +118,7 @@ pub struct Instant(time::Instant);
/// }
/// }
/// ```
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[stable(feature = "time2", since = "1.8.0")]
pub struct SystemTime(time::SystemTime);

View file

@ -1553,7 +1553,7 @@ impl<'a> Parser<'a> {
if self.eat(&token::Not) {
// Macro invocation in type position
let (_, tts) = self.expect_delimited_token_tree()?;
TyKind::Mac(respan(lo.to(self.span), Mac_ { path: path, tts: tts }))
TyKind::Mac(respan(lo.to(self.prev_span), Mac_ { path: path, tts: tts }))
} else {
// Just a type path or bound list (trait object type) starting with a trait.
// `Type`

View file

@ -1066,11 +1066,11 @@ impl<'a> State<'a> {
self.print_qpath(path, qself, false)?
}
ast::TyKind::TraitObject(ref bounds, syntax) => {
let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn " } else { "" };
let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn" } else { "" };
self.print_bounds(prefix, &bounds[..])?;
}
ast::TyKind::ImplTrait(ref bounds) => {
self.print_bounds("impl ", &bounds[..])?;
self.print_bounds("impl", &bounds[..])?;
}
ast::TyKind::Array(ref ty, ref v) => {
self.s.word("[")?;
@ -1398,7 +1398,8 @@ impl<'a> State<'a> {
real_bounds.push(b.clone());
}
}
self.print_bounds(" = ", &real_bounds[..])?;
self.nbsp()?;
self.print_bounds("=", &real_bounds[..])?;
self.print_where_clause(&generics.where_clause)?;
self.s.word(";")?;
}
@ -1444,6 +1445,7 @@ impl<'a> State<'a> {
comma = true;
}
self.s.word(">")?;
self.nbsp()?;
}
Ok(())
}
@ -2818,30 +2820,29 @@ impl<'a> State<'a> {
self.s.word(prefix)?;
let mut first = true;
for bound in bounds {
self.nbsp()?;
if !(first && prefix.is_empty()) {
self.nbsp()?;
}
if first {
first = false;
} else {
self.word_space("+")?;
}
(match *bound {
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
self.print_poly_trait_ref(tref)
match bound {
TraitTyParamBound(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
self.print_poly_trait_ref(tref)?;
}
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
self.s.word("?")?;
self.print_poly_trait_ref(tref)
RegionTyParamBound(lt) => {
self.print_lifetime(lt)?;
}
RegionTyParamBound(ref lt) => {
self.print_lifetime(lt)
}
})?
}
}
Ok(())
} else {
Ok(())
}
Ok(())
}
pub fn print_lifetime(&mut self,

View file

@ -14,9 +14,9 @@ fn main() {
let _: Box<((Copy)) + Copy>;
//~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))`
let _: Box<(Copy + Copy) + Copy>;
//~^ ERROR expected a path on the left-hand side of `+`, not `( Copy + Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)`
let _: Box<(Copy +) + Copy>;
//~^ ERROR expected a path on the left-hand side of `+`, not `( Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)`
let _: Box<(dyn Copy) + Copy>;
//~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)`
//~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)`
}

View file

@ -12,7 +12,7 @@ trait Trait<'a> {}
fn main() {
let _: &for<'a> Trait<'a> + 'static;
//~^ ERROR expected a path on the left-hand side of `+`, not `& for<'a>Trait<'a>`
//~^ ERROR expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>`
//~| HELP try adding parentheses
//~| SUGGESTION &( for<'a>Trait<'a> + 'static)
//~| SUGGESTION &(for<'a> Trait<'a> + 'static)
}

View file

@ -17,7 +17,7 @@ fn call_it(f: Box<FnMut(String) -> String>) { }
fn call_this<F>(f: F) where F: Fn(&str) + Send { }
fn call_that<F>(f: F) where F: for<'a>Fn(&'a isize, &'a isize) -> isize { }
fn call_that<F>(f: F) where F: for<'a> Fn(&'a isize, &'a isize) -> isize { }
fn call_extern(f: fn() -> isize) { }

View file

@ -16,10 +16,10 @@ trait Tr {
}
impl Tr for isize { }
fn foo<'a>(x: Box< Tr + Sync + 'a>) -> Box< Tr + Sync + 'a> { x }
fn foo<'a>(x: Box<Tr + Sync + 'a>) -> Box<Tr + Sync + 'a> { x }
fn main() {
let x: Box< Tr + Sync>;
let x: Box<Tr + Sync>;
Box::new(1isize) as Box< Tr + Sync>;
Box::new(1isize) as Box<Tr + Sync>;
}

View file

@ -158,8 +158,8 @@ pub fn main() {
// Float edge cases
t!(format!("{}", -0.0), "0");
t!(format!("{:?}", -0.0), "-0");
t!(format!("{:?}", 0.0), "0");
t!(format!("{:?}", -0.0), "-0.0");
t!(format!("{:?}", 0.0), "0.0");
// sign aware zero padding
t!(format!("{:<3}", 1), "1 ");

View file

@ -0,0 +1,32 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name = "foo"]
#[doc(hidden)]
pub trait Foo {}
trait Dark {}
pub trait Bam {}
pub struct Bar;
struct Hidden;
// @!has foo/struct.Bar.html '//*[@id="impl-Foo"]' 'impl Foo for Bar'
impl Foo for Bar {}
// @!has foo/struct.Bar.html '//*[@id="impl-Dark"]' 'impl Dark for Bar'
impl Dark for Bar {}
// @has foo/struct.Bar.html '//*[@id="impl-Bam"]' 'impl Bam for Bar'
// @has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar'
impl Bam for Bar {}
// @!has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden'
impl Bam for Hidden {}

View file

@ -0,0 +1,23 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests the rustdoc --sort-modules-by-appearance option, that allows module declarations to appear
// in the order they are declared in the source code, rather than only alphabetically.
// compile-flags: -Z unstable-options --sort-modules-by-appearance
pub mod module_b {}
pub mod module_c {}
pub mod module_a {}
// @matches 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a'
// @matches 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"'

View file

@ -27,7 +27,7 @@ error[E0046]: not all trait items implemented, missing: `fmt`
--> $DIR/trait_type.rs:31:1
|
31 | impl std::fmt::Display for MyType4 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`

View file

@ -1,9 +1,8 @@
error: `derive` cannot be used on items with type macros
--> $DIR/issue-32950.rs:15:5
|
15 | / concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
16 | | );
| |_^
15 | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -3,9 +3,8 @@ error[E0601]: main function not found
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
--> $DIR/m2.rs:19:1
|
19 | / impl m1::X for X { //~ ERROR not all trait items implemented
20 | | }
| |_^ missing `CONSTANT`, `Type`, `method` in implementation
19 | impl m1::X for X { //~ ERROR not all trait items implemented
| ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method` in implementation
|
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
= note: `Type` from trait: `type Type;`

View file

@ -5,7 +5,7 @@ error[E0046]: not all trait items implemented, missing: `foo`
| --------- `foo` from trait
...
17 | impl Foo for Bar {}
| ^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
error: aborting due to previous error

View file

@ -16,16 +16,11 @@ error[E0323]: item `bar` is an associated const, which doesn't match its trait `
error[E0046]: not all trait items implemented, missing: `bar`
--> $DIR/impl-wrong-item-for-trait.rs:21:1
|
15 | fn bar(&self);
| -------------- `bar` from trait
15 | fn bar(&self);
| -------------- `bar` from trait
...
21 | / impl Foo for FooConstForMethod {
22 | | //~^ ERROR E0046
23 | | const bar: u64 = 1;
24 | | //~^ ERROR E0323
25 | | const MY_CONST: u32 = 1;
26 | | }
| |_^ missing `bar` in implementation
21 | impl Foo for FooConstForMethod {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
--> $DIR/impl-wrong-item-for-trait.rs:33:5
@ -39,16 +34,11 @@ error[E0324]: item `MY_CONST` is an associated method, which doesn't match its t
error[E0046]: not all trait items implemented, missing: `MY_CONST`
--> $DIR/impl-wrong-item-for-trait.rs:30:1
|
16 | const MY_CONST: u32;
| -------------------- `MY_CONST` from trait
16 | const MY_CONST: u32;
| -------------------- `MY_CONST` from trait
...
30 | / impl Foo for FooMethodForConst {
31 | | //~^ ERROR E0046
32 | | fn bar(&self) {}
33 | | fn MY_CONST() {}
34 | | //~^ ERROR E0324
35 | | }
| |_^ missing `MY_CONST` in implementation
30 | impl Foo for FooMethodForConst {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `MY_CONST` in implementation
error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
--> $DIR/impl-wrong-item-for-trait.rs:41:5
@ -62,24 +52,17 @@ error[E0325]: item `bar` is an associated type, which doesn't match its trait `F
error[E0046]: not all trait items implemented, missing: `bar`
--> $DIR/impl-wrong-item-for-trait.rs:39:1
|
15 | fn bar(&self);
| -------------- `bar` from trait
15 | fn bar(&self);
| -------------- `bar` from trait
...
39 | / impl Foo for FooTypeForMethod {
40 | | //~^ ERROR E0046
41 | | type bar = u64;
42 | | //~^ ERROR E0325
43 | | //~| ERROR E0437
44 | | const MY_CONST: u32 = 1;
45 | | }
| |_^ missing `bar` in implementation
39 | impl Foo for FooTypeForMethod {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation
error[E0046]: not all trait items implemented, missing: `fmt`
--> $DIR/impl-wrong-item-for-trait.rs:47:1
|
47 | / impl Debug for FooTypeForMethod {
48 | | }
| |_^ missing `fmt` in implementation
47 | impl Debug for FooTypeForMethod {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`

View file

@ -1,14 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Item`
--> $DIR/issue-23729.rs:20:9
|
20 | / impl Iterator for Recurrence {
21 | | //~^ ERROR E0046
22 | | #[inline]
23 | | fn next(&mut self) -> Option<u64> {
... |
34 | | }
35 | | }
| |_________^ missing `Item` in implementation
20 | impl Iterator for Recurrence {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation
|
= note: `Item` from trait: `type Item;`

View file

@ -1,13 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Output`
--> $DIR/issue-23827.rs:36:1
|
36 | / impl<C: Component> FnOnce<(C,)> for Prototype {
37 | | //~^ ERROR E0046
38 | | extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
39 | | Fn::call(&self, (comp,))
40 | | }
41 | | }
| |_^ missing `Output` in implementation
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation
|
= note: `Output` from trait: `type Output;`

View file

@ -1,11 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Target`
--> $DIR/issue-24356.rs:30:9
|
30 | / impl Deref for Thing {
31 | | //~^ ERROR E0046
32 | | fn deref(&self) -> i8 { self.0 }
33 | | }
| |_________^ missing `Target` in implementation
30 | impl Deref for Thing {
| ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation
|
= note: `Target` from trait: `type Target;`

View file

@ -1506,7 +1506,7 @@ impl<'test> TestCx<'test> {
if let Some(ref incremental_dir) = self.props.incremental_dir {
rustc.args(&[
"-Z",
"-C",
&format!("incremental={}", incremental_dir.display()),
]);
rustc.args(&["-Z", "incremental-verify-ich"]);