Moved compile-fail tests to ui tests.
This commit is contained in:
parent
fe28bcf1db
commit
b16a30677f
4052 changed files with 59249 additions and 0 deletions
1
src/test/ui/compile-fail-migration/.gitattributes
vendored
Normal file
1
src/test/ui/compile-fail-migration/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
trailing-carriage-return-in-string.rs -text
|
||||
31
src/test/ui/compile-fail-migration/E0501.ast.nll.stderr
Normal file
31
src/test/ui/compile-fail-migration/E0501.ast.nll.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:28:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - first borrow occurs due to use of `a` in closure
|
||||
LL | };
|
||||
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- borrow later used here
|
||||
|
||||
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:31:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - first borrow occurs due to use of `a` in closure
|
||||
...
|
||||
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0501`.
|
||||
31
src/test/ui/compile-fail-migration/E0501.ast.stderr
Normal file
31
src/test/ui/compile-fail-migration/E0501.ast.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:28:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - previous borrow occurs due to use of `a` in closure
|
||||
LL | };
|
||||
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - borrow from closure ends here
|
||||
|
||||
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:31:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - previous borrow occurs due to use of `a` in closure
|
||||
...
|
||||
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - borrow from closure ends here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0501`.
|
||||
31
src/test/ui/compile-fail-migration/E0501.mir.stderr
Normal file
31
src/test/ui/compile-fail-migration/E0501.mir.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:28:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - first borrow occurs due to use of `a` in closure
|
||||
LL | };
|
||||
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- borrow later used here
|
||||
|
||||
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
--> $DIR/E0501.rs:31:23
|
||||
|
|
||||
LL | let bar = || {
|
||||
| -- closure construction occurs here
|
||||
LL | inside_closure(a)
|
||||
| - first borrow occurs due to use of `a` in closure
|
||||
...
|
||||
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
| ^ borrow occurs here
|
||||
...
|
||||
LL | drop(bar);
|
||||
| --- borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0501`.
|
||||
38
src/test/ui/compile-fail-migration/E0501.rs
Normal file
38
src/test/ui/compile-fail-migration/E0501.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// 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.
|
||||
|
||||
// ignore-tidy-linelength
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
fn inside_closure(x: &mut i32) {
|
||||
}
|
||||
|
||||
fn outside_closure_1(x: &mut i32) {
|
||||
}
|
||||
|
||||
fn outside_closure_2(x: &i32) {
|
||||
}
|
||||
|
||||
fn foo(a: &mut i32) {
|
||||
let bar = || {
|
||||
inside_closure(a)
|
||||
};
|
||||
outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
|
||||
outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
|
||||
drop(bar);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
14
src/test/ui/compile-fail-migration/E0506.ast.nll.stderr
Normal file
14
src/test/ui/compile-fail-migration/E0506.ast.nll.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error[E0506]: cannot assign to `fancy_num` because it is borrowed
|
||||
--> $DIR/E0506.rs:21:5
|
||||
|
|
||||
LL | let fancy_ref = &fancy_num;
|
||||
| ---------- borrow of `fancy_num` occurs here
|
||||
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
|
||||
...
|
||||
LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
|
||||
| ------------- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0506`.
|
||||
11
src/test/ui/compile-fail-migration/E0506.ast.stderr
Normal file
11
src/test/ui/compile-fail-migration/E0506.ast.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0506]: cannot assign to `fancy_num` because it is borrowed
|
||||
--> $DIR/E0506.rs:21:5
|
||||
|
|
||||
LL | let fancy_ref = &fancy_num;
|
||||
| --------- borrow of `fancy_num` occurs here
|
||||
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0506`.
|
||||
14
src/test/ui/compile-fail-migration/E0506.mir.stderr
Normal file
14
src/test/ui/compile-fail-migration/E0506.mir.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error[E0506]: cannot assign to `fancy_num` because it is borrowed
|
||||
--> $DIR/E0506.rs:21:5
|
||||
|
|
||||
LL | let fancy_ref = &fancy_num;
|
||||
| ---------- borrow of `fancy_num` occurs here
|
||||
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
|
||||
...
|
||||
LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
|
||||
| ------------- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0506`.
|
||||
25
src/test/ui/compile-fail-migration/E0506.rs
Normal file
25
src/test/ui/compile-fail-migration/E0506.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
struct FancyNum {
|
||||
num: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut fancy_num = FancyNum { num: 5 };
|
||||
let fancy_ref = &fancy_num;
|
||||
fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
||||
//[mir]~^ ERROR [E0506]
|
||||
|
||||
println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
|
||||
}
|
||||
12
src/test/ui/compile-fail-migration/E0508.ast.stderr
Normal file
12
src/test/ui/compile-fail-migration/E0508.ast.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
|
||||
--> $DIR/E0508.rs:18:18
|
||||
|
|
||||
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| cannot move out of here
|
||||
| help: consider using a reference instead: `&array[0]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0508`.
|
||||
12
src/test/ui/compile-fail-migration/E0508.mir.stderr
Normal file
12
src/test/ui/compile-fail-migration/E0508.mir.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
|
||||
--> $DIR/E0508.rs:18:18
|
||||
|
|
||||
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| cannot move out of here
|
||||
| help: consider using a reference instead: `&array[0]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0508`.
|
||||
20
src/test/ui/compile-fail-migration/E0508.rs
Normal file
20
src/test/ui/compile-fail-migration/E0508.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
struct NonCopy;
|
||||
|
||||
fn main() {
|
||||
let array = [NonCopy; 1];
|
||||
let _value = array[0]; //[ast]~ ERROR [E0508]
|
||||
//[mir]~^ ERROR [E0508]
|
||||
}
|
||||
14
src/test/ui/compile-fail-migration/E0583.rs
Normal file
14
src/test/ui/compile-fail-migration/E0583.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
mod module_that_doesnt_exist; //~ ERROR E0583
|
||||
|
||||
fn main() {
|
||||
}
|
||||
11
src/test/ui/compile-fail-migration/E0583.stderr
Normal file
11
src/test/ui/compile-fail-migration/E0583.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0583]: file not found for module `module_that_doesnt_exist`
|
||||
--> $DIR/E0583.rs:11:5
|
||||
|
|
||||
LL | mod module_that_doesnt_exist; //~ ERROR E0583
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: name the file either module_that_doesnt_exist.rs or module_that_doesnt_exist/mod.rs inside the directory "$DIR"
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0583`.
|
||||
9
src/test/ui/compile-fail-migration/E0594.ast.nll.stderr
Normal file
9
src/test/ui/compile-fail-migration/E0594.ast.nll.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0594]: cannot assign to immutable static item `NUM`
|
||||
--> $DIR/E0594.rs:17:5
|
||||
|
|
||||
LL | NUM = 20; //[ast]~ ERROR E0594
|
||||
| ^^^^^^^^ cannot assign
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0594`.
|
||||
9
src/test/ui/compile-fail-migration/E0594.ast.stderr
Normal file
9
src/test/ui/compile-fail-migration/E0594.ast.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0594]: cannot assign to immutable static item
|
||||
--> $DIR/E0594.rs:17:5
|
||||
|
|
||||
LL | NUM = 20; //[ast]~ ERROR E0594
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0594`.
|
||||
9
src/test/ui/compile-fail-migration/E0594.mir.stderr
Normal file
9
src/test/ui/compile-fail-migration/E0594.mir.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0594]: cannot assign to immutable static item `NUM`
|
||||
--> $DIR/E0594.rs:17:5
|
||||
|
|
||||
LL | NUM = 20; //[ast]~ ERROR E0594
|
||||
| ^^^^^^^^ cannot assign
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0594`.
|
||||
19
src/test/ui/compile-fail-migration/E0594.rs
Normal file
19
src/test/ui/compile-fail-migration/E0594.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
static NUM: i32 = 18;
|
||||
|
||||
fn main() {
|
||||
NUM = 20; //[ast]~ ERROR E0594
|
||||
//[mir]~^ ERROR cannot assign to immutable static item `NUM`
|
||||
}
|
||||
11
src/test/ui/compile-fail-migration/E0596.ast.nll.stderr
Normal file
11
src/test/ui/compile-fail-migration/E0596.ast.nll.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> $DIR/E0596.rs:16:13
|
||||
|
|
||||
LL | let x = 1;
|
||||
| - help: consider changing this to be mutable: `mut x`
|
||||
LL | let y = &mut x; //[ast]~ ERROR [E0596]
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
11
src/test/ui/compile-fail-migration/E0596.ast.stderr
Normal file
11
src/test/ui/compile-fail-migration/E0596.ast.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow immutable local variable `x` as mutable
|
||||
--> $DIR/E0596.rs:16:18
|
||||
|
|
||||
LL | let x = 1;
|
||||
| - consider changing this to `mut x`
|
||||
LL | let y = &mut x; //[ast]~ ERROR [E0596]
|
||||
| ^ cannot borrow mutably
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
11
src/test/ui/compile-fail-migration/E0596.mir.stderr
Normal file
11
src/test/ui/compile-fail-migration/E0596.mir.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> $DIR/E0596.rs:16:13
|
||||
|
|
||||
LL | let x = 1;
|
||||
| - help: consider changing this to be mutable: `mut x`
|
||||
LL | let y = &mut x; //[ast]~ ERROR [E0596]
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
18
src/test/ui/compile-fail-migration/E0596.rs
Normal file
18
src/test/ui/compile-fail-migration/E0596.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
fn main() {
|
||||
let x = 1;
|
||||
let y = &mut x; //[ast]~ ERROR [E0596]
|
||||
//[mir]~^ ERROR [E0596]
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
mod foo {}
|
||||
|
||||
use foo::{
|
||||
::bar, //~ ERROR crate root in paths can only be used in start position
|
||||
super::bar, //~ ERROR `super` in paths can only be used in start position
|
||||
self::bar, //~ ERROR `self` in paths can only be used in start position
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
error[E0433]: failed to resolve. crate root in paths can only be used in start position
|
||||
--> $DIR/absolute-paths-in-nested-use-groups.rs:16:5
|
||||
|
|
||||
LL | ::bar, //~ ERROR crate root in paths can only be used in start position
|
||||
| ^ crate root in paths can only be used in start position
|
||||
|
||||
error[E0433]: failed to resolve. `super` in paths can only be used in start position
|
||||
--> $DIR/absolute-paths-in-nested-use-groups.rs:17:5
|
||||
|
|
||||
LL | super::bar, //~ ERROR `super` in paths can only be used in start position
|
||||
| ^^^^^ `super` in paths can only be used in start position
|
||||
|
||||
error[E0433]: failed to resolve. `self` in paths can only be used in start position
|
||||
--> $DIR/absolute-paths-in-nested-use-groups.rs:18:5
|
||||
|
|
||||
LL | self::bar, //~ ERROR `self` in paths can only be used in start position
|
||||
| ^^^^ `self` in paths can only be used in start position
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/access-mode-in-closures.rs:19:15
|
||||
|
|
||||
LL | match *s { sty(v) => v } //~ ERROR cannot move out
|
||||
| ^^ - move occurs because v has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
|
||||
| |
|
||||
| cannot move out of borrowed content
|
||||
| help: consider removing this dereference operator: `s`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2012 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 sty(Vec<isize> );
|
||||
|
||||
fn unpack<F>(_unpack: F) where F: FnOnce(&sty) -> Vec<isize> {}
|
||||
|
||||
fn main() {
|
||||
let _foo = unpack(|s| {
|
||||
// Test that `s` is moved here.
|
||||
match *s { sty(v) => v } //~ ERROR cannot move out
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/access-mode-in-closures.rs:19:15
|
||||
|
|
||||
LL | match *s { sty(v) => v } //~ ERROR cannot move out
|
||||
| ^^ - hint: to prevent move, use `ref v` or `ref mut v`
|
||||
| |
|
||||
| cannot move out of borrowed content
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 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 panic=abort
|
||||
|
||||
#![feature(alloc_error_handler, panic_implementation)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::alloc::Layout;
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn oom(
|
||||
info: &Layout, //~ ERROR argument should be `Layout`
|
||||
) -> () //~ ERROR return type should be `!`
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error: return type should be `!`
|
||||
--> $DIR/alloc-error-handler-bad-signature-1.rs:22:6
|
||||
|
|
||||
LL | ) -> () //~ ERROR return type should be `!`
|
||||
| ^^
|
||||
|
||||
error: argument should be `Layout`
|
||||
--> $DIR/alloc-error-handler-bad-signature-1.rs:21:11
|
||||
|
|
||||
LL | info: &Layout, //~ ERROR argument should be `Layout`
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2018 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 panic=abort
|
||||
|
||||
#![feature(alloc_error_handler, panic_implementation)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
struct Layout;
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn oom(
|
||||
info: Layout, //~ ERROR argument should be `Layout`
|
||||
) { //~ ERROR return type should be `!`
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error: return type should be `!`
|
||||
--> $DIR/alloc-error-handler-bad-signature-2.rs:22:3
|
||||
|
|
||||
LL | ) { //~ ERROR return type should be `!`
|
||||
| ^
|
||||
|
||||
error: argument should be `Layout`
|
||||
--> $DIR/alloc-error-handler-bad-signature-2.rs:21:11
|
||||
|
|
||||
LL | info: Layout, //~ ERROR argument should be `Layout`
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018 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 panic=abort
|
||||
|
||||
#![feature(alloc_error_handler, panic_implementation)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
struct Layout;
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn oom() -> ! { //~ ERROR function should have one argument
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: function should have one argument
|
||||
--> $DIR/alloc-error-handler-bad-signature-3.rs:20:1
|
||||
|
|
||||
LL | / fn oom() -> ! { //~ ERROR function should have one argument
|
||||
LL | | loop {}
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
use std::alloc::System;
|
||||
|
||||
#[global_allocator]
|
||||
static A: System = System;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
|
||||
use std::alloc::System;
|
||||
|
||||
#[global_allocator]
|
||||
static A: System = System;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// 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.
|
||||
|
||||
|
||||
#[global_allocator]
|
||||
fn foo() {} //~ ERROR: allocators must be statics
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: allocators must be statics
|
||||
--> $DIR/function-allocator.rs:13:1
|
||||
|
|
||||
LL | fn foo() {} //~ ERROR: allocators must be statics
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
#[global_allocator]
|
||||
static A: usize = 0;
|
||||
//~^ the trait bound `usize:
|
||||
//~| the trait bound `usize:
|
||||
//~| the trait bound `usize:
|
||||
//~| the trait bound `usize:
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
|
||||
--> $DIR/not-an-allocator.rs:12:1
|
||||
|
|
||||
LL | static A: usize = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
|
||||
|
|
||||
= note: required by `std::alloc::GlobalAlloc::alloc`
|
||||
|
||||
error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
|
||||
--> $DIR/not-an-allocator.rs:12:1
|
||||
|
|
||||
LL | static A: usize = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
|
||||
|
|
||||
= note: required by `std::alloc::GlobalAlloc::dealloc`
|
||||
|
||||
error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
|
||||
--> $DIR/not-an-allocator.rs:12:1
|
||||
|
|
||||
LL | static A: usize = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
|
||||
|
|
||||
= note: required by `std::alloc::GlobalAlloc::realloc`
|
||||
|
||||
error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
|
||||
--> $DIR/not-an-allocator.rs:12:1
|
||||
|
|
||||
LL | static A: usize = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
|
||||
|
|
||||
= note: required by `std::alloc::GlobalAlloc::alloc_zeroed`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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::alloc::System;
|
||||
|
||||
#[global_allocator]
|
||||
static A: System = System;
|
||||
#[global_allocator]
|
||||
static B: System = System;
|
||||
//~^ ERROR: cannot define more than one #[global_allocator]
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: cannot define more than one #[global_allocator]
|
||||
--> $DIR/two-allocators.rs:16:1
|
||||
|
|
||||
LL | static B: System = System;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -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.
|
||||
|
||||
// aux-build:system-allocator.rs
|
||||
// no-prefer-dynamic
|
||||
// error-pattern: the #[global_allocator] in
|
||||
|
||||
extern crate system_allocator;
|
||||
|
||||
use std::alloc::System;
|
||||
|
||||
#[global_allocator]
|
||||
static A: System = System;
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
error: the #[global_allocator] in this crate conflicts with global allocator in: system_allocator
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
// aux-build:system-allocator.rs
|
||||
// aux-build:system-allocator2.rs
|
||||
// no-prefer-dynamic
|
||||
// error-pattern: the #[global_allocator] in
|
||||
|
||||
|
||||
extern crate system_allocator;
|
||||
extern crate system_allocator2;
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
error: the #[global_allocator] in system_allocator conflicts with this global allocator in: system_allocator2
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
25
src/test/ui/compile-fail-migration/anon-params-deprecated.rs
Normal file
25
src/test/ui/compile-fail-migration/anon-params-deprecated.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// 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.
|
||||
|
||||
#![forbid(anonymous_parameters)]
|
||||
// Test for the anonymous_parameters deprecation lint (RFC 1685)
|
||||
|
||||
trait T {
|
||||
fn foo(i32); //~ ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
|
||||
fn bar_with_default_impl(String, String) {}
|
||||
//~^ ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
//~| ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
error: anonymous parameters are deprecated and will be removed in the next edition.
|
||||
--> $DIR/anon-params-deprecated.rs:15:12
|
||||
|
|
||||
LL | fn foo(i32); //~ ERROR anonymous parameters are deprecated
|
||||
| ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/anon-params-deprecated.rs:11:11
|
||||
|
|
||||
LL | #![forbid(anonymous_parameters)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
|
||||
|
||||
error: anonymous parameters are deprecated and will be removed in the next edition.
|
||||
--> $DIR/anon-params-deprecated.rs:18:30
|
||||
|
|
||||
LL | fn bar_with_default_impl(String, String) {}
|
||||
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
|
||||
|
||||
error: anonymous parameters are deprecated and will be removed in the next edition.
|
||||
--> $DIR/anon-params-deprecated.rs:18:38
|
||||
|
|
||||
LL | fn bar_with_default_impl(String, String) {}
|
||||
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
15
src/test/ui/compile-fail-migration/arg-count-mismatch.rs
Normal file
15
src/test/ui/compile-fail-migration/arg-count-mismatch.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2012 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.
|
||||
|
||||
// error-pattern: parameters were supplied
|
||||
|
||||
fn f(x: isize) { }
|
||||
|
||||
fn main() { let i: (); i = f(); }
|
||||
12
src/test/ui/compile-fail-migration/arg-count-mismatch.stderr
Normal file
12
src/test/ui/compile-fail-migration/arg-count-mismatch.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
|
||||
--> $DIR/arg-count-mismatch.rs:15:28
|
||||
|
|
||||
LL | fn f(x: isize) { }
|
||||
| -------------- defined here
|
||||
LL |
|
||||
LL | fn main() { let i: (); i = f(); }
|
||||
| ^^^ expected 1 parameter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0061`.
|
||||
16
src/test/ui/compile-fail-migration/arg-type-mismatch.rs
Normal file
16
src/test/ui/compile-fail-migration/arg-type-mismatch.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2012 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.
|
||||
|
||||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn f(x: isize) { }
|
||||
|
||||
fn main() { let i: (); i = f(()); }
|
||||
12
src/test/ui/compile-fail-migration/arg-type-mismatch.stderr
Normal file
12
src/test/ui/compile-fail-migration/arg-type-mismatch.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/arg-type-mismatch.rs:16:30
|
||||
|
|
||||
LL | fn main() { let i: (); i = f(()); }
|
||||
| ^^ expected isize, found ()
|
||||
|
|
||||
= note: expected type `isize`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
24
src/test/ui/compile-fail-migration/array-not-vector.rs
Normal file
24
src/test/ui/compile-fail-migration/array-not-vector.rs
Normal 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.
|
||||
|
||||
fn main() {
|
||||
let _x: i32 = [1, 2, 3];
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `i32`
|
||||
//~| found type `[{integer}; 3]`
|
||||
//~| expected i32, found array of 3 elements
|
||||
|
||||
let x: &[i32] = &[1, 2, 3];
|
||||
let _y: &i32 = x;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `&i32`
|
||||
//~| found type `&[i32]`
|
||||
//~| expected i32, found slice
|
||||
}
|
||||
21
src/test/ui/compile-fail-migration/array-not-vector.stderr
Normal file
21
src/test/ui/compile-fail-migration/array-not-vector.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/array-not-vector.rs:12:19
|
||||
|
|
||||
LL | let _x: i32 = [1, 2, 3];
|
||||
| ^^^^^^^^^ expected i32, found array of 3 elements
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `[{integer}; 3]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/array-not-vector.rs:19:20
|
||||
|
|
||||
LL | let _y: &i32 = x;
|
||||
| ^ expected i32, found slice
|
||||
|
|
||||
= note: expected type `&i32`
|
||||
found type `&[i32]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
18
src/test/ui/compile-fail-migration/array_const_index-0.rs
Normal file
18
src/test/ui/compile-fail-migration/array_const_index-0.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
const A: &'static [i32] = &[];
|
||||
const B: i32 = (&A)[1];
|
||||
//~^ index out of bounds: the len is 0 but the index is 1
|
||||
//~| ERROR this constant cannot be used
|
||||
|
||||
fn main() {
|
||||
let _ = B;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error: this constant cannot be used
|
||||
--> $DIR/array_const_index-0.rs:12:1
|
||||
|
|
||||
LL | const B: i32 = (&A)[1];
|
||||
| ^^^^^^^^^^^^^^^-------^
|
||||
| |
|
||||
| index out of bounds: the len is 0 but the index is 1
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
18
src/test/ui/compile-fail-migration/array_const_index-1.rs
Normal file
18
src/test/ui/compile-fail-migration/array_const_index-1.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
const A: [i32; 0] = [];
|
||||
const B: i32 = A[1];
|
||||
//~^ index out of bounds: the len is 0 but the index is 1
|
||||
//~| ERROR this constant cannot be used
|
||||
|
||||
fn main() {
|
||||
let _ = B;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error: this constant cannot be used
|
||||
--> $DIR/array_const_index-1.rs:12:1
|
||||
|
|
||||
LL | const B: i32 = A[1];
|
||||
| ^^^^^^^^^^^^^^^----^
|
||||
| |
|
||||
| index out of bounds: the len is 0 but the index is 1
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
35
src/test/ui/compile-fail-migration/asm-bad-clobber.rs
Normal file
35
src/test/ui/compile-fail-migration/asm-bad-clobber.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// 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.
|
||||
|
||||
// ignore-android
|
||||
// ignore-arm
|
||||
// ignore-aarch64
|
||||
// ignore-s390x
|
||||
// ignore-emscripten
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-powerpc64le
|
||||
// ignore-sparc
|
||||
// ignore-sparc64
|
||||
// ignore-mips
|
||||
// ignore-mips64
|
||||
|
||||
#![feature(asm, rustc_attrs)]
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64"))]
|
||||
#[rustc_error]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
// clobber formatted as register input/output
|
||||
asm!("xor %eax, %eax" : : : "{eax}");
|
||||
//~^ ERROR clobber should not be surrounded by braces
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0664]: clobber should not be surrounded by braces
|
||||
--> $DIR/asm-bad-clobber.rs:32:37
|
||||
|
|
||||
LL | asm!("xor %eax, %eax" : : : "{eax}");
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0664`.
|
||||
44
src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs
Normal file
44
src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2012-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.
|
||||
|
||||
// ignore-s390x
|
||||
// ignore-emscripten
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-powerpc64le
|
||||
// ignore-sparc
|
||||
// ignore-sparc64
|
||||
// ignore-mips
|
||||
// ignore-mips64
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: isize;
|
||||
let y: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
|
||||
asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
|
||||
}
|
||||
foo(x);
|
||||
foo(y);
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64")))]
|
||||
pub fn main() {}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error[E0662]: input operand constraint contains '='
|
||||
--> $DIR/asm-in-bad-modifier.rs:33:39
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
|
||||
| ^^^^
|
||||
|
||||
error[E0663]: input operand constraint contains '+'
|
||||
--> $DIR/asm-in-bad-modifier.rs:34:39
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0662, E0663.
|
||||
For more information about an error, try `rustc --explain E0662`.
|
||||
47
src/test/ui/compile-fail-migration/asm-misplaced-option.rs
Normal file
47
src/test/ui/compile-fail-migration/asm-misplaced-option.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// 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.
|
||||
|
||||
// ignore-android
|
||||
// ignore-arm
|
||||
// ignore-aarch64
|
||||
// ignore-s390x
|
||||
// ignore-emscripten
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-powerpc64le
|
||||
// ignore-sparc
|
||||
// ignore-sparc64
|
||||
// ignore-mips
|
||||
// ignore-mips64
|
||||
|
||||
#![feature(asm, rustc_attrs)]
|
||||
|
||||
#![allow(dead_code, non_upper_case_globals)]
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64"))]
|
||||
#[rustc_error]
|
||||
pub fn main() { //~ ERROR compilation successful
|
||||
// assignment not dead
|
||||
let mut x: isize = 0;
|
||||
unsafe {
|
||||
// extra colon
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
|
||||
//~^ WARNING unrecognized option
|
||||
}
|
||||
assert_eq!(x, 5);
|
||||
|
||||
unsafe {
|
||||
// comma in place of a colon
|
||||
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
|
||||
//~^ WARNING expected a clobber, found an option
|
||||
}
|
||||
assert_eq!(x, 13);
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
warning: unrecognized option
|
||||
--> $DIR/asm-misplaced-option.rs:36:64
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
|
||||
| ^^^^
|
||||
|
||||
warning: expected a clobber, found an option
|
||||
--> $DIR/asm-misplaced-option.rs:43:80
|
||||
|
|
||||
LL | asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: compilation successful
|
||||
--> $DIR/asm-misplaced-option.rs:31:1
|
||||
|
|
||||
LL | / pub fn main() { //~ ERROR compilation successful
|
||||
LL | | // assignment not dead
|
||||
LL | | let mut x: isize = 0;
|
||||
LL | | unsafe {
|
||||
... |
|
||||
LL | | assert_eq!(x, 13);
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
41
src/test/ui/compile-fail-migration/asm-out-no-modifier.rs
Normal file
41
src/test/ui/compile-fail-migration/asm-out-no-modifier.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2012-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.
|
||||
|
||||
// ignore-s390x
|
||||
// ignore-emscripten
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-powerpc64le
|
||||
// ignore-sparc
|
||||
// ignore-sparc64
|
||||
// ignore-mips
|
||||
// ignore-mips64
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64")))]
|
||||
pub fn main() {}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0661]: output operand constraint lacks '=' or '+'
|
||||
--> $DIR/asm-out-no-modifier.rs:32:29
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0661`.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0381]: use of possibly uninitialized variable: `x`
|
||||
--> $DIR/asm-out-read-uninit.rs:35:43
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
||||
| ^ use of possibly uninitialized `x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0381`.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0381]: use of possibly uninitialized variable: `x`
|
||||
--> $DIR/asm-out-read-uninit.rs:35:43
|
||||
|
|
||||
LL | asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
||||
| ^ use of possibly uninitialized `x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0381`.
|
||||
46
src/test/ui/compile-fail-migration/asm-out-read-uninit.rs
Normal file
46
src/test/ui/compile-fail-migration/asm-out-read-uninit.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2012-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.
|
||||
|
||||
// ignore-s390x
|
||||
// ignore-emscripten
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-powerpc64le
|
||||
// ignore-sparc
|
||||
// ignore-sparc64
|
||||
// ignore-mips
|
||||
// ignore-mips64
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
||||
//[ast]~^ ERROR use of possibly uninitialized variable: `x`
|
||||
//[mir]~^^ ERROR use of possibly uninitialized variable: `x`
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64")))]
|
||||
pub fn main() {}
|
||||
|
|
@ -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.
|
||||
|
||||
// WONTFIX(#20184) Needs landing pads (not present in stage1) or the compiler hangs.
|
||||
// ignore-stage1
|
||||
// compile-flags: -C codegen-units=2
|
||||
// ignore-emscripten
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error: <inline asm>:1:2: error: invalid instruction mnemonic 'nowayisthisavalidinstruction'
|
||||
nowayisthisavalidinstruction
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
--> $DIR/asm-src-loc-codegen-units.rs:20:9
|
||||
|
|
||||
LL | asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
19
src/test/ui/compile-fail-migration/asm-src-loc.rs
Normal file
19
src/test/ui/compile-fail-migration/asm-src-loc.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2014-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.
|
||||
|
||||
// ignore-emscripten
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
|
||||
}
|
||||
}
|
||||
11
src/test/ui/compile-fail-migration/asm-src-loc.stderr
Normal file
11
src/test/ui/compile-fail-migration/asm-src-loc.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error: <inline asm>:1:2: error: invalid instruction mnemonic 'nowayisthisavalidinstruction'
|
||||
nowayisthisavalidinstruction
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
--> $DIR/asm-src-loc.rs:17:9
|
||||
|
|
||||
LL | asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
error[E0384]: cannot assign twice to immutable variable `v`
|
||||
--> $DIR/assign-imm-local-twice.rs:20:5
|
||||
|
|
||||
LL | let v: isize;
|
||||
| - consider changing this to `mut v`
|
||||
LL | //[mir]~^ NOTE consider changing this to `mut v`
|
||||
LL | v = 1; //[ast]~ NOTE first assignment
|
||||
| ----- first assignment to `v`
|
||||
...
|
||||
LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
|
||||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0384]: cannot assign twice to immutable variable `v`
|
||||
--> $DIR/assign-imm-local-twice.rs:20:5
|
||||
|
|
||||
LL | v = 1; //[ast]~ NOTE first assignment
|
||||
| ----- first assignment to `v`
|
||||
...
|
||||
LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
|
||||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
error[E0384]: cannot assign twice to immutable variable `v`
|
||||
--> $DIR/assign-imm-local-twice.rs:20:5
|
||||
|
|
||||
LL | let v: isize;
|
||||
| - consider changing this to `mut v`
|
||||
LL | //[mir]~^ NOTE consider changing this to `mut v`
|
||||
LL | v = 1; //[ast]~ NOTE first assignment
|
||||
| ----- first assignment to `v`
|
||||
...
|
||||
LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
|
||||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
28
src/test/ui/compile-fail-migration/assign-imm-local-twice.rs
Normal file
28
src/test/ui/compile-fail-migration/assign-imm-local-twice.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2012 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Zborrowck=mir
|
||||
|
||||
fn test() {
|
||||
let v: isize;
|
||||
//[mir]~^ NOTE consider changing this to `mut v`
|
||||
v = 1; //[ast]~ NOTE first assignment
|
||||
//[mir]~^ NOTE first assignment
|
||||
println!("v={}", v);
|
||||
v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
|
||||
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
|
||||
//[ast]~| NOTE cannot assign twice to immutable
|
||||
//[mir]~| NOTE cannot assign twice to immutable
|
||||
println!("v={}", v);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
31
src/test/ui/compile-fail-migration/assign-to-method.rs
Normal file
31
src/test/ui/compile-fail-migration/assign-to-method.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2012 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 cat {
|
||||
meows : usize,
|
||||
|
||||
how_hungry : isize,
|
||||
}
|
||||
|
||||
impl cat {
|
||||
pub fn speak(&self) { self.meows += 1; }
|
||||
}
|
||||
|
||||
fn cat(in_x : usize, in_y : isize) -> cat {
|
||||
cat {
|
||||
meows: in_x,
|
||||
how_hungry: in_y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let nyan : cat = cat(52, 99);
|
||||
nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
|
||||
}
|
||||
11
src/test/ui/compile-fail-migration/assign-to-method.stderr
Normal file
11
src/test/ui/compile-fail-migration/assign-to-method.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0615]: attempted to take value of method `speak` on type `cat`
|
||||
--> $DIR/assign-to-method.rs:30:8
|
||||
|
|
||||
LL | nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe a `()` to call it is missing?
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0615`.
|
||||
|
|
@ -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.
|
||||
|
||||
struct Foo;
|
||||
|
||||
fn main() {
|
||||
let mut a = Foo;
|
||||
let ref b = Foo;
|
||||
a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo`
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
error[E0368]: binary assignment operation `+=` cannot be applied to type `Foo`
|
||||
--> $DIR/assignment-operator-unimplemented.rs:16:3
|
||||
|
|
||||
LL | a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo`
|
||||
| -^^^^^^
|
||||
| |
|
||||
| cannot use `+=` on type `Foo`
|
||||
|
|
||||
= note: an implementation of `std::ops::AddAssign` might be missing for `Foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0368`.
|
||||
19
src/test/ui/compile-fail-migration/assoc-inherent.rs
Normal file
19
src/test/ui/compile-fail-migration/assoc-inherent.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// 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 associated types are forbidden in inherent impls.
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
type Bar = isize; //~ERROR associated types are not allowed in inherent impls
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
9
src/test/ui/compile-fail-migration/assoc-inherent.stderr
Normal file
9
src/test/ui/compile-fail-migration/assoc-inherent.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0202]: associated types are not allowed in inherent impls
|
||||
--> $DIR/assoc-inherent.rs:16:5
|
||||
|
|
||||
LL | type Bar = isize; //~ERROR associated types are not allowed in inherent impls
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0202`.
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// 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.
|
||||
|
||||
|
||||
trait Foo {
|
||||
const ID: i32;
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
const ID: i32;
|
||||
}
|
||||
|
||||
impl Foo for i32 {
|
||||
const ID: i32 = 1;
|
||||
}
|
||||
|
||||
impl Bar for i32 {
|
||||
const ID: i32 = 3;
|
||||
}
|
||||
|
||||
const X: i32 = <i32>::ID; //~ ERROR E0034
|
||||
|
||||
fn main() {
|
||||
assert_eq!(1, X);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
error[E0034]: multiple applicable items in scope
|
||||
--> $DIR/associated-const-ambiguity-report.rs:28:16
|
||||
|
|
||||
LL | const X: i32 = <i32>::ID; //~ ERROR E0034
|
||||
| ^^^^^^^^^ multiple `ID` found
|
||||
|
|
||||
note: candidate #1 is defined in an impl of the trait `Foo` for the type `i32`
|
||||
--> $DIR/associated-const-ambiguity-report.rs:21:5
|
||||
|
|
||||
LL | const ID: i32 = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: candidate #2 is defined in an impl of the trait `Bar` for the type `i32`
|
||||
--> $DIR/associated-const-ambiguity-report.rs:25:5
|
||||
|
|
||||
LL | const ID: i32 = 3;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0034`.
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
trait Foo {
|
||||
const ID: usize;
|
||||
}
|
||||
|
||||
const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
|
||||
//~^ ERROR the trait bound `i32: Foo` is not satisfied
|
||||
|
||||
fn main() {
|
||||
assert_eq!(1, X);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
error[E0277]: the trait bound `i32: Foo` is not satisfied
|
||||
--> $DIR/associated-const-array-len.rs:16:16
|
||||
|
|
||||
LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
|
||||
| ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
|
||||
|
|
||||
note: required by `Foo::ID`
|
||||
--> $DIR/associated-const-array-len.rs:13:5
|
||||
|
|
||||
LL | const ID: usize;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
#![deny(dead_code)]
|
||||
|
||||
struct MyFoo;
|
||||
|
||||
impl MyFoo {
|
||||
const BAR: u32 = 1;
|
||||
//~^ ERROR associated const is never used: `BAR`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: MyFoo = MyFoo;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error: associated const is never used: `BAR`
|
||||
--> $DIR/associated-const-dead-code.rs:16:5
|
||||
|
|
||||
LL | const BAR: u32 = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/associated-const-dead-code.rs:11:9
|
||||
|
|
||||
LL | #![deny(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
trait Foo {
|
||||
type Out: Sized;
|
||||
}
|
||||
|
||||
impl Foo for String {
|
||||
type Out = String;
|
||||
}
|
||||
|
||||
trait Bar: Foo {
|
||||
const FROM: Self::Out;
|
||||
}
|
||||
|
||||
impl<T: Foo> Bar for T {
|
||||
const FROM: &'static str = "foo";
|
||||
//~^ ERROR the trait bound `T: Foo` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error[E0277]: the trait bound `T: Foo` is not satisfied
|
||||
--> $DIR/associated-const-generic-obligations.rs:25:5
|
||||
|
|
||||
LL | const FROM: &'static str = "foo";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
|
||||
|
|
||||
= help: consider adding a `where T: Foo` bound
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// 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.
|
||||
|
||||
// #29924
|
||||
|
||||
#![feature(const_fn, associated_consts)]
|
||||
|
||||
trait Trait {
|
||||
const N: usize;
|
||||
}
|
||||
|
||||
impl Trait {
|
||||
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
|
||||
const fn n() -> usize { Self::N }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error[E0038]: the trait `Trait` cannot be made into an object
|
||||
--> $DIR/associated-const-in-trait.rs:19:6
|
||||
|
|
||||
LL | impl Trait {
|
||||
| ^^^^^ the trait `Trait` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot contain associated consts like `N`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
trait Foo {
|
||||
const ID: i32;
|
||||
}
|
||||
|
||||
const X: i32 = <i32>::ID;
|
||||
//~^ ERROR no associated item named `ID` found for type `i32`
|
||||
|
||||
fn main() {
|
||||
assert_eq!(1, X);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
error[E0599]: no associated item named `ID` found for type `i32` in the current scope
|
||||
--> $DIR/associated-const-no-item.rs:16:16
|
||||
|
|
||||
LL | const X: i32 = <i32>::ID;
|
||||
| ^^^^^^^^^ associated item not found in `i32`
|
||||
|
|
||||
= help: items from traits can only be used if the trait is implemented and in scope
|
||||
= note: the following trait defines an item `ID`, perhaps you need to implement it:
|
||||
candidate #1: `Foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// 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 bar1 {
|
||||
pub use self::bar2::Foo;
|
||||
mod bar2 {
|
||||
pub struct Foo;
|
||||
|
||||
impl Foo {
|
||||
const ID: i32 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(1, bar1::Foo::ID);
|
||||
//~^ERROR associated constant `ID` is private
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0624]: associated constant `ID` is private
|
||||
--> $DIR/associated-const-private-impl.rs:24:19
|
||||
|
|
||||
LL | assert_eq!(1, bar1::Foo::ID);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0624`.
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// 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.
|
||||
|
||||
|
||||
pub enum EFoo { A, B, C, D }
|
||||
|
||||
pub trait Foo {
|
||||
const X: EFoo;
|
||||
}
|
||||
|
||||
struct Abc;
|
||||
|
||||
impl Foo for Abc {
|
||||
const X: EFoo = EFoo::B;
|
||||
}
|
||||
|
||||
struct Def;
|
||||
impl Foo for Def {
|
||||
const X: EFoo = EFoo::D;
|
||||
}
|
||||
|
||||
pub fn test<A: Foo, B: Foo>(arg: EFoo) {
|
||||
match arg {
|
||||
A::X => println!("A::X"),
|
||||
//~^ error: associated consts cannot be referenced in patterns [E0158]
|
||||
B::X => println!("B::X"),
|
||||
//~^ error: associated consts cannot be referenced in patterns [E0158]
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
error[E0158]: associated consts cannot be referenced in patterns
|
||||
--> $DIR/associated-const-type-parameter-arms.rs:31:9
|
||||
|
|
||||
LL | A::X => println!("A::X"),
|
||||
| ^^^^
|
||||
|
||||
error[E0158]: associated consts cannot be referenced in patterns
|
||||
--> $DIR/associated-const-type-parameter-arms.rs:33:9
|
||||
|
|
||||
LL | B::X => println!("B::X"),
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0158`.
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// 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.
|
||||
|
||||
|
||||
pub trait Foo {
|
||||
const Y: usize;
|
||||
}
|
||||
|
||||
struct Abc;
|
||||
impl Foo for Abc {
|
||||
const Y: usize = 8;
|
||||
}
|
||||
|
||||
struct Def;
|
||||
impl Foo for Def {
|
||||
const Y: usize = 33;
|
||||
}
|
||||
|
||||
pub fn test<A: Foo, B: Foo>() {
|
||||
let _array = [4; <A as Foo>::Y];
|
||||
//~^ ERROR the trait bound `A: Foo` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error[E0277]: the trait bound `A: Foo` is not satisfied
|
||||
--> $DIR/associated-const-type-parameter-arrays-2.rs:27:22
|
||||
|
|
||||
LL | let _array = [4; <A as Foo>::Y];
|
||||
| ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A`
|
||||
|
|
||||
= help: consider adding a `where A: Foo` bound
|
||||
note: required by `Foo::Y`
|
||||
--> $DIR/associated-const-type-parameter-arrays-2.rs:13:5
|
||||
|
|
||||
LL | const Y: usize;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue