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

Add tests for issues with the 'E-needtest' label. #40296

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions src/test/codegen/issue-15953.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.

// Test that llvm generates `memcpy` for moving a value
// inside a function and moving an argument.

struct Foo {
x: Vec<i32>,
}

#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn interior(x: Vec<i32>) -> Vec<i32> {
let Foo { x } = Foo { x: x };
x
}

#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn exterior(x: Vec<i32>) -> Vec<i32> {
x
}

fn main() {
let x = interior(Vec::new());
println!("{:?}", x);

let x = exterior(Vec::new());
println!("{:?}", x);
}
29 changes: 29 additions & 0 deletions src/test/compile-fail/issue-18446.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.

// Test that name clashes between the method in an impl for the type
// and the method in the trait when both are in the same scope.

trait T {
fn foo(&self);
}

impl<'a> T + 'a {
fn foo(&self) {}
}

impl T for i32 {
fn foo(&self) {}
}

fn main() {
let x: &T = &0i32;
x.foo(); //~ ERROR multiple applicable items in scope [E0034]
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-22874.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

struct Table {
rows: [[String]],
//~^ ERROR the trait bound `[std::string::String]: std::marker::Sized` is not satisfied [E0277]
}

fn f(table: &Table) -> &[String] {
&table.rows[0]
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/run-pass/issue-18446.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

// Test that methods in trait impls should override default methods.

trait T {
fn foo(&self) -> i32 { 0 }
}

impl<'a> T + 'a {
fn foo(&self) -> i32 { 1 }
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/run-pass/issue-23311.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

// Test that we do not ICE when pattern matching an array against a slice.

#![feature(slice_patterns)]

fn main() {
match "foo".as_bytes() {
b"food" => (),
&[b'f', ..] => (),
_ => ()
}
}