Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/2590

struct Parser {
tokens: Vec<isize> ,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0507]: cannot move out of `self.tokens` which is behind a shared reference
--> $DIR/cannot-move-out-of-borrowed-field-issue-2590.rs:13:9
|
LL | self.tokens
| ^^^^^^^^^^^ move occurs because `self.tokens` has type `Vec<isize>`, which does not implement the `Copy` trait
|
help: consider cloning the value if the performance cost is acceptable
|
LL | self.tokens.clone()
| ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0507`.
17 changes: 17 additions & 0 deletions tests/ui/borrowck/cannot-move-out-of-borrowed-field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://github.com/rust-lang/rust/issues/2590
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test was added twice: as tests/ui/borrowck/cannot-move-out-of-borrowed-field-issue-2590.rs and as tests/ui/borrowck/cannot-move-out-of-borrowed-field.rs.


struct Parser {
tokens: Vec<isize> ,
}

trait Parse {
fn parse(&self) -> Vec<isize> ;
}

impl Parse for Parser {
fn parse(&self) -> Vec<isize> {
self.tokens //~ ERROR cannot move out
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of `self.tokens` which is behind a shared reference
--> $DIR/issue-2590.rs:11:9
--> $DIR/cannot-move-out-of-borrowed-field.rs:13:9
|
LL | self.tokens
| ^^^^^^^^^^^ move occurs because `self.tokens` has type `Vec<isize>`, which does not implement the `Copy` trait
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/4335

#![feature(fn_traits)]

fn id<T>(t: T) -> T { t }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of `*v`, as `v` is a captured variable in an `FnMut` closure
--> $DIR/issue-4335.rs:6:20
--> $DIR/move-out-of-borrowed-content-in-closure.rs:8:20
|
LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> {
| - ----- move occurs because `*v` has type `T`, which does not implement the `Copy` trait
Expand All @@ -12,7 +12,7 @@ LL | id(Box::new(|| *v))
|
= help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once
help: if `T` implemented `Clone`, you could clone the value
--> $DIR/issue-4335.rs:5:10
--> $DIR/move-out-of-borrowed-content-in-closure.rs:7:10
|
LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> {
| ^ consider constraining this type parameter with `Clone`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/3021

fn siphash(k0 : u64) {

struct SipHash {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0434]: can't capture dynamic environment in a fn item
--> $DIR/issue-3021-b.rs:9:22
--> $DIR/capture-dynamic-environment.rs:11:22
|
LL | self.v0 = k0 ^ 0x736f6d6570736575;
| ^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/17252

const FOO: usize = FOO; //~ ERROR E0391
//@ ignore-parallel-frontend query cycle
fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
error[E0391]: cycle detected when checking if `FOO` is a trivial const
--> $DIR/issue-17252.rs:1:1
--> $DIR/const-eval-cycle-detection.rs:3:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires building MIR for `FOO`...
--> $DIR/issue-17252.rs:1:1
--> $DIR/const-eval-cycle-detection.rs:3:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^
= note: ...which again requires checking if `FOO` is a trivial const, completing the cycle
note: cycle used when simplifying constant for the type system `FOO`
--> $DIR/issue-17252.rs:1:1
--> $DIR/const-eval-cycle-detection.rs:3:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0391]: cycle detected when checking if `main::BAR` is a trivial const
--> $DIR/issue-17252.rs:6:9
--> $DIR/const-eval-cycle-detection.rs:8:9
|
LL | const BAR: usize = BAR;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires building MIR for `main::BAR`...
--> $DIR/issue-17252.rs:6:9
--> $DIR/const-eval-cycle-detection.rs:8:9
|
LL | const BAR: usize = BAR;
| ^^^^^^^^^^^^^^^^
= note: ...which again requires checking if `main::BAR` is a trivial const, completing the cycle
note: cycle used when simplifying constant for the type system `main::BAR`
--> $DIR/issue-17252.rs:6:9
--> $DIR/const-eval-cycle-detection.rs:8:9
|
LL | const BAR: usize = BAR;
| ^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/2150

#![deny(unreachable_code)]
#![allow(unused_variables)]
#![allow(dead_code)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: unreachable statement
--> $DIR/issue-2150.rs:8:5
--> $DIR/unreachable-code-in-loop.rs:10:5
|
LL | panic!();
| -------- any code following this expression is unreachable
LL | for x in &v { i += 1; }
| ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
|
note: the lint level is defined here
--> $DIR/issue-2150.rs:1:9
--> $DIR/unreachable-code-in-loop.rs:3:9
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/4972

#![feature(box_patterns)]

trait MyTrait {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0033]: type `Box<(dyn MyTrait + 'static)>` cannot be dereferenced
--> $DIR/issue-4972.rs:13:25
--> $DIR/box-pattern-trait-object-deref-error.rs:15:25
|
LL | TraitWrapper::A(box ref map) => map,
| ^^^^^^^^^^^ type `Box<(dyn MyTrait + 'static)>` cannot be dereferenced
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ dont-require-annotations: NOTE
// https://github.com/rust-lang/rust/issues/5100

#![feature(box_patterns)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-5100.rs:9:9
--> $DIR/pattern-mismatched-types-diagnostics.rs:10:9
|
LL | match (true, false) {
| ------------- this expression has type `(bool, bool)`
Expand All @@ -10,7 +10,7 @@ LL | A::B => (),
found enum `A`

error[E0308]: mismatched types
--> $DIR/issue-5100.rs:18:9
--> $DIR/pattern-mismatched-types-diagnostics.rs:19:9
|
LL | match (true, false) {
| ------------- this expression has type `(bool, bool)`
Expand All @@ -21,7 +21,7 @@ LL | (true, false, false) => ()
found tuple `(_, _, _)`

error[E0308]: mismatched types
--> $DIR/issue-5100.rs:26:9
--> $DIR/pattern-mismatched-types-diagnostics.rs:27:9
|
LL | match (true, false) {
| ------------- this expression has type `(bool, bool)`
Expand All @@ -32,7 +32,7 @@ LL | (true, false, false) => ()
found tuple `(_, _, _)`

error[E0308]: mismatched types
--> $DIR/issue-5100.rs:34:9
--> $DIR/pattern-mismatched-types-diagnostics.rs:35:9
|
LL | match (true, false) {
| ------------- this expression has type `(bool, bool)`
Expand All @@ -43,7 +43,7 @@ LL | box (true, false) => ()
found struct `Box<_>`

error[E0308]: mismatched types
--> $DIR/issue-5100.rs:41:9
--> $DIR/pattern-mismatched-types-diagnostics.rs:42:9
|
LL | match (true, false) {
| ------------- this expression has type `(bool, bool)`
Expand All @@ -54,13 +54,13 @@ LL | &(true, false) => ()
found reference `&_`

error[E0618]: expected function, found `(char, char)`
--> $DIR/issue-5100.rs:49:14
--> $DIR/pattern-mismatched-types-diagnostics.rs:50:14
|
LL | let v = [('a', 'b')
| ^^^^^^^^^^- help: consider separating array elements with a comma: `,`

error[E0308]: mismatched types
--> $DIR/issue-5100.rs:56:19
--> $DIR/pattern-mismatched-types-diagnostics.rs:57:19
|
LL | let x: char = true;
| ---- ^^^^ expected `char`, found `bool`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/17800

enum MyOption<T> {
MySome(T),
MyNone,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0769]: tuple variant `MyOption::MySome` written as struct variant
--> $DIR/issue-17800.rs:8:9
--> $DIR/tuple-variant-written-as-struct-pattern.rs:10:9
|
LL | MyOption::MySome { x: 42 } => (),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/3702

pub trait ToPrimitive {
fn to_int(&self) -> isize { 0 }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0034]: multiple applicable items in scope
--> $DIR/issue-3702-2.rs:16:14
--> $DIR/method-resolution-multiple-traits.rs:18:14
|
LL | self.to_int() + other.to_int()
| ^^^^^^ multiple `to_int` found
|
note: candidate #1 is defined in an impl of the trait `Add` for the type `isize`
--> $DIR/issue-3702-2.rs:14:5
--> $DIR/method-resolution-multiple-traits.rs:16:5
|
LL | fn to_int(&self) -> isize { *self }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `ToPrimitive` for the type `isize`
--> $DIR/issue-3702-2.rs:2:5
--> $DIR/method-resolution-multiple-traits.rs:4:5
|
LL | fn to_int(&self) -> isize { 0 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/4265
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should not be moved to ui/traits, there are no traits involved at all.


struct Foo {
baz: usize
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0592]: duplicate definitions with name `bar`
--> $DIR/issue-4265.rs:11:5
--> $DIR/duplicate-method-definitions-in-impl.rs:13:5
|
LL | fn bar() {
| -------- other definition for `bar`
Expand All @@ -8,7 +8,7 @@ LL | fn bar() {
| ^^^^^^^^ duplicate definitions for `bar`

error[E0599]: no method named `bar` found for struct `Foo` in the current scope
--> $DIR/issue-4265.rs:7:24
--> $DIR/duplicate-method-definitions-in-impl.rs:9:24
|
LL | struct Foo {
| ---------- method `bar` not found for this struct
Expand All @@ -18,7 +18,7 @@ LL | Foo { baz: 0 }.bar();
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Foo`
--> $DIR/issue-4265.rs:6:5
--> $DIR/duplicate-method-definitions-in-impl.rs:8:5
|
LL | fn bar() {
| ^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/4736

struct NonCopyable(());

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0560]: struct `NonCopyable` has no field named `p`
--> $DIR/issue-4736.rs:4:26
--> $DIR/tuple-struct-field-constructor-error.rs:6:26
|
LL | struct NonCopyable(());
| ----------- `NonCopyable` defined here
Expand Down
Loading