Auto merge of #36491 - Manishearth:rollup, r=Manishearth

Rollup of 9 pull requests

- Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463
- Failed merges: #36444
This commit is contained in:
bors 2016-09-15 06:14:26 -07:00 committed by GitHub
commit dc75933aba
62 changed files with 1397 additions and 975 deletions

View file

@ -22,11 +22,11 @@ use syntax_pos::DUMMY_SP;
fn main() {
let ps = syntax::parse::ParseSess::new();
let mut loader = syntax::ext::base::DummyMacroLoader;
let mut resolver = syntax::ext::base::DummyResolver;
let mut cx = syntax::ext::base::ExtCtxt::new(
&ps, vec![],
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
&mut loader);
&mut resolver);
cx.bt_push(syntax::codemap::ExpnInfo {
call_site: DUMMY_SP,
callee: syntax::codemap::NameAndSpan {

View file

@ -18,7 +18,7 @@ impl Foo for Bar {
fn a() {}
fn b() {}
//~^ ERROR E0407
//~| NOTE not a member of `Foo`
//~| NOTE not a member of trait `Foo`
}
fn main() {

View file

@ -10,11 +10,11 @@
#![feature(associated_consts)]
trait Foo {}
trait Bar {}
impl Foo for i32 {
impl Bar for i32 {
const BAR: bool = true; //~ ERROR E0438
//~| NOTE not a member of trait `Foo`
//~| NOTE not a member of trait `Bar`
}
fn main () {

View file

@ -18,16 +18,12 @@ struct S {
b: u16,
}
#[derive(Clone, Copy)]
union U {
s: S,
c: u32,
}
impl Clone for U {
fn clone(&self) -> Self { *self }
}
impl Copy for U {}
fn main() {
unsafe {
{

View file

@ -12,16 +12,12 @@
#![feature(untagged_unions)]
#[derive(Clone, Copy)]
union U {
a: u8,
b: u64,
}
impl Clone for U {
fn clone(&self) -> Self { *self }
}
impl Copy for U {}
fn main() {
unsafe {
let mut u = U { b: 0 };

View file

@ -0,0 +1,21 @@
// Copyright 2016 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.
// Regression test for #36053. ICE was caused due to obligations
// being added to a special, dedicated fulfillment cx during
// a probe.
use std::iter::once;
fn main() {
once::<&str>("str").fuse().filter(|a: &str| true).count();
//~^ ERROR no method named `count`
//~| ERROR E0281
//~| ERROR E0281
}

View file

@ -0,0 +1,46 @@
// Copyright 2016 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.
mod macros_cant_escape_fns {
fn f() {
macro_rules! m { () => { 3 + 4 } }
}
fn g() -> i32 { m!() } //~ ERROR macro undefined
}
mod macros_cant_escape_mods {
mod f {
macro_rules! m { () => { 3 + 4 } }
}
fn g() -> i32 { m!() } //~ ERROR macro undefined
}
mod macros_can_escape_flattened_mods_test {
#[macro_use]
mod f {
macro_rules! m { () => { 3 + 4 } }
}
fn g() -> i32 { m!() }
}
fn macro_tokens_should_match() {
macro_rules! m { (a) => { 13 } }
m!(a);
}
// should be able to use a bound identifier as a literal in a macro definition:
fn self_macro_parsing() {
macro_rules! foo { (zz) => { 287; } }
fn f(zz: i32) {
foo!(zz);
}
}
fn main() {}

View file

@ -10,16 +10,16 @@
#![feature(untagged_unions)]
#[derive(Clone)]
union U {
a: u8
}
#[derive(Clone)]
union W {
a: String
}
impl Clone for U { fn clone(&self) { panic!(); } }
impl Clone for W { fn clone(&self) { panic!(); } }
impl Copy for U {} // OK
impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type

View file

@ -0,0 +1,41 @@
// Copyright 2016 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.
#![feature(untagged_unions)]
#[derive(Clone)] //~ ERROR the trait bound `U1: std::marker::Copy` is not satisfied
union U1 {
a: u8,
}
#[derive(Clone)]
union U2 {
a: u8, // OK
}
impl Copy for U2 {}
#[derive(Clone, Copy)]
union U3 {
a: u8, // OK
}
#[derive(Clone, Copy)]
union U4<T> {
a: T, // OK
}
#[derive(Clone)]
struct CloneNoCopy;
fn main() {
let u = U4 { a: CloneNoCopy };
let w = u.clone(); //~ ERROR no method named `clone` found for type `U4<CloneNoCopy>`
}

View file

@ -0,0 +1,30 @@
// Copyright 2016 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.
#![feature(untagged_unions)]
#[derive(Eq)] // OK
union U1 {
a: u8,
}
impl PartialEq for U1 { fn eq(&self, rhs: &Self) -> bool { true } }
#[derive(PartialEq)]
struct PartialEqNotEq;
#[derive(Eq)]
union U2 {
a: PartialEqNotEq, //~ ERROR the trait bound `PartialEqNotEq: std::cmp::Eq` is not satisfied
}
impl PartialEq for U2 { fn eq(&self, rhs: &Self) -> bool { true } }
fn main() {}

View file

@ -13,9 +13,7 @@
#![feature(untagged_unions)]
#[derive(
Clone, //~ ERROR this trait cannot be derived for unions
PartialEq, //~ ERROR this trait cannot be derived for unions
Eq, //~ ERROR this trait cannot be derived for unions
PartialOrd, //~ ERROR this trait cannot be derived for unions
Ord, //~ ERROR this trait cannot be derived for unions
Hash, //~ ERROR this trait cannot be derived for unions

View file

@ -25,11 +25,11 @@ use syntax_pos::DUMMY_SP;
fn main() {
let ps = syntax::parse::ParseSess::new();
let mut loader = syntax::ext::base::DummyMacroLoader;
let mut resolver = syntax::ext::base::DummyResolver;
let mut cx = syntax::ext::base::ExtCtxt::new(
&ps, vec![],
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
&mut loader);
&mut resolver);
cx.bt_push(syntax::codemap::ExpnInfo {
call_site: DUMMY_SP,
callee: syntax::codemap::NameAndSpan {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:assertion failed: index < self.len()
// error-pattern:index out of bounds
use std::usize;
use std::mem::size_of;

View file

@ -21,11 +21,11 @@ use syntax_pos::DUMMY_SP;
fn main() {
let ps = syntax::parse::ParseSess::new();
let mut loader = syntax::ext::base::DummyMacroLoader;
let mut resolver = syntax::ext::base::DummyResolver;
let mut cx = syntax::ext::base::ExtCtxt::new(
&ps, vec![],
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
&mut loader);
&mut resolver);
cx.bt_push(syntax::codemap::ExpnInfo {
call_site: DUMMY_SP,
callee: syntax::codemap::NameAndSpan {

View file

@ -22,6 +22,8 @@ pub type F = Option<isize>;
pub type G = usize;
pub type H = &'static str;
pub type I = Box<Fn()>;
pub type I32Iterator = Iterator<Item=i32>;
pub type U32Iterator = Iterator<Item=u32>;
pub fn id_A() -> TypeId { TypeId::of::<A>() }
pub fn id_B() -> TypeId { TypeId::of::<B>() }
@ -34,3 +36,6 @@ pub fn id_H() -> TypeId { TypeId::of::<H>() }
pub fn id_I() -> TypeId { TypeId::of::<I>() }
pub fn foo<T: Any>() -> TypeId { TypeId::of::<T>() }
pub fn id_i32_iterator() -> TypeId { TypeId::of::<I32Iterator>() }
pub fn id_u32_iterator() -> TypeId { TypeId::of::<U32Iterator>() }

View file

@ -22,6 +22,8 @@ pub type F = Option<isize>;
pub type G = usize;
pub type H = &'static str;
pub type I = Box<Fn()>;
pub type I32Iterator = Iterator<Item=i32>;
pub type U32Iterator = Iterator<Item=u32>;
pub fn id_A() -> TypeId { TypeId::of::<A>() }
pub fn id_B() -> TypeId { TypeId::of::<B>() }
@ -34,3 +36,6 @@ pub fn id_H() -> TypeId { TypeId::of::<H>() }
pub fn id_I() -> TypeId { TypeId::of::<I>() }
pub fn foo<T: Any>() -> TypeId { TypeId::of::<T>() }
pub fn id_i32_iterator() -> TypeId { TypeId::of::<I32Iterator>() }
pub fn id_u32_iterator() -> TypeId { TypeId::of::<U32Iterator>() }

View file

@ -0,0 +1,28 @@
// Copyright 2016 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.
// Regression test for #35546. Check that we are able to codegen
// this. Before we had problems because of the drop glue signature
// around dropping a trait object (specifically, when dropping the
// `value` field of `Node<Send>`).
struct Node<T: ?Sized + Send> {
next: Option<Box<Node<Send>>>,
value: T,
}
fn clear(head: &mut Option<Box<Node<Send>>>) {
match head.take() {
Some(node) => *head = node.next,
None => (),
}
}
fn main() {}

View file

@ -0,0 +1,32 @@
// Copyright 2016 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.
// Regression test for #36053. ICE was caused due to obligations being
// added to a special, dedicated fulfillment cx during a
// probe. Problem seems to be related to the particular definition of
// `FusedIterator` in std but I was not able to isolate that into an
// external crate.
#![feature(fused)]
use std::iter::FusedIterator;
struct Thing<'a>(&'a str);
impl<'a> Iterator for Thing<'a> {
type Item = &'a str;
fn next(&mut self) -> Option<&'a str> {
None
}
}
impl<'a> FusedIterator for Thing<'a> {}
fn main() {
Thing("test").fuse().filter(|_| true).count();
}

View file

@ -78,4 +78,13 @@ pub fn main() {
b.hash(&mut s2);
assert_eq!(s1.finish(), s2.finish());
// Check projections
assert_eq!(TypeId::of::<other1::I32Iterator>(), other1::id_i32_iterator());
assert_eq!(TypeId::of::<other1::U32Iterator>(), other1::id_u32_iterator());
assert_eq!(other1::id_i32_iterator(), other2::id_i32_iterator());
assert_eq!(other1::id_u32_iterator(), other2::id_u32_iterator());
assert!(other1::id_i32_iterator() != other1::id_u32_iterator());
assert!(TypeId::of::<other1::I32Iterator>() != TypeId::of::<other1::U32Iterator>());
}

View file

@ -10,14 +10,14 @@
#![feature(untagged_unions)]
#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
struct LARGE_INTEGER_U {
LowPart: u32,
HighPart: u32,
}
#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
union LARGE_INTEGER {
__unnamed__: LARGE_INTEGER_U,
@ -25,9 +25,6 @@ union LARGE_INTEGER {
QuadPart: u64,
}
impl Clone for LARGE_INTEGER_U { fn clone(&self) -> Self { *self } }
impl Clone for LARGE_INTEGER { fn clone(&self) -> Self { *self } }
#[link(name = "rust_test_helpers")]
extern "C" {
fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER;

View file

@ -14,18 +14,34 @@
#[derive(
Copy,
Clone,
Eq,
)]
union U {
a: u8,
b: u16,
}
impl Clone for U {
fn clone(&self) -> Self { *self }
impl PartialEq for U { fn eq(&self, rhs: &Self) -> bool { true } }
#[derive(
Clone,
Copy,
Eq
)]
union W<T> {
a: T,
}
impl<T> PartialEq for W<T> { fn eq(&self, rhs: &Self) -> bool { true } }
fn main() {
let u = U { b: 0 };
let u1 = u;
let u2 = u.clone();
assert!(u1 == u2);
let w = W { a: 0 };
let w1 = w.clone();
assert!(w == w1);
}