Merge branch 'master' into issue-32540
This commit is contained in:
commit
dedb7bbbbf
664 changed files with 11577 additions and 8696 deletions
|
|
@ -27,7 +27,7 @@ fn main() {
|
|||
x; //~ value moved here
|
||||
|
||||
let y = Int(2);
|
||||
//~^use `mut y` here to make mutable
|
||||
//~^ consider changing this to `mut y`
|
||||
y //~ error: cannot borrow immutable local variable `y` as mutable
|
||||
//~| cannot borrow
|
||||
+=
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn indirect_write_to_imm_box() {
|
|||
let mut x: isize = 1;
|
||||
let y: Box<_> = box &mut x;
|
||||
let p = &y;
|
||||
***p = 2; //~ ERROR cannot assign to data in an immutable container
|
||||
***p = 2; //~ ERROR cannot assign to data in a `&` reference
|
||||
drop(p);
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,6 @@ fn borrow_in_var_from_var_via_imm_box() {
|
|||
let p = &y;
|
||||
let q = &***p;
|
||||
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -64,7 +63,6 @@ fn borrow_in_var_from_field_via_imm_box() {
|
|||
let p = &y;
|
||||
let q = &***p;
|
||||
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -85,7 +83,6 @@ fn borrow_in_field_from_var_via_imm_box() {
|
|||
let p = &y.a;
|
||||
let q = &***p;
|
||||
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -106,7 +103,6 @@ fn borrow_in_field_from_field_via_imm_box() {
|
|||
let p = &y.a;
|
||||
let q = &***p;
|
||||
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
|
|||
23
src/test/compile-fail/coerce-to-bang-cast.rs
Normal file
23
src/test/compile-fail/coerce-to-bang-cast.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// 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(never_type)]
|
||||
|
||||
fn foo(x: usize, y: !, z: usize) { }
|
||||
|
||||
fn cast_a() {
|
||||
let y = {return; 22} as !;
|
||||
}
|
||||
|
||||
fn cast_b() {
|
||||
let y = 22 as !; //~ ERROR non-scalar cast
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
90
src/test/compile-fail/coerce-to-bang.rs
Normal file
90
src/test/compile-fail/coerce-to-bang.rs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// 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(never_type)]
|
||||
|
||||
fn foo(x: usize, y: !, z: usize) { }
|
||||
|
||||
fn call_foo_a() {
|
||||
// FIXME(#40800) -- accepted beacuse divergence happens **before**
|
||||
// the coercion to `!`, but within same expression. Not clear that
|
||||
// these are the rules we want.
|
||||
foo(return, 22, 44);
|
||||
}
|
||||
|
||||
fn call_foo_b() {
|
||||
// Divergence happens in the argument itself, definitely ok.
|
||||
foo(22, return, 44);
|
||||
}
|
||||
|
||||
fn call_foo_c() {
|
||||
// This test fails because the divergence happens **after** the
|
||||
// coercion to `!`:
|
||||
foo(22, 44, return); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn call_foo_d() {
|
||||
// This test passes because `a` has type `!`:
|
||||
let a: ! = return;
|
||||
let b = 22;
|
||||
let c = 44;
|
||||
foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
|
||||
}
|
||||
|
||||
fn call_foo_e() {
|
||||
// This test probably could pass but we don't *know* that `a`
|
||||
// has type `!` so we don't let it work.
|
||||
let a = return;
|
||||
let b = 22;
|
||||
let c = 44;
|
||||
foo(a, b, c); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn call_foo_f() {
|
||||
// This fn fails because `a` has type `usize`, and hence a
|
||||
// reference to is it **not** considered to diverge.
|
||||
let a: usize = return;
|
||||
let b = 22;
|
||||
let c = 44;
|
||||
foo(a, b, c); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn array_a() {
|
||||
// Accepted: return is coerced to `!` just fine, and then `22` can be
|
||||
// because we already diverged.
|
||||
let x: [!; 2] = [return, 22];
|
||||
}
|
||||
|
||||
fn array_b() {
|
||||
// Error: divergence has not yet occurred.
|
||||
let x: [!; 2] = [22, return]; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn tuple_a() {
|
||||
// No divergence at all.
|
||||
let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn tuple_b() {
|
||||
// Divergence happens before coercion: OK
|
||||
let x: (usize, !, usize) = (return, 44, 66);
|
||||
}
|
||||
|
||||
fn tuple_c() {
|
||||
// Divergence happens before coercion: OK
|
||||
let x: (usize, !, usize) = (22, return, 66);
|
||||
}
|
||||
|
||||
fn tuple_d() {
|
||||
// Error: divergence happens too late
|
||||
let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -9,10 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![deny(overlapping_inherent_impls)]
|
||||
|
||||
trait C {}
|
||||
impl C { fn f() {} } //~ ERROR duplicate definitions with name `f`
|
||||
//~^ WARN: this was previously accepted
|
||||
impl C { fn f() {} }
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -22,16 +22,6 @@ impl Deserialize for () {
|
|||
}
|
||||
}
|
||||
|
||||
fn doit() -> Result<(), String> {
|
||||
let _ = match Deserialize::deserialize() {
|
||||
//~^ ERROR code relies on type
|
||||
//~| WARNING previously accepted
|
||||
Ok(x) => x,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
trait ImplementedForUnitButNotNever {}
|
||||
|
||||
impl ImplementedForUnitButNotNever for () {}
|
||||
|
|
@ -46,6 +36,6 @@ fn smeg() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _ = doit();
|
||||
smeg();
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/test/compile-fail/diverging-tuple-parts-39485.rs
Normal file
25
src/test/compile-fail/diverging-tuple-parts-39485.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// 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.
|
||||
|
||||
// After #39485, this test used to pass, but that change was reverted
|
||||
// due to numerous inference failures like #39808, so it now fails
|
||||
// again. #39485 made it so that diverging types never propagate
|
||||
// upward; but we now do propagate such types upward in many more
|
||||
// cases.
|
||||
|
||||
fn g() {
|
||||
&panic!() //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn f() -> isize {
|
||||
(return 1, return 2) //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -25,7 +25,6 @@ fn f() {
|
|||
bar::m! { //~ ERROR ambiguous
|
||||
//~| NOTE macro-expanded items do not shadow when used in a macro invocation path
|
||||
mod bar { pub use two_macros::m; } //~ NOTE could refer to the name defined here
|
||||
//~^^^ NOTE in this expansion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +36,5 @@ fn g() {
|
|||
baz::m! { //~ ERROR ambiguous
|
||||
//~| NOTE macro-expanded items do not shadow when used in a macro invocation path
|
||||
mod baz { pub use two_macros::m; } //~ NOTE could refer to the name defined here
|
||||
//~^^^ NOTE in this expansion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ mod m2 {
|
|||
m! { //~ ERROR ambiguous
|
||||
//~| NOTE macro-expanded macro imports do not shadow
|
||||
use foo::m; //~ NOTE could refer to the name imported here
|
||||
//~^^^ NOTE in this expansion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +42,6 @@ mod m3 {
|
|||
m! { //~ ERROR ambiguous
|
||||
//~| NOTE macro-expanded macro imports do not shadow
|
||||
use two_macros::n as m; //~ NOTE could refer to the name imported here
|
||||
//~^^^ NOTE in this expansion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
71
src/test/compile-fail/imports/shadow_builtin_macros.rs
Normal file
71
src/test/compile-fail/imports/shadow_builtin_macros.rs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
mod foo {
|
||||
extern crate two_macros;
|
||||
pub use self::two_macros::m as panic;
|
||||
}
|
||||
|
||||
mod m1 {
|
||||
use foo::panic; // ok
|
||||
fn f() { panic!(); }
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
use foo::*; //~ NOTE `panic` could refer to the name imported here
|
||||
fn f() { panic!(); } //~ ERROR ambiguous
|
||||
//~| NOTE `panic` is also a builtin macro
|
||||
//~| NOTE consider adding an explicit import of `panic` to disambiguate
|
||||
}
|
||||
|
||||
mod m3 {
|
||||
::two_macros::m!(use foo::panic;); //~ NOTE `panic` could refer to the name imported here
|
||||
fn f() { panic!(); } //~ ERROR ambiguous
|
||||
//~| NOTE `panic` is also a builtin macro
|
||||
//~| NOTE macro-expanded macro imports do not shadow
|
||||
}
|
||||
|
||||
mod m4 {
|
||||
macro_rules! panic { () => {} } // ok
|
||||
panic!();
|
||||
}
|
||||
|
||||
mod m5 {
|
||||
macro_rules! m { () => {
|
||||
macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
|
||||
//~| NOTE macro-expanded `macro_rules!`s may not shadow existing macros
|
||||
} }
|
||||
m!(); //~ NOTE in this expansion
|
||||
//~| NOTE in this expansion
|
||||
panic!();
|
||||
}
|
||||
|
||||
#[macro_use(n)] //~ NOTE `n` could also refer to the name imported here
|
||||
extern crate two_macros;
|
||||
mod bar {
|
||||
pub use two_macros::m as n;
|
||||
}
|
||||
|
||||
mod m6 {
|
||||
use bar::n; // ok
|
||||
n!();
|
||||
}
|
||||
|
||||
mod m7 {
|
||||
use bar::*; //~ NOTE `n` could refer to the name imported here
|
||||
n!(); //~ ERROR ambiguous
|
||||
//~| NOTE consider adding an explicit import of `n` to disambiguate
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
(return)[0]; //~ ERROR the type of this value must be known in this context
|
||||
(return)[0]; //~ ERROR cannot index a value of type `!`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
fn main() {
|
||||
fn bar<T>(_: T) {}
|
||||
[0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<{integer}>` is not satisfied
|
||||
[0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied
|
||||
|
||||
[0][0]; // should infer to be a usize
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ struct Foo;
|
|||
|
||||
impl Foo {
|
||||
fn id() {} //~ ERROR duplicate definitions
|
||||
//~^ WARN previously accepted
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
|
|
@ -28,7 +27,6 @@ struct Bar<T>(T);
|
|||
|
||||
impl<T> Bar<T> {
|
||||
fn bar(&self) {} //~ ERROR duplicate definitions
|
||||
//~^ WARN previously accepted
|
||||
}
|
||||
|
||||
impl Bar<u32> {
|
||||
|
|
@ -39,7 +37,6 @@ struct Baz<T>(T);
|
|||
|
||||
impl<T: Copy> Baz<T> {
|
||||
fn baz(&self) {} //~ ERROR duplicate definitions
|
||||
//~^ WARN previously accepted
|
||||
}
|
||||
|
||||
impl<T> Baz<Vec<T>> {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ pub fn main() {
|
|||
v[3i32]; //~ERROR : std::ops::Index<i32>` is not satisfied
|
||||
s.as_bytes()[3_usize];
|
||||
s.as_bytes()[3];
|
||||
s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied
|
||||
s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied
|
||||
s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied
|
||||
s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Obj<F> where F: FnMut() -> u32 {
|
||||
closure: F,
|
||||
fn f() -> isize {
|
||||
(return 1, return 2)
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `isize`
|
||||
//~| found type `(!, !)`
|
||||
//~| expected isize, found tuple
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let o = Obj { closure: || 42 };
|
||||
o.closure(); //~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
|
||||
}
|
||||
fn main() {}
|
||||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
return.is_failure //~ ERROR the type of this value must be known in this context
|
||||
return.is_failure //~ ERROR no field `is_failure` on type `!`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn main() {
|
||||
loop {
|
||||
break.push(1) //~ ERROR the type of this value must be known in this context
|
||||
break.push(1) //~ ERROR no method named `push` found for type `!`
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
*return //~ ERROR the type of this value must be known in this context
|
||||
*return //~ ERROR type `!` cannot be dereferenced
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,5 @@
|
|||
// into it.
|
||||
|
||||
fn main() {
|
||||
(return)((),());
|
||||
//~^ ERROR the type of this value must be known
|
||||
(return)((),()); //~ ERROR expected function, found `!`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ impl<A> vec_monad<A> for Vec<A> {
|
|||
}
|
||||
fn main() {
|
||||
["hi"].bind(|x| [x] );
|
||||
//~^ ERROR no method named `bind` found for type `[&'static str; 1]` in the current scope
|
||||
//~^ ERROR no method named `bind` found for type `[&str; 1]` in the current scope
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
// 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(core, fnbox)]
|
||||
|
||||
use std::boxed::FnBox;
|
||||
|
||||
struct FuncContainer {
|
||||
f1: fn(data: u8),
|
||||
f2: extern "C" fn(data: u8),
|
||||
f3: unsafe fn(data: u8),
|
||||
}
|
||||
|
||||
struct FuncContainerOuter {
|
||||
container: Box<FuncContainer>
|
||||
}
|
||||
|
||||
struct Obj<F> where F: FnOnce() -> u32 {
|
||||
closure: F,
|
||||
not_closure: usize,
|
||||
}
|
||||
|
||||
struct BoxedObj {
|
||||
boxed_closure: Box<FnBox() -> u32>,
|
||||
}
|
||||
|
||||
struct Wrapper<F> where F: FnMut() -> u32 {
|
||||
wrap: Obj<F>,
|
||||
}
|
||||
|
||||
fn func() -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
fn check_expression() -> Obj<Box<FnBox() -> u32>> {
|
||||
Obj { closure: Box::new(|| 42_u32) as Box<FnBox() -> u32>, not_closure: 42 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test variations of function
|
||||
|
||||
let o_closure = Obj { closure: || 42, not_closure: 42 };
|
||||
o_closure.closure(); //~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(o_closure.closure)(...)` if you meant to call the function stored
|
||||
|
||||
o_closure.not_closure(); //~ ERROR no method named `not_closure` found
|
||||
//~^ NOTE did you mean to write `o_closure.not_closure`?
|
||||
|
||||
let o_func = Obj { closure: func, not_closure: 5 };
|
||||
o_func.closure(); //~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(o_func.closure)(...)` if you meant to call the function stored
|
||||
|
||||
let boxed_fn = BoxedObj { boxed_closure: Box::new(func) };
|
||||
boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
|
||||
//~^ NOTE use `(boxed_fn.boxed_closure)(...)` if you meant to call the function stored
|
||||
|
||||
let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnBox() -> u32> };
|
||||
boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
|
||||
//~^ NOTE use `(boxed_closure.boxed_closure)(...)` if you meant to call the function stored
|
||||
|
||||
// test expression writing in the notes
|
||||
|
||||
let w = Wrapper { wrap: o_func };
|
||||
w.wrap.closure();//~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(w.wrap.closure)(...)` if you meant to call the function stored
|
||||
|
||||
w.wrap.not_closure();//~ ERROR no method named `not_closure` found
|
||||
//~^ NOTE did you mean to write `w.wrap.not_closure`?
|
||||
|
||||
check_expression().closure();//~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(check_expression().closure)(...)` if you meant to call the function stored
|
||||
}
|
||||
|
||||
impl FuncContainerOuter {
|
||||
fn run(&self) {
|
||||
unsafe {
|
||||
(*self.container).f1(1); //~ ERROR no method named `f1` found
|
||||
//~^ NOTE use `((*self.container).f1)(...)`
|
||||
(*self.container).f2(1); //~ ERROR no method named `f2` found
|
||||
//~^ NOTE use `((*self.container).f2)(...)`
|
||||
(*self.container).f3(1); //~ ERROR no method named `f3` found
|
||||
//~^ NOTE use `((*self.container).f3)(...)`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,5 +21,4 @@ fn main() {
|
|||
|
||||
foo!(1i32.foo());
|
||||
//~^ ERROR no method named `foo` found for type `i32` in the current scope
|
||||
//~^^ NOTE in this expansion of foo!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
fn main() {
|
||||
let _: i32 =
|
||||
'a: //~ ERROR mismatched types
|
||||
loop { break };
|
||||
'a: // in this case, the citation is just the `break`:
|
||||
loop { break }; //~ ERROR mismatched types
|
||||
let _: i32 =
|
||||
'b: //~ ERROR mismatched types
|
||||
while true { break };
|
||||
while true { break }; // but here we cite the whole loop
|
||||
let _: i32 =
|
||||
'c: //~ ERROR mismatched types
|
||||
for _ in None { break };
|
||||
for _ in None { break }; // but here we cite the whole loop
|
||||
let _: i32 =
|
||||
'd: //~ ERROR mismatched types
|
||||
while let Some(_) = None { break };
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
// 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.
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
struct Obj<F> where F: FnMut() -> u32 {
|
||||
fn_ptr: fn() -> (),
|
||||
closure: F,
|
||||
}
|
||||
|
||||
struct C {
|
||||
c_fn_ptr: fn() -> (),
|
||||
}
|
||||
|
||||
struct D(C);
|
||||
|
||||
impl Deref for D {
|
||||
type Target = C;
|
||||
fn deref(&self) -> &C {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn empty() {}
|
||||
|
||||
fn main() {
|
||||
let o = Obj { fn_ptr: empty, closure: || 42 };
|
||||
let p = &o;
|
||||
p.closure(); //~ ERROR no method named `closure` found
|
||||
//~^ NOTE use `(p.closure)(...)` if you meant to call the function stored in the `closure` field
|
||||
let q = &p;
|
||||
q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
|
||||
//~^ NOTE use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field
|
||||
let r = D(C { c_fn_ptr: empty });
|
||||
let s = &r;
|
||||
s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
|
||||
//~^ NOTE use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr`
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ fn main() {
|
|||
match op {
|
||||
Some(ref v) => { let a = &mut v; },
|
||||
//~^ ERROR:cannot borrow immutable
|
||||
//~| use `ref mut v` here to make mutable
|
||||
//~| cannot borrow mutably
|
||||
None => {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/test/compile-fail/issue-40000.rs
Normal file
21
src/test/compile-fail/issue-40000.rs
Normal file
|
|
@ -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.
|
||||
|
||||
#![feature(closure_to_fn_coercion)]
|
||||
|
||||
fn main() {
|
||||
let bar: fn(&mut u32) = |_| {}; //~ ERROR mismatched types
|
||||
//~| expected concrete lifetime, found bound lifetime parameter
|
||||
|
||||
fn foo(x: Box<Fn(&i32)>) {}
|
||||
let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>;
|
||||
foo(bar); //~ ERROR mismatched types
|
||||
//~| expected concrete lifetime, found bound lifetime parameter
|
||||
}
|
||||
16
src/test/compile-fail/issue-40749.rs
Normal file
16
src/test/compile-fail/issue-40749.rs
Normal file
|
|
@ -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 main() {
|
||||
[0; ..10];
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `usize`
|
||||
//~| found type `std::ops::RangeTo<{integer}>`
|
||||
}
|
||||
16
src/test/compile-fail/issue-40845.rs
Normal file
16
src/test/compile-fail/issue-40845.rs
Normal file
|
|
@ -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.
|
||||
|
||||
trait T { m!(); } //~ ERROR cannot find macro `m!` in this scope
|
||||
|
||||
struct S;
|
||||
impl S { m!(); } //~ ERROR cannot find macro `m!` in this scope
|
||||
|
||||
fn main() {}
|
||||
17
src/test/compile-fail/issue-5500.rs
Normal file
17
src/test/compile-fail/issue-5500.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// 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.
|
||||
|
||||
fn main() {
|
||||
&panic!()
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `()`
|
||||
//~| found type `&_`
|
||||
//~| expected (), found reference
|
||||
}
|
||||
|
|
@ -40,37 +40,40 @@ fn main() {
|
|||
loop {
|
||||
break 'while_loop 123;
|
||||
//~^ ERROR `break` with value from a `while` loop
|
||||
//~| ERROR mismatched types
|
||||
break 456;
|
||||
break 789;
|
||||
};
|
||||
}
|
||||
|
||||
'while_let_loop: while let Some(_) = Some(()) {
|
||||
while let Some(_) = Some(()) {
|
||||
if break () { //~ ERROR `break` with value from a `while let` loop
|
||||
break;
|
||||
break None;
|
||||
//~^ ERROR `break` with value from a `while let` loop
|
||||
//~| ERROR mismatched types
|
||||
}
|
||||
}
|
||||
|
||||
while let Some(_) = Some(()) {
|
||||
break None;
|
||||
//~^ ERROR `break` with value from a `while let` loop
|
||||
}
|
||||
|
||||
'while_let_loop: while let Some(_) = Some(()) {
|
||||
loop {
|
||||
break 'while_let_loop "nope";
|
||||
//~^ ERROR `break` with value from a `while let` loop
|
||||
//~| ERROR mismatched types
|
||||
break 33;
|
||||
};
|
||||
}
|
||||
|
||||
'for_loop: for _ in &[1,2,3] {
|
||||
for _ in &[1,2,3] {
|
||||
break (); //~ ERROR `break` with value from a `for` loop
|
||||
break [()];
|
||||
//~^ ERROR `break` with value from a `for` loop
|
||||
//~| ERROR mismatched types
|
||||
}
|
||||
|
||||
'for_loop: for _ in &[1,2,3] {
|
||||
loop {
|
||||
break Some(3);
|
||||
break 'for_loop Some(17);
|
||||
//~^ ERROR `break` with value from a `for` loop
|
||||
//~| ERROR mismatched types
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
22
src/test/compile-fail/match-no-arms-unreachable-after.rs
Normal file
22
src/test/compile-fail/match-no-arms-unreachable-after.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
#![allow(warnings)]
|
||||
#![deny(unreachable_code)]
|
||||
|
||||
enum Void { }
|
||||
|
||||
fn foo(v: Void) {
|
||||
match v { }
|
||||
let x = 2; //~ ERROR unreachable
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// 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.
|
||||
|
||||
#![allow(unused_parens)]
|
||||
#![deny(unreachable_code)]
|
||||
|
||||
fn main() {
|
||||
match (return) { } //~ ERROR unreachable expression
|
||||
}
|
||||
|
|
@ -8,18 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Example {
|
||||
example: Box<Fn(i32) -> i32>
|
||||
}
|
||||
fn foo<T>() -> T { panic!("Rocks for my pillow") }
|
||||
|
||||
fn main() {
|
||||
let demo = Example {
|
||||
example: Box::new(|x| {
|
||||
x + 1
|
||||
})
|
||||
let x = match () { //~ ERROR type annotations needed
|
||||
() => foo() // T here should be unresolved
|
||||
};
|
||||
|
||||
demo.example(1); //~ ERROR no method named `example`
|
||||
//~^ NOTE use `(demo.example)(...)`
|
||||
// (demo.example)(1);
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ impl S {
|
|||
}
|
||||
|
||||
fn func(arg: S) {
|
||||
//~^ here to make mutable
|
||||
//~^ consider changing this to `mut arg`
|
||||
arg.mutate();
|
||||
//~^ ERROR cannot borrow immutable argument
|
||||
//~| cannot borrow mutably
|
||||
|
|
@ -25,7 +25,7 @@ fn func(arg: S) {
|
|||
|
||||
fn main() {
|
||||
let local = S;
|
||||
//~^ here to make mutable
|
||||
//~^ consider changing this to `mut local`
|
||||
local.mutate();
|
||||
//~^ ERROR cannot borrow immutable local variable
|
||||
//~| cannot borrow mutably
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@
|
|||
fn main() {
|
||||
let x: ! = panic!("aah"); //~ ERROR unused
|
||||
drop(x); //~ ERROR unreachable
|
||||
//~^ ERROR unreachable
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
// Test that we can't use another type in place of !
|
||||
|
||||
#![feature(never_type)]
|
||||
#![deny(warnings)]
|
||||
|
||||
fn main() {
|
||||
let x: ! = "hello"; //~ ERROR mismatched types
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test that diverging types default to ! when feature(never_type) is enabled. This test is the
|
||||
// same as run-pass/unit-fallback.rs except that ! is enabled.
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
trait Balls: Sized {
|
||||
fn smeg() -> Result<Self, ()>;
|
||||
}
|
||||
|
||||
impl Balls for () {
|
||||
fn smeg() -> Result<(), ()> { Ok(()) }
|
||||
}
|
||||
|
||||
struct Flah;
|
||||
|
||||
impl Flah {
|
||||
fn flah<T: Balls>(&self) -> Result<T, ()> {
|
||||
T::smeg()
|
||||
}
|
||||
}
|
||||
|
||||
fn doit() -> Result<(), ()> {
|
||||
// The type of _ is unconstrained here and should default to !
|
||||
let _ = try!(Flah.flah()); //~ ERROR the trait bound
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = doit();
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
|
|||
|
||||
fn make_baz<T:Baz>(t: &T) -> &Baz {
|
||||
//~^ ERROR E0038
|
||||
//~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing
|
||||
//~| NOTE the trait cannot use `Self` as a type parameter in the supertraits or where-clauses
|
||||
//~| NOTE the trait `Baz` cannot be made into an object
|
||||
t
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ fn main() {
|
|||
let x = &[1, 2, 3] as &[i32];
|
||||
x[1i32]; //~ ERROR E0277
|
||||
//~| NOTE slice indices are of type `usize` or ranges of `usize`
|
||||
//~| NOTE trait `std::slice::SliceIndex<i32>` is not implemented for `i32`
|
||||
//~| NOTE trait `std::slice::SliceIndex<[i32]>` is not implemented for `i32`
|
||||
//~| NOTE required because of the requirements on the impl of `std::ops::Index<i32>`
|
||||
x[..1i32]; //~ ERROR E0277
|
||||
//~| NOTE slice indices are of type `usize` or ranges of `usize`
|
||||
//~| NOTE trait `std::slice::SliceIndex<i32>` is not implemented for `std::ops::RangeTo<i32>`
|
||||
//~| NOTE trait `std::slice::SliceIndex<[i32]>` is not implemented for `std::ops::RangeTo<i32>`
|
||||
//~| NOTE requirements on the impl of `std::ops::Index<std::ops::RangeTo<i32>>`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
mod foo {
|
||||
type T = ();
|
||||
struct S1(pub(foo) (), pub(T), pub(crate) (), pub(((), T)));
|
||||
struct S2(pub((foo)) ()); //~ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T)));
|
||||
struct S2(pub((foo)) ());
|
||||
//~^ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@
|
|||
macro_rules! define_struct {
|
||||
($t:ty) => {
|
||||
struct S1(pub $t);
|
||||
struct S2(pub (foo) ());
|
||||
struct S3(pub $t ()); //~ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
struct S2(pub (in foo) ());
|
||||
struct S3(pub $t ());
|
||||
//~^ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@
|
|||
macro_rules! define_struct {
|
||||
($t:ty) => {
|
||||
struct S1(pub($t));
|
||||
struct S2(pub (foo) ());
|
||||
struct S3(pub($t) ()); //~ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
struct S2(pub (in foo) ());
|
||||
struct S3(pub($t) ());
|
||||
//~^ ERROR expected `,`, found `(`
|
||||
//~| ERROR expected one of `;` or `where`, found `(`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ trait SomeTrait { }
|
|||
|
||||
// Bounds on object types:
|
||||
|
||||
struct Foo<'a,'b,'c> { //~ ERROR parameter `'b` is never used
|
||||
struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used
|
||||
// All of these are ok, because we can derive exactly one bound:
|
||||
a: Box<IsStatic>,
|
||||
b: Box<Is<'static>>,
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
// over time, but this test used to exhibit some pretty bogus messages
|
||||
// that were not remotely helpful.
|
||||
|
||||
// error-pattern:cannot infer
|
||||
// error-pattern:cannot outlive the lifetime 'a
|
||||
// error-pattern:must be valid for the static lifetime
|
||||
// error-pattern:cannot infer
|
||||
// error-pattern:cannot outlive the lifetime 'a
|
||||
// error-pattern:must be valid for the static lifetime
|
||||
|
|
|
|||
|
|
@ -16,17 +16,11 @@ struct an_enum<'a>(&'a isize);
|
|||
struct a_class<'a> { x:&'a isize }
|
||||
|
||||
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
|
||||
return e; //~ ERROR mismatched types
|
||||
//~| expected type `an_enum<'b>`
|
||||
//~| found type `an_enum<'a>`
|
||||
//~| lifetime mismatch
|
||||
return e; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
|
||||
return e; //~ ERROR mismatched types
|
||||
//~| expected type `a_class<'b>`
|
||||
//~| found type `a_class<'a>`
|
||||
//~| lifetime mismatch
|
||||
return e; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
16
src/test/compile-fail/static-lifetime-bound.rs
Normal file
16
src/test/compile-fail/static-lifetime-bound.rs
Normal file
|
|
@ -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<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a`
|
||||
|
||||
fn main() {
|
||||
let x = 0;
|
||||
f(&x); //~ERROR does not live long enough
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue