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

Fix some E-needstest issues. #45020

Merged
merged 1 commit into from
Oct 8, 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
21 changes: 21 additions & 0 deletions src/test/compile-fail/issue-30355.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.

pub struct X([u8]);

pub static Y: &'static X = {
const Y: &'static [u8] = b"";
&X(*Y)
//~^ ERROR cannot move out
//~^^ ERROR cannot move a
//~^^^ ERROR cannot move a
};

fn main() {}
23 changes: 23 additions & 0 deletions src/test/compile-fail/issue-33241.rs
Original file line number Diff line number Diff line change
@@ -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.

#![feature(rustc_attrs)]

use std::fmt;

// CoerceUnsized is not implemented for tuples. You can still create
// an unsized tuple by transmuting a trait object.
fn any<T>() -> T { unreachable!() }

#[rustc_error]
fn main() { //~ ERROR compilation successful
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you, instead of forcing the failure, make a run-pass test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test panics when running, because of the unreachable!().

Do you want me to move it to run-fail?

let t: &(u8, fmt::Debug) = any();
println!("{:?}", &t.1);
}
14 changes: 14 additions & 0 deletions src/test/compile-fail/issue-37887.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

fn main() {
extern crate libc; //~ ERROR use of unstable
use libc::*; //~ ERROR unresolved import
}
34 changes: 34 additions & 0 deletions src/test/compile-fail/issue-44578.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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.

trait Foo {
const AMT: usize;
}

enum Bar<A, B> {
First(A),
Second(B),
}

impl<A: Foo, B: Foo> Foo for Bar<A, B> {
const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ ERROR constant evaluation
}

impl Foo for u8 {
const AMT: usize = 1;
}

impl Foo for u16 {
const AMT: usize = 2;
}

fn main() {
println!("{}", <Bar<u16, u8> as Foo>::AMT);
}
1 change: 1 addition & 0 deletions src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// aux-build:attr-on-trait.rs
// ignore-stage1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only test that fails on my machine (x86_64-unknown-linux-gnu with ./x.py test --stage 1), and because it is in run-pass-fulldeps, running it only in stage 2 doesn't seem a problem, because other tests in this directory are ignored on stage 1.


#![feature(proc_macro)]

Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/issue-36400.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

fn f(x: &mut u32) {}

fn main() {
let x = Box::new(3);
f(&mut *x);
}
10 changes: 10 additions & 0 deletions src/test/ui/issue-36400.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error[E0596]: cannot borrow immutable `Box` content `*x` as mutable
--> $DIR/issue-36400.rs:15:12
|
14 | let x = Box::new(3);
| - consider changing this to `mut x`
15 | f(&mut *x);
| ^^ cannot borrow as mutable

error: aborting due to previous error