Skip to content

Commit

Permalink
Auto merge of #43181 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

- Successful merges: #42670, #42826, #43000, #43011, #43098, #43100, #43136, #43137
- Failed merges:
  • Loading branch information
bors committed Jul 12, 2017
2 parents b2b19ec + 388fce9 commit f85579d
Show file tree
Hide file tree
Showing 34 changed files with 338 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,14 +726,14 @@ impl<T: Clone> Clone for Box<[T]> {
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "box_borrow", since = "1.1.0")]
impl<T: ?Sized> borrow::Borrow<T> for Box<T> {
fn borrow(&self) -> &T {
&**self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "box_borrow", since = "1.1.0")]
impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
fn borrow_mut(&mut self) -> &mut T {
&mut **self
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Ref<'b, U>> for Ref<'b, T> {}

#[stable(feature = "std_guard_impls", since = "1.20")]
#[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for Ref<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.value.fmt(f)
Expand Down Expand Up @@ -1041,7 +1041,7 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> {
#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {}

#[stable(feature = "std_guard_impls", since = "1.20")]
#[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.value.fmt(f)
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl From<u8> for char {


/// An error which can be returned when parsing a char.
#[stable(feature = "char_from_str", since = "1.19.0")]
#[stable(feature = "char_from_str", since = "1.20.0")]
#[derive(Clone, Debug)]
pub struct ParseCharError {
kind: CharErrorKind,
Expand All @@ -237,15 +237,15 @@ enum CharErrorKind {
TooManyChars,
}

#[stable(feature = "char_from_str", since = "1.19.0")]
#[stable(feature = "char_from_str", since = "1.20.0")]
impl fmt::Display for ParseCharError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.__description().fmt(f)
}
}


#[stable(feature = "char_from_str", since = "1.19.0")]
#[stable(feature = "char_from_str", since = "1.20.0")]
impl FromStr for char {
type Err = ParseCharError;

Expand Down
9 changes: 7 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,13 +1627,13 @@ macro_rules! tuple {
() => ();
( $($name:ident,)+ ) => (
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($name:Debug),*> Debug for ($($name,)*) {
impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized {
#[allow(non_snake_case, unused_assignments, deprecated)]
fn fmt(&self, f: &mut Formatter) -> Result {
let mut builder = f.debug_tuple("");
let ($(ref $name,)*) = *self;
$(
builder.field($name);
builder.field(&$name);
)*

builder.finish()
Expand All @@ -1643,6 +1643,11 @@ macro_rules! tuple {
)
}

macro_rules! last_type {
($a:ident,) => { $a };
($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) };
}

tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
7 changes: 6 additions & 1 deletion src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ mod impls {

( $($name:ident)+) => (
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($name: Hash),*> Hash for ($($name,)*) {
impl<$($name: Hash),*> Hash for ($($name,)*) where last_type!($($name,)+): ?Sized {
#[allow(non_snake_case)]
fn hash<S: Hasher>(&self, state: &mut S) {
let ($(ref $name,)*) = *self;
Expand All @@ -569,6 +569,11 @@ mod impls {
);
}

macro_rules! last_type {
($a:ident,) => { $a };
($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) };
}

impl_hash_tuple! {}
impl_hash_tuple! { A }
impl_hash_tuple! { A B }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ macro_rules! writeln {
///
/// # Panics
///
/// This will always panic.
/// This will always [panic!](macro.panic.html)
///
/// # Examples
///
Expand Down
14 changes: 10 additions & 4 deletions src/libcore/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ macro_rules! tuple_impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
impl<$($T:PartialEq),+> PartialEq for ($($T,)+) where last_type!($($T,)+): ?Sized {
#[inline]
fn eq(&self, other: &($($T,)+)) -> bool {
$(self.$idx == other.$idx)&&+
Expand All @@ -41,10 +41,11 @@ macro_rules! tuple_impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T:Eq),+> Eq for ($($T,)+) {}
impl<$($T:Eq),+> Eq for ($($T,)+) where last_type!($($T,)+): ?Sized {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+)
where last_type!($($T,)+): ?Sized {
#[inline]
fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
lexical_partial_cmp!($(self.$idx, other.$idx),+)
Expand All @@ -68,7 +69,7 @@ macro_rules! tuple_impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T:Ord),+> Ord for ($($T,)+) {
impl<$($T:Ord),+> Ord for ($($T,)+) where last_type!($($T,)+): ?Sized {
#[inline]
fn cmp(&self, other: &($($T,)+)) -> Ordering {
lexical_cmp!($(self.$idx, other.$idx),+)
Expand Down Expand Up @@ -118,6 +119,11 @@ macro_rules! lexical_cmp {
($a:expr, $b:expr) => { ($a).cmp(&$b) };
}

macro_rules! last_type {
($a:ident,) => { $a };
($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) };
}

tuple_impls! {
Tuple1 {
(0) -> A
Expand Down
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl Literal {
Literal(token::Literal(token::Lit::Integer(Symbol::intern(&n.to_string())), None))
}

int_literals!(u8, i8, u16, i16, u32, i32, u64, i64);
int_literals!(u8, i8, u16, i16, u32, i32, u64, i64, usize, isize);
fn typed_integer(n: i128, kind: &'static str) -> Literal {
Literal(token::Literal(token::Lit::Integer(Symbol::intern(&n.to_string())),
Some(Symbol::intern(kind))))
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
let exp_path = self.tcx.item_path_str(did1);
let found_path = self.tcx.item_path_str(did2);
let exp_abs_path = self.tcx.absolute_item_path_str(did1);
let found_abs_path = self.tcx.absolute_item_path_str(did2);
// We compare strings because DefPath can be different
// for imported and non-imported crates
if exp_path == found_path {
if exp_path == found_path
|| exp_abs_path == found_abs_path {
let crate_name = self.tcx.sess.cstore.crate_name(did1.krate);
err.span_note(sp, &format!("Perhaps two different versions \
of crate `{}` are being used?",
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
.filter(|a| a.check_name("rustc_on_unimplemented"))
.next()
{
let name = self.tcx.item_name(def_id).as_str();
let err_sp = item.span.substitute_dummy(span);
let trait_str = self.tcx.item_path_str(trait_ref.def_id);
if let Some(istring) = item.value_str() {
Expand All @@ -347,6 +348,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
Piece::NextArgument(a) => match a.position {
Position::ArgumentNamed(s) => match generic_map.get(s) {
Some(val) => Some(val),
None if s == name => {
Some(&trait_str)
}
None => {
span_err!(self.tcx.sess, err_sp, E0272,
"the #[rustc_on_unimplemented] attribute on trait \
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}) {
if let Some(istring) = attr.value_str() {
let istring = istring.as_str();
let name = tcx.item_name(def_id).as_str();
let parser = Parser::new(&istring);
let types = &generics.types;
for token in parser {
Expand All @@ -1175,13 +1176,14 @@ fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Piece::NextArgument(a) => match a.position {
// `{Self}` is allowed
Position::ArgumentNamed(s) if s == "Self" => (),
// `{ThisTraitsName}` is allowed
Position::ArgumentNamed(s) if s == name => (),
// So is `{A}` if A is a type parameter
Position::ArgumentNamed(s) => match types.iter().find(|t| {
t.name == s
}) {
Some(_) => (),
None => {
let name = tcx.item_name(def_id);
span_err!(tcx.sess, attr.span, E0230,
"there is no type parameter \
{} on trait {}",
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl Error for char::CharTryFromError {
}
}

#[stable(feature = "char_from_str", since = "1.19.0")]
#[stable(feature = "char_from_str", since = "1.20.0")]
impl Error for char::ParseCharError {
fn description(&self) -> &str {
self.__description()
Expand Down
6 changes: 5 additions & 1 deletion src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ impl<R: Seek> Seek for BufReader<R> {
/// `BufWriter` keeps an in-memory buffer of data and writes it to an underlying
/// writer in large, infrequent batches.
///
/// The buffer will be written out when the writer is dropped.
/// When the `BufWriter` is dropped, the contents of its buffer will be written
/// out. However, any errors that happen in the process of flushing the buffer
/// when the writer is dropped will be ignored. Code that wishes to handle such
/// errors must manually call [`flush`] before the writer is dropped.
///
/// # Examples
///
Expand Down Expand Up @@ -316,6 +319,7 @@ impl<R: Seek> Seek for BufReader<R> {
/// [`Write`]: ../../std/io/trait.Write.html
/// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
/// [`flush`]: #method.flush
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BufWriter<W: Write> {
inner: Option<W>,
Expand Down
5 changes: 5 additions & 0 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
/// The multi-argument form of this macro panics with a string and has the
/// `format!` syntax for building a string.
///
/// # Current implementation
///
/// If the main thread panics it will terminate all your threads and end your
/// program with code `101`.
///
/// # Examples
///
/// ```should_panic
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
}
}

#[stable(feature = "std_guard_impls", since = "1.20")]
#[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> {
}
}

#[stable(feature = "std_guard_impls", since = "1.20")]
#[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
Expand All @@ -386,7 +386,7 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> {
}
}

#[stable(feature = "std_guard_impls", since = "1.20")]
#[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockWriteGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
Expand Down
15 changes: 15 additions & 0 deletions src/libstd/sys/redox/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ pub trait MetadataExt {
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn mode(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn nlink(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn uid(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn gid(&self) -> u32;
Expand All @@ -194,6 +196,10 @@ pub trait MetadataExt {
fn ctime(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn ctime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn blksize(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn blocks(&self) -> u64;
}

#[stable(feature = "metadata_ext", since = "1.1.0")]
Expand All @@ -207,6 +213,9 @@ impl MetadataExt for fs::Metadata {
fn mode(&self) -> u32 {
self.as_inner().as_inner().st_mode as u32
}
fn nlink(&self) -> u64 {
self.as_inner().as_inner().st_nlink as u64
}
fn uid(&self) -> u32 {
self.as_inner().as_inner().st_uid as u32
}
Expand Down Expand Up @@ -234,6 +243,12 @@ impl MetadataExt for fs::Metadata {
fn ctime_nsec(&self) -> i64 {
self.as_inner().as_inner().st_ctime_nsec as i64
}
fn blksize(&self) -> u64 {
self.as_inner().as_inner().st_blksize as u64
}
fn blocks(&self) -> u64 {
self.as_inner().as_inner().st_blocks as u64
}
}

/// Add special Redox types (block/char device, fifo and socket)
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/redox/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ impl FilePermissions {
impl FileType {
pub fn is_dir(&self) -> bool { self.is(syscall::MODE_DIR) }
pub fn is_file(&self) -> bool { self.is(syscall::MODE_FILE) }
pub fn is_symlink(&self) -> bool { false /*FIXME: Implement symlink mode*/ }
pub fn is_symlink(&self) -> bool { self.is(syscall::MODE_SYMLINK) }

pub fn is(&self, mode: u16) -> bool {
self.mode & (syscall::MODE_DIR | syscall::MODE_FILE) == mode
self.mode & syscall::MODE_TYPE == mode
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd_unicode/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use tables::{conversions, derived_property, general_category, property};
pub use core::char::{MAX, from_digit, from_u32, from_u32_unchecked};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode};
#[stable(feature = "char_from_str", since = "1.19.0")]
#[stable(feature = "char_from_str", since = "1.20.0")]
pub use core::char::ParseCharError;

// unstable reexports
Expand Down
19 changes: 19 additions & 0 deletions src/test/run-make/type-mismatch-same-crate-name/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-include ../tools.mk

all:
# compile two different versions of crateA
$(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1
$(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2
# make crateB depend on version 1 of crateA
$(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib
# make crateC depend on version 2 of crateA
$(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \
tr -d '\r\n' | grep \
"mismatched types.*\
crateB::try_foo(foo2);.*\
expected struct \`crateA::foo::Foo\`, found struct \`crateA::Foo\`.*\
different versions of crate \`crateA\`.*\
mismatched types.*\
crateB::try_bar(bar2);.*\
expected trait \`crateA::bar::Bar\`, found trait \`crateA::Bar\`.*\
different versions of crate \`crateA\`"
Loading

0 comments on commit f85579d

Please sign in to comment.