Auto merge of #52409 - estebank:move-cfail-ui, r=oli-obk

Move some `compile-fail` tests to `ui`

Re: #44844.
This commit is contained in:
bors 2018-07-17 06:52:20 +00:00
commit 9d6f4e5eea
1137 changed files with 9577 additions and 17 deletions

View file

@ -0,0 +1,19 @@
// Copyright 2014 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() -> isize {
(return 1, return 2)
//~^ ERROR mismatched types
//~| expected type `isize`
//~| found type `(!, !)`
//~| expected isize, found tuple
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-10176.rs:12:5
|
LL | fn f() -> isize {
| ----- expected `isize` because of return type
LL | (return 1, return 2)
| ^^^^^^^^^^^^^^^^^^^^ expected isize, found tuple
|
= note: expected type `isize`
found type `(!, !)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,19 @@
// Copyright 2014 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 Foo(bool);
fn foo(_: usize) -> Foo { Foo(false) }
fn main() {
match Foo(true) {
foo(x) //~ ERROR expected tuple struct/variant, found function `foo`
=> ()
}
}

View file

@ -0,0 +1,9 @@
error[E0532]: expected tuple struct/variant, found function `foo`
--> $DIR/issue-10200.rs:16:9
|
LL | foo(x) //~ ERROR expected tuple struct/variant, found function `foo`
| ^^^ did you mean `Foo`?
error: aborting due to previous error
For more information about this error, try `rustc --explain E0532`.

View file

@ -0,0 +1,14 @@
warning: not reporting region error due to nll
--> $DIR/issue-10291.rs:13:9
|
LL | x //~ ERROR E0312
| ^
error: unsatisfied lifetime constraints
--> $DIR/issue-10291.rs:12:5
|
LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ free region requires that `'x` must outlive `'static`
error: aborting due to previous error

View file

@ -0,0 +1,17 @@
// Copyright 2014 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 test<'x>(x: &'x isize) {
drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
x //~ ERROR E0312
}));
}
fn main() {}

View file

@ -0,0 +1,23 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-10291.rs:13:9
|
LL | x //~ ERROR E0312
| ^
|
note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 12:65...
--> $DIR/issue-10291.rs:12:65
|
LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
| _________________________________________________________________^
LL | | x //~ ERROR E0312
LL | | }));
| |_____^
note: ...but the borrowed content is only valid for the lifetime 'x as defined on the function body at 11:9
--> $DIR/issue-10291.rs:11:9
|
LL | fn test<'x>(x: &'x isize) {
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0312`.

View file

@ -0,0 +1,13 @@
error[E0382]: use of moved value: `x`
--> $DIR/issue-10398.rs:17:14
|
LL | let _a = x;
| - value moved here
LL | drop(x);
| ^ value used here after move
|
= note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,21 @@
// Copyright 2014 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(box_syntax)]
fn main() {
let x: Box<_> = box 1;
let f = move|| {
let _a = x;
drop(x);
//~^ ERROR: use of moved value: `x`
};
f();
}

View file

@ -0,0 +1,13 @@
error[E0382]: use of moved value: `x`
--> $DIR/issue-10398.rs:17:14
|
LL | let _a = x;
| -- value moved here
LL | drop(x);
| ^ value used here after move
|
= note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,15 @@
// Copyright 2014 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() {
let mut a = "a";
a += { "b" };
//~^ ERROR: binary assignment operation `+=` cannot be applied
}

View file

@ -0,0 +1,16 @@
error[E0368]: binary assignment operation `+=` cannot be applied to type `&str`
--> $DIR/issue-10401.rs:13:5
|
LL | a += { "b" };
| -^^^^^^^^^^^
| |
| cannot use `+=` on type `&str`
| `+` can't be used to concatenate two `&str` strings
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
LL | a.to_owned() += { "b" };
| ^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0368`.

View file

@ -0,0 +1,32 @@
// Copyright 2013 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 Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
fn serialize(val : &'self T) -> Vec<u8>; //~ ERROR lifetimes cannot use keyword names
fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names
}
impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
//~^ ERROR lifetimes cannot use keyword names
//~| ERROR missing lifetime specifier
fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR lifetimes cannot use keyword names
vec![1]
}
fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR lifetimes cannot use keyword names
"hi"
}
}
fn main() {
println!("hello");
let x = "foo".to_string();
let y = x;
println!("{}", y);
}

View file

@ -0,0 +1,51 @@
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:11:20
|
LL | trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:12:25
|
LL | fn serialize(val : &'self T) -> Vec<u8>; //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:13:38
|
LL | fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:16:6
|
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:16:36
|
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:19:25
|
LL | fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error: lifetimes cannot use keyword names
--> $DIR/issue-10412.rs:22:37
|
LL | fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR lifetimes cannot use keyword names
| ^^^^^
error[E0106]: missing lifetime specifier
--> $DIR/issue-10412.rs:16:13
|
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
| ^^^^^^^^^^^^^^^^^ expected lifetime parameter
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0106`.

View file

@ -0,0 +1,33 @@
// Copyright 2014 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 mod a {
pub trait A {
fn foo(&self);
}
}
pub mod b {
use a::A;
pub struct B;
impl A for B { fn foo(&self) {} }
pub mod c {
use b::B;
fn foo(b: &B) {
b.foo(); //~ ERROR: no method named `foo` found
}
}
}
fn main() {}

View file

@ -0,0 +1,13 @@
error[E0599]: no method named `foo` found for type `&b::B` in the current scope
--> $DIR/issue-10465.rs:27:15
|
LL | b.foo(); //~ ERROR: no method named `foo` found
| ^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
`use a::A;`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.

View file

@ -0,0 +1,33 @@
// Copyright 2014 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.
// We only want to assert that this doesn't ICE, we don't particularly care
// about whether it nor it fails to compile.
// error-pattern:
macro_rules! foo{
() => {{
macro_rules! bar{() => (())}
1
}}
}
pub fn main() {
foo!();
assert!({one! two()});
//~^ ERROR macros that expand to items must either be surrounded with braces or followed by a
// regardless of whether nested macro_rules works, the following should at
// least throw a conventional error.
assert!({one! two});
//~^ ERROR expected
}

View file

@ -0,0 +1,14 @@
error: macros that expand to items must either be surrounded with braces or followed by a semicolon
--> $DIR/issue-10536.rs:26:22
|
LL | assert!({one! two()});
| ^^
error: expected `(` or `{`, found `}`
--> $DIR/issue-10536.rs:31:22
|
LL | assert!({one! two});
| ^ expected `(` or `{`
error: aborting due to 2 previous errors

View file

@ -0,0 +1,20 @@
// Copyright 2013 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 a {
struct S;
impl S { }
}
fn foo(_: a::S) { //~ ERROR: struct `S` is private
}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0603]: struct `S` is private
--> $DIR/issue-10545.rs:17:11
|
LL | fn foo(_: a::S) { //~ ERROR: struct `S` is private
| ^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0603`.

View file

@ -0,0 +1,13 @@
// Copyright 2013 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.
#![deny(missing_docs)]
#![crate_type="lib"]
//~^^ ERROR missing documentation for crate

View file

@ -0,0 +1,15 @@
error: missing documentation for crate
--> $DIR/issue-10656.rs:11:1
|
LL | / #![deny(missing_docs)]
LL | | #![crate_type="lib"]
| |____________________^
|
note: lint level defined here
--> $DIR/issue-10656.rs:11:9
|
LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,15 @@
// Copyright 2014 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(_: extern "Rust" fn()) {}
extern fn bar() {}
fn main() { f(bar) }
//~^ ERROR mismatched types

View file

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/issue-10764.rs:14:15
|
LL | fn main() { f(bar) }
| ^^^ expected "Rust" fn, found "C" fn
|
= note: expected type `fn()`
found type `extern "C" fn() {bar}`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,24 @@
// Copyright 2014 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 Foo { x: isize }
extern {
fn foo(1: ());
//~^ ERROR: patterns aren't allowed in foreign function declarations
fn bar((): isize);
//~^ ERROR: patterns aren't allowed in foreign function declarations
fn baz(Foo { x }: isize);
//~^ ERROR: patterns aren't allowed in foreign function declarations
fn qux((x,y): ());
//~^ ERROR: patterns aren't allowed in foreign function declarations
fn this_is_actually_ok(a: usize);
fn and_so_is_this(_: usize);
}
fn main() {}

View file

@ -0,0 +1,27 @@
error[E0130]: patterns aren't allowed in foreign function declarations
--> $DIR/issue-10877.rs:13:12
|
LL | fn foo(1: ());
| ^ pattern not allowed in foreign function
error[E0130]: patterns aren't allowed in foreign function declarations
--> $DIR/issue-10877.rs:15:12
|
LL | fn bar((): isize);
| ^^ pattern not allowed in foreign function
error[E0130]: patterns aren't allowed in foreign function declarations
--> $DIR/issue-10877.rs:17:12
|
LL | fn baz(Foo { x }: isize);
| ^^^^^^^^^ pattern not allowed in foreign function
error[E0130]: patterns aren't allowed in foreign function declarations
--> $DIR/issue-10877.rs:19:12
|
LL | fn qux((x,y): ());
| ^^^^^ pattern not allowed in foreign function
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0130`.

View file

@ -0,0 +1,14 @@
// Copyright 2014 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() {
let nil = ();
let _t = nil as usize; //~ ERROR: non-primitive cast: `()` as `usize`
}

View file

@ -0,0 +1,11 @@
error[E0605]: non-primitive cast: `()` as `usize`
--> $DIR/issue-10991.rs:13:14
|
LL | let _t = nil as usize; //~ ERROR: non-primitive cast: `()` as `usize`
| ^^^^^^^^^^^^
|
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0605`.

View file

@ -0,0 +1,15 @@
// Copyright 2013 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.
// compile-flags: -C lto -C prefer-dynamic
// error-pattern: cannot prefer dynamic linking
fn main() {}

View file

@ -0,0 +1,6 @@
error: cannot prefer dynamic linking when performing LTO
note: only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable
--> $DIR/issue-11192.rs:30:10
|
LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here
LL | println!("access {}", foo.x);
LL | ptr = box Foo { x: ptr.x + 1 };
| --- previous borrow occurs due to use of `ptr` in closure
...
LL | test(&*ptr);
| -----^^^^^-
| | |
| | immutable borrow occurs here
| borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0502`.

View file

@ -0,0 +1,32 @@
// Copyright 2014 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(box_syntax)]
struct Foo {
x: isize
}
impl Drop for Foo {
fn drop(&mut self) {
println!("drop {}", self.x);
}
}
fn main() {
let mut ptr: Box<_> = box Foo { x: 0 };
let mut test = |foo: &Foo| {
println!("access {}", foo.x);
ptr = box Foo { x: ptr.x + 1 };
println!("access {}", foo.x);
};
test(&*ptr);
//~^ ERROR: cannot borrow `*ptr` as immutable
}

View file

@ -0,0 +1,18 @@
error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable
--> $DIR/issue-11192.rs:30:11
|
LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here
LL | println!("access {}", foo.x);
LL | ptr = box Foo { x: ptr.x + 1 };
| --- previous borrow occurs due to use of `ptr` in closure
...
LL | test(&*ptr);
| ^^^^ immutable borrow occurs here
LL | //~^ ERROR: cannot borrow `*ptr` as immutable
LL | }
| - mutable borrow ends here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0502`.

View file

@ -0,0 +1,37 @@
// Copyright 2014 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.
use std::io::{self, Read};
use std::vec;
pub struct Container<'a> {
reader: &'a mut Read
}
impl<'a> Container<'a> {
pub fn wrap<'s>(reader: &'s mut io::Read) -> Container<'s> {
Container { reader: reader }
}
pub fn read_to(&mut self, vec: &mut [u8]) {
self.reader.read(vec);
}
}
pub fn for_stdin<'a>() -> Container<'a> {
let mut r = io::stdin();
Container::wrap(&mut r as &mut io::Read)
}
fn main() {
let mut c = for_stdin();
let mut v = Vec::new();
c.read_to(v); //~ ERROR E0308
}

View file

@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/issue-11374.rs:36:15
|
LL | c.read_to(v); //~ ERROR E0308
| ^
| |
| expected &mut [u8], found struct `std::vec::Vec`
| help: consider mutably borrowing here: `&mut v`
|
= note: expected type `&mut [u8]`
found type `std::vec::Vec<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,16 @@
error[E0597]: borrowed value does not live long enough (Ast)
--> $DIR/issue-11493.rs:20:35
|
LL | let y = x.as_ref().unwrap_or(&id(5));
| ^^^^^ - temporary value dropped here while still borrowed
| |
| temporary value does not live long enough
...
LL | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View file

@ -0,0 +1,16 @@
error[E0597]: borrowed value does not live long enough (Ast)
--> $DIR/issue-11493.rs:20:35
|
LL | let y = x.as_ref().unwrap_or(&id(5));
| ^^^^^ - temporary value dropped here while still borrowed
| |
| temporary value does not live long enough
...
LL | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View file

@ -0,0 +1,24 @@
// Copyright 2014 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.
// This file must never have a trailing newline
//
// revisions: ast mir
// compile-flags: -Z borrowck=compare
fn id<T>(x: T) -> T { x }
fn main() {
let x = Some(3);
let y = x.as_ref().unwrap_or(&id(5));
//[ast]~^ ERROR borrowed value does not live long enough (Ast)
//[mir]~^^ ERROR borrowed value does not live long enough (Ast)
// This actually passes in mir
}

View file

@ -0,0 +1,20 @@
// Copyright 2014 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(box_syntax)]
struct Test {
func: Box<FnMut()+'static>
}
fn main() {
let closure: Box<Fn()+'static> = Box::new(|| ());
let test = box Test { func: closure }; //~ ERROR mismatched types
}

View file

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/issue-11515.rs:19:33
|
LL | let test = box Test { func: closure }; //~ ERROR mismatched types
| ^^^^^^^ expected trait `std::ops::FnMut`, found trait `std::ops::Fn`
|
= note: expected type `std::boxed::Box<(dyn std::ops::FnMut() + 'static)>`
found type `std::boxed::Box<(dyn std::ops::Fn() + 'static)>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,29 @@
// Copyright 2014 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.
// This tests verifies that unary structs and enum variants
// are treated as rvalues and their lifetime is not bounded to
// the static scope.
struct Test;
impl Drop for Test {
fn drop (&mut self) {}
}
fn createTest<'a>() -> &'a Test {
let testValue = &Test; //~ ERROR borrowed value does not live long enough
return testValue;
}
pub fn main() {
createTest();
}

View file

@ -0,0 +1,18 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/issue-11681.rs:22:20
|
LL | let testValue = &Test; //~ ERROR borrowed value does not live long enough
| ^^^^ temporary value does not live long enough
LL | return testValue;
LL | }
| - temporary value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:15...
--> $DIR/issue-11681.rs:21:15
|
LL | fn createTest<'a>() -> &'a Test {
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View file

@ -0,0 +1,14 @@
// Copyright 2014 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() {
print!(test!());
//~^ ERROR: format argument must be a string literal
}

View file

@ -0,0 +1,8 @@
error: format argument must be a string literal.
--> $DIR/issue-11692-1.rs:12:12
|
LL | print!(test!());
| ^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,14 @@
// Copyright 2014 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() {
concat!(test!());
//~^ ERROR cannot find macro `test!` in this scope
}

View file

@ -0,0 +1,8 @@
error: cannot find macro `test!` in this scope
--> $DIR/issue-11692-2.rs:12:13
|
LL | concat!(test!());
| ^^^^
error: aborting due to previous error

View file

@ -0,0 +1,38 @@
// 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)]
#![allow(warnings)]
struct Attr {
name: String,
value: String,
}
struct Element {
attrs: Vec<Box<Attr>>,
}
impl Element {
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
self.attrs
.iter()
.find(|attr| {
let attr: &&Box<Attr> = std::mem::transmute(attr);
true
});
}
}
#[rustc_error]
fn main() { //~ ERROR compilation successful
let element = Element { attrs: Vec::new() };
let _ = unsafe { element.get_attr("foo") };
}

View file

@ -0,0 +1,11 @@
error: compilation successful
--> $DIR/issue-11740.rs:35:1
|
LL | / fn main() { //~ ERROR compilation successful
LL | | let element = Element { attrs: Vec::new() };
LL | | let _ = unsafe { element.get_attr("foo") };
LL | | }
| |_^
error: aborting due to previous error

View file

@ -0,0 +1,21 @@
// Copyright 2014 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() {
let x = ();
1 +
x //~^ ERROR E0277
;
let x: () = ();
1 +
x //~^ ERROR E0277
;
}

View file

@ -0,0 +1,19 @@
error[E0277]: cannot add `()` to `{integer}`
--> $DIR/issue-11771.rs:13:7
|
LL | 1 +
| ^ no implementation for `{integer} + ()`
|
= help: the trait `std::ops::Add<()>` is not implemented for `{integer}`
error[E0277]: cannot add `()` to `{integer}`
--> $DIR/issue-11771.rs:18:7
|
LL | 1 +
| ^ no implementation for `{integer} + ()`
|
= help: the trait `std::ops::Add<()>` is not implemented for `{integer}`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,20 @@
// Copyright 2014 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(box_syntax)]
fn main() {
let a = Some(box 1);
match a {
Ok(a) => //~ ERROR: mismatched types
println!("{}",a),
None => panic!()
}
}

View file

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/issue-11844.rs:16:9
|
LL | Ok(a) => //~ ERROR: mismatched types
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<std::boxed::Box<{integer}>>`
found type `std::result::Result<_, _>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,14 @@
error[E0505]: cannot move out of `v` because it is borrowed
--> $DIR/issue-11873.rs:14:14
|
LL | let mut f = || v.push(2);
| ------------ borrow of `v` occurs here
LL | let _w = v; //~ ERROR: cannot move out of `v`
| ^ move out of `v` occurs here
LL |
LL | f();
| - borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0505`.

View file

@ -0,0 +1,17 @@
// Copyright 2012-2014 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() {
let mut v = vec![1];
let mut f = || v.push(2);
let _w = v; //~ ERROR: cannot move out of `v`
f();
}

View file

@ -0,0 +1,11 @@
error[E0505]: cannot move out of `v` because it is borrowed
--> $DIR/issue-11873.rs:14:9
|
LL | let mut f = || v.push(2);
| -- borrow of `v` occurs here
LL | let _w = v; //~ ERROR: cannot move out of `v`
| ^^ move out of `v` occurs here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0505`.

View file

@ -0,0 +1,50 @@
// Copyright 2014 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 an example where we fail to infer the type parameter H. This
// is because there is really nothing constraining it. At one time, we
// would infer based on the where clauses in scope, but that no longer
// works.
trait Hash<H> {
fn hash2(&self, hasher: &H) -> u64;
}
trait Stream {
fn input(&mut self, bytes: &[u8]);
fn result(&self) -> u64;
}
trait StreamHasher {
type S : Stream;
fn stream(&self) -> Self::S;
}
//////////////////////////////////////////////////////////////////////////////
trait StreamHash<H: StreamHasher>: Hash<H> {
fn input_stream(&self, stream: &mut H::S);
}
impl<H: StreamHasher> Hash<H> for u8 {
fn hash2(&self, hasher: &H) -> u64 {
let mut stream = hasher.stream();
self.input_stream(&mut stream); //~ ERROR type annotations required
Stream::result(&stream)
}
}
impl<H: StreamHasher> StreamHash<H> for u8 {
fn input_stream(&self, stream: &mut H::S) {
Stream::input(stream, &[*self]);
}
}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0284]: type annotations required: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
--> $DIR/issue-12028.rs:39:14
|
LL | self.input_stream(&mut stream); //~ ERROR type annotations required
| ^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0284`.

View file

@ -0,0 +1,11 @@
error[E0382]: use of moved value: `tx`
--> $DIR/issue-12041.rs:18:22
|
LL | let tx = tx;
| ^^ value moved here in previous iteration of loop
|
= note: move occurs because `tx` has type `std::sync::mpsc::Sender<i32>`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,23 @@
// Copyright 2014 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.
use std::sync::mpsc::channel;
use std::thread;
fn main() {
let (tx, rx) = channel();
let _t = thread::spawn(move|| -> () {
loop {
let tx = tx;
//~^ ERROR: use of moved value: `tx`
tx.send(1);
}
});
}

View file

@ -0,0 +1,11 @@
error[E0382]: use of moved value: `tx`
--> $DIR/issue-12041.rs:18:17
|
LL | let tx = tx;
| ^^ value moved here in previous iteration of loop
|
= note: move occurs because `tx` has type `std::sync::mpsc::Sender<i32>`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,31 @@
// Copyright 2012-2014 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(box_patterns)]
#![feature(box_syntax)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![deny(unreachable_patterns)]
enum IntList {
Cons(isize, Box<IntList>),
Nil
}
fn tail(source_list: &IntList) -> IntList {
match source_list {
&IntList::Cons(val, box ref next_list) => tail(next_list),
&IntList::Cons(val, box IntList::Nil) => IntList::Cons(val, box IntList::Nil),
//~^ ERROR unreachable pattern
_ => panic!()
}
}
fn main() {}

View file

@ -0,0 +1,14 @@
error: unreachable pattern
--> $DIR/issue-12116.rs:25:9
|
LL | &IntList::Cons(val, box IntList::Nil) => IntList::Cons(val, box IntList::Nil),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/issue-12116.rs:15:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,24 @@
// Copyright 2014 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(box_syntax, unboxed_closures)]
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn do_it(x: &isize) { }
fn main() {
let x: Box<_> = box 22;
let f = to_fn_once(move|| do_it(&*x));
to_fn_once(move|| {
f();
f();
//~^ ERROR: use of moved value: `f`
})()
}

View file

@ -0,0 +1,13 @@
error[E0382]: use of moved value: `f`
--> $DIR/issue-12127.rs:21:9
|
LL | f();
| - value moved here
LL | f();
| ^ value used here after move
|
= note: move occurs because `f` has type `[closure@$DIR/issue-12127.rs:18:24: 18:41 x:std::boxed::Box<isize>]`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,22 @@
// Copyright 2014 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(slice_patterns)]
#![deny(unreachable_patterns)]
fn main() {
let sl = vec![1,2,3];
let v: isize = match &*sl {
&[] => 0,
&[a,b,c] => 3,
&[a, ref rest..] => a,
&[10,a, ref rest..] => 10 //~ ERROR: unreachable pattern
};
}

View file

@ -0,0 +1,14 @@
error: unreachable pattern
--> $DIR/issue-12369.rs:20:9
|
LL | &[10,a, ref rest..] => 10 //~ ERROR: unreachable pattern
| ^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/issue-12369.rs:12:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
error[E0597]: `*b` does not live long enough
--> $DIR/issue-12470.rs:38:18
|
LL | let bb: &B = &*b; //~ ERROR does not live long enough
| ^^^ borrowed value does not live long enough
LL | make_a(bb)
LL | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 36:16...
--> $DIR/issue-12470.rs:36:16
|
LL | fn make_make_a<'a>() -> A<'a> {
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View file

@ -0,0 +1,44 @@
// Copyright 2012-2014 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(box_syntax)]
trait X {
fn get_i(&self) -> isize;
}
struct B {
i: isize
}
impl X for B {
fn get_i(&self) -> isize {
self.i
}
}
struct A<'a> {
p: &'a (X+'a)
}
fn make_a<'a>(p: &'a X) -> A<'a> {
A { p: p }
}
fn make_make_a<'a>() -> A<'a> {
let b: Box<B> = box B {i:1};
let bb: &B = &*b; //~ ERROR does not live long enough
make_a(bb)
}
fn main() {
let _a = make_make_a();
}

View file

@ -0,0 +1,18 @@
error[E0597]: `*b` does not live long enough
--> $DIR/issue-12470.rs:38:19
|
LL | let bb: &B = &*b; //~ ERROR does not live long enough
| ^^ borrowed value does not live long enough
LL | make_a(bb)
LL | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 36:16...
--> $DIR/issue-12470.rs:36:16
|
LL | fn make_make_a<'a>() -> A<'a> {
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View file

@ -0,0 +1,21 @@
// Copyright 2014 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.
// this code used to cause an ICE
fn main() {
let t = Err(0);
match t {
Some(k) => match k { //~ ERROR mismatched types
a => println!("{}", a)
},
None => () //~ ERROR mismatched types
}
}

View file

@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:16:5
|
LL | Some(k) => match k { //~ ERROR mismatched types
| ^^^^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
|
= note: expected type `std::result::Result<_, {integer}>`
found type `std::option::Option<_>`
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:19:5
|
LL | None => () //~ ERROR mismatched types
| ^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
|
= note: expected type `std::result::Result<_, {integer}>`
found type `std::option::Option<_>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,31 @@
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:14:11
|
LL | match (l1, l2) {
| ^^^^^^^^ cannot move out of here
help: to prevent move, use ref or ref mut
|
LL | (&[], &[ref hd, ..]) | (&[hd, ..], &[])
| ^^^^^^
help: to prevent move, use ref or ref mut
|
LL | (&[hd1, ..], &[ref hd2, ..])
| ^^^^^^^
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:14:11
|
LL | match (l1, l2) {
| ^^^^^^^^ cannot move out of here
help: to prevent move, use ref or ref mut
|
LL | (&[], &[ref hd, ..]) | (&[hd, ..], &[])
| ^^^^^^
help: to prevent move, use ref or ref mut
|
LL | (&[ref hd1, ..], &[hd2, ..])
| ^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0508`.

View file

@ -0,0 +1,27 @@
// Copyright 2014 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(slice_patterns)]
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
match (l1, l2) {
(&[], &[]) => println!("both empty"),
(&[], &[hd, ..]) | (&[hd, ..], &[])
=> println!("one empty"),
//~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
(&[hd1, ..], &[hd2, ..])
=> println!("both nonempty"),
//~^^ ERROR: cannot move out of type `[T]`, a non-copy slice
//~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice
}
}
fn main() {}

View file

@ -0,0 +1,39 @@
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:16:16
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^--^^^^^
| ||
| |hint: to prevent move, use `ref hd` or `ref mut hd`
| cannot move out of here
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:16:30
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^--^^^^^
| ||
| |hint: to prevent move, use `ref hd` or `ref mut hd`
| cannot move out of here
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:20:11
|
LL | (&[hd1, ..], &[hd2, ..])
| ^---^^^^^
| ||
| |hint: to prevent move, use `ref hd1` or `ref mut hd1`
| cannot move out of here
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:20:23
|
LL | (&[hd1, ..], &[hd2, ..])
| ^---^^^^^
| ||
| |hint: to prevent move, use `ref hd2` or `ref mut hd2`
| cannot move out of here
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0508`.

View file

@ -0,0 +1,19 @@
// Copyright 2014 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 Trait {
fn outer(&self) {
fn inner(_: &Self) {
//~^ ERROR can't use type parameters from outer function
}
}
}
fn main() { }

View file

@ -0,0 +1,11 @@
error[E0401]: can't use type parameters from outer function
--> $DIR/issue-12796.rs:13:22
|
LL | fn inner(_: &Self) {
| ----- ^^^^ use of type variable from outer function
| |
| help: try using a local type parameter instead: `inner<Self>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0401`.

View file

@ -0,0 +1,17 @@
// Copyright 2014 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 foo { pub fn bar() {} }
fn main() {
match () {
foo::bar => {} //~ ERROR expected unit struct/variant or constant, found function `foo::bar`
}
}

View file

@ -0,0 +1,9 @@
error[E0532]: expected unit struct/variant or constant, found function `foo::bar`
--> $DIR/issue-12863.rs:15:9
|
LL | foo::bar => {} //~ ERROR expected unit struct/variant or constant, found function `foo::bar`
| ^^^^^^^^ not a unit struct/variant or constant
error: aborting due to previous error
For more information about this error, try `rustc --explain E0532`.

View file

@ -0,0 +1,19 @@
// Copyright 2014 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.
// compile-flags: --test
//! Test that makes sure wrongly-typed bench functions aren't ignored
#[bench]
fn foo() { } //~ ERROR functions used as benches
#[bench]
fn bar(x: isize, y: isize) { } //~ ERROR functions used as benches

View file

@ -0,0 +1,14 @@
error: functions used as benches must have signature `fn(&mut Bencher) -> impl Termination`
--> $DIR/issue-12997-1.rs:16:1
|
LL | fn foo() { } //~ ERROR functions used as benches
| ^^^^^^^^^^^^
error: functions used as benches must have signature `fn(&mut Bencher) -> impl Termination`
--> $DIR/issue-12997-1.rs:19:1
|
LL | fn bar(x: isize, y: isize) { } //~ ERROR functions used as benches
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -0,0 +1,17 @@
// Copyright 2014 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.
// compile-flags: --test
//! Test that makes sure wrongly-typed bench functions are rejected
#[bench]
fn bar(x: isize) { }
//~^ ERROR mismatched types

View file

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/issue-12997-2.rs:16:1
|
LL | fn bar(x: isize) { }
| ^^^^^^^^^^^^^^^^^^^^ expected isize, found mutable reference
|
= note: expected type `isize`
found type `&mut __test::test::Bencher`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,24 @@
// Copyright 2014 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 {
fn bar(&mut self, other: &mut Foo);
}
struct Baz;
impl Foo for Baz {
fn bar(&mut self, other: &Foo) {}
//~^ ERROR method `bar` has an incompatible type for trait
//~| expected type `fn(&mut Baz, &mut dyn Foo)`
//~| found type `fn(&mut Baz, &dyn Foo)`
}
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/issue-13033.rs:18:30
|
LL | fn bar(&mut self, other: &mut Foo);
| -------- type in trait
...
LL | fn bar(&mut self, other: &Foo) {}
| ^^^^ types differ in mutability
|
= note: expected type `fn(&mut Baz, &mut dyn Foo)`
found type `fn(&mut Baz, &dyn Foo)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0053`.

View file

@ -0,0 +1,21 @@
// Copyright 2014 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.
// ignore-cloudabi no std::process
fn foo(_: Box<FnMut()>) {}
fn main() {
foo(loop {
std::process::exit(0);
});
2_usize + (loop {});
//~^ ERROR E0277
}

View file

@ -0,0 +1,11 @@
error[E0277]: cannot add `()` to `usize`
--> $DIR/issue-13352.rs:19:13
|
LL | 2_usize + (loop {});
| ^ no implementation for `usize + ()`
|
= help: the trait `std::ops::Add<()>` is not implemented for `usize`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,23 @@
// Copyright 2014 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 foo(_s: i16) { }
fn bar(_s: u32) { }
fn main() {
foo(1*(1 as isize));
//~^ ERROR mismatched types
//~| expected i16, found isize
bar(1*(1 as usize));
//~^ ERROR mismatched types
//~| expected u32, found usize
}

View file

@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/issue-13359.rs:16:9
|
LL | foo(1*(1 as isize));
| ^^^^^^^^^^^^^^ expected i16, found isize
error[E0308]: mismatched types
--> $DIR/issue-13359.rs:20:9
|
LL | bar(1*(1 as usize));
| ^^^^^^^^^^^^^^ expected u32, found usize
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,20 @@
// Copyright 2014 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.
use a::f;
use b::f; //~ ERROR: unresolved import `b::f` [E0432]
//~^ no `f` in `b`
mod a { pub fn f() {} }
mod b { }
fn main() {
f();
}

View file

@ -0,0 +1,9 @@
error[E0432]: unresolved import `b::f`
--> $DIR/issue-13404.rs:12:5
|
LL | use b::f; //~ ERROR: unresolved import `b::f` [E0432]
| ^^^^ no `f` in `b`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.

View file

@ -0,0 +1,20 @@
// Copyright 2015 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 A {
struct C;
}
fn main() {
A::C = 1;
//~^ ERROR: invalid left-hand side expression
//~| ERROR: mismatched types
//~| ERROR: struct `C` is private
}

View file

@ -0,0 +1,25 @@
error[E0603]: unit struct `C` is private
--> $DIR/issue-13407.rs:16:5
|
LL | A::C = 1;
| ^^^^
error[E0308]: mismatched types
--> $DIR/issue-13407.rs:16:12
|
LL | A::C = 1;
| ^ expected struct `A::C`, found integral variable
|
= note: expected type `A::C`
found type `{integer}`
error[E0070]: invalid left-hand side expression
--> $DIR/issue-13407.rs:16:5
|
LL | A::C = 1;
| ^^^^^^^^ left-hand of expression not valid
error: aborting due to 3 previous errors
Some errors occurred: E0070, E0308, E0603.
For more information about an error, try `rustc --explain E0070`.

View file

@ -0,0 +1,18 @@
// Copyright 2014 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.
// Used to cause ICE
// error-pattern: mismatched types
static VEC: [u32; 256] = vec![];
fn main() {}

View file

@ -0,0 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-13446.rs:16:26
|
LL | static VEC: [u32; 256] = vec![];
| ^^^^^^ expected array of 256 elements, found struct `std::vec::Vec`
|
= note: expected type `[u32; 256]`
found type `std::vec::Vec<_>`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,30 @@
// Copyright 2014 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 #13466
pub fn main() {
// The expected arm type `Option<T>` has one type parameter, while
// the actual arm `Result<T, E>` has two. typeck should not be
// tricked into looking up a non-existing second type parameter.
let _x: usize = match Some(1) {
Ok(u) => u,
//~^ ERROR mismatched types
//~| expected type `std::option::Option<{integer}>`
//~| found type `std::result::Result<_, _>`
//~| expected enum `std::option::Option`, found enum `std::result::Result`
Err(e) => panic!(e)
//~^ ERROR mismatched types
//~| expected type `std::option::Option<{integer}>`
//~| found type `std::result::Result<_, _>`
//~| expected enum `std::option::Option`, found enum `std::result::Result`
};
}

View file

@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:18:9
|
LL | Ok(u) => u,
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<{integer}>`
found type `std::result::Result<_, _>`
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:24:9
|
LL | Err(e) => panic!(e)
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<{integer}>`
found type `std::result::Result<_, _>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,19 @@
// Copyright 2014 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.
// compile-flags:-Z verbose
fn main() {
let x = [1,2];
let y = match x {
[] => None, //~ ERROR pattern requires 0 elements but array has 2
[a,_] => Some(a)
};
}

View file

@ -0,0 +1,9 @@
error[E0527]: pattern requires 0 elements but array has 2
--> $DIR/issue-13482-2.rs:16:9
|
LL | [] => None, //~ ERROR pattern requires 0 elements but array has 2
| ^^ expected 2 elements
error: aborting due to previous error
For more information about this error, try `rustc --explain E0527`.

View file

@ -0,0 +1,17 @@
// Copyright 2014 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() {
let x = [1,2];
let y = match x {
[] => None, //~ ERROR pattern requires 0 elements but array has 2
[a,_] => Some(a)
};
}

View file

@ -0,0 +1,9 @@
error[E0527]: pattern requires 0 elements but array has 2
--> $DIR/issue-13482.rs:14:5
|
LL | [] => None, //~ ERROR pattern requires 0 elements but array has 2
| ^^ expected 2 elements
error: aborting due to previous error
For more information about this error, try `rustc --explain E0527`.

Some files were not shown because too many files have changed in this diff Show more