diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs (renamed from tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs (renamed from tests/ui/rfc-2005-default-binding-mode/const.rs) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/const.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs | 45 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs | 29 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/enum.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs (renamed from tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs | 20 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs | 23 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/for.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs (renamed from tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs | 34 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs | 26 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/lit.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs (renamed from tests/ui/rfc-2005-default-binding-mode/no-double-error.rs) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs | 25 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs | 26 | ||||
-rw-r--r-- | tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr (renamed from tests/ui/rfc-2005-default-binding-mode/slice.stderr) | 0 |
22 files changed, 145 insertions, 83 deletions
diff --git a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs index 54ab9f0ad..54ab9f0ad 100644 --- a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs diff --git a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr index b7c0b0bb6..b7c0b0bb6 100644 --- a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr diff --git a/tests/ui/rfc-2005-default-binding-mode/const.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs index 93df88040..93df88040 100644 --- a/tests/ui/rfc-2005-default-binding-mode/const.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs diff --git a/tests/ui/rfc-2005-default-binding-mode/const.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr index fc06de90a..fc06de90a 100644 --- a/tests/ui/rfc-2005-default-binding-mode/const.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs new file mode 100644 index 000000000..52fbb90ed --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs @@ -0,0 +1,45 @@ +// run-pass +enum Wrapper { + Wrap(i32), +} + +use Wrapper::Wrap; + +pub fn main() { + let Wrap(x) = &Wrap(3); + println!("{}", *x); + + let Wrap(x) = &mut Wrap(3); + println!("{}", *x); + + if let Some(x) = &Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + *x += 1; + } else { + panic!(); + } + + while let Some(x) = &Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + *x += 1; + break; + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs index 52fbb90ed..4e57769d6 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs @@ -1,4 +1,3 @@ -// run-pass enum Wrapper { Wrap(i32), } @@ -7,39 +6,17 @@ use Wrapper::Wrap; pub fn main() { let Wrap(x) = &Wrap(3); - println!("{}", *x); + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference - let Wrap(x) = &mut Wrap(3); - println!("{}", *x); if let Some(x) = &Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - *x += 1; + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference } else { panic!(); } while let Some(x) = &Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - *x += 1; + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference break; } } diff --git a/tests/ui/rfc-2005-default-binding-mode/enum.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr index 21e3d3d27..21e3d3d27 100644 --- a/tests/ui/rfc-2005-default-binding-mode/enum.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr diff --git a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs index b8fde2208..b8fde2208 100644 --- a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs diff --git a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr index c3f64f65a..c3f64f65a 100644 --- a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs new file mode 100644 index 000000000..a5a24a806 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs @@ -0,0 +1,20 @@ +// run-pass +pub fn main() { + let mut tups = vec![(0u8, 1u8)]; + + for (n, m) in &tups { + let _: &u8 = n; + let _: &u8 = m; + } + + for (n, m) in &mut tups { + *n += 1; + *m += 2; + } + + assert_eq!(tups, vec![(1u8, 3u8)]); + + for (n, m) in tups { + println!("{} {}", m, n); + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs index a5a24a806..d6c5a13b1 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs @@ -1,20 +1,9 @@ -// run-pass -pub fn main() { - let mut tups = vec![(0u8, 1u8)]; - - for (n, m) in &tups { - let _: &u8 = n; - let _: &u8 = m; - } +struct Foo {} - for (n, m) in &mut tups { - *n += 1; - *m += 2; - } - - assert_eq!(tups, vec![(1u8, 3u8)]); - - for (n, m) in tups { - println!("{} {}", m, n); +pub fn main() { + let mut tups = vec![(Foo {}, Foo {})]; + // The below desugars to &(ref n, mut m). + for (n, mut m) in &tups { + //~^ ERROR cannot move out of a shared reference } } diff --git a/tests/ui/rfc-2005-default-binding-mode/for.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr index 07991af6e..07991af6e 100644 --- a/tests/ui/rfc-2005-default-binding-mode/for.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr diff --git a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs index b4a0d8145..b4a0d8145 100644 --- a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs diff --git a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr index e1e1bf7f6..e1e1bf7f6 100644 --- a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs new file mode 100644 index 000000000..937975359 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs @@ -0,0 +1,34 @@ +// run-pass +#![allow(dead_code)] +fn with_u8() { + let s = 5u8; + let r = match &s { + 4 => false, + 5 => true, + _ => false, + }; + assert!(r); +} + +// A string literal isn't mistaken for a non-ref pattern (in which case we'd +// deref `s` and mess things up). +fn with_str() { + let s: &'static str = "abc"; + match s { + "abc" => true, + _ => panic!(), + }; +} + +// Ditto with byte strings. +fn with_bytes() { + let s: &'static [u8] = b"abc"; + match s { + b"abc" => true, + _ => panic!(), + }; +} + +pub fn main() { + with_str(); +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs index 937975359..ce79cfbdc 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs @@ -1,34 +1,24 @@ -// run-pass -#![allow(dead_code)] -fn with_u8() { - let s = 5u8; - let r = match &s { - 4 => false, - 5 => true, - _ => false, - }; - assert!(r); -} +// FIXME(tschottdorf): we want these to compile, but they don't. -// A string literal isn't mistaken for a non-ref pattern (in which case we'd -// deref `s` and mess things up). fn with_str() { let s: &'static str = "abc"; - match s { - "abc" => true, + + match &s { + "abc" => true, //~ ERROR mismatched types _ => panic!(), }; } -// Ditto with byte strings. fn with_bytes() { let s: &'static [u8] = b"abc"; - match s { - b"abc" => true, + + match &s { + b"abc" => true, //~ ERROR mismatched types _ => panic!(), }; } pub fn main() { with_str(); + with_bytes(); } diff --git a/tests/ui/rfc-2005-default-binding-mode/lit.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr index 181f57899..181f57899 100644 --- a/tests/ui/rfc-2005-default-binding-mode/lit.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr diff --git a/tests/ui/rfc-2005-default-binding-mode/no-double-error.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs index 46fdfd678..46fdfd678 100644 --- a/tests/ui/rfc-2005-default-binding-mode/no-double-error.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs diff --git a/tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr index c672acee0..c672acee0 100644 --- a/tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs new file mode 100644 index 000000000..33229a205 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs @@ -0,0 +1,25 @@ +// run-pass + +fn slice_pat() { + let sl: &[u8] = b"foo"; + + match sl { + [first, remainder @ ..] => { + let _: &u8 = first; + assert_eq!(first, &b'f'); + assert_eq!(remainder, b"oo"); + } + [] => panic!(), + } +} + +fn slice_pat_omission() { + match &[0, 1, 2] { + [..] => {} + }; +} + +fn main() { + slice_pat(); + slice_pat_omission(); +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs index 33229a205..363a0e3e6 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs @@ -1,25 +1,7 @@ -// run-pass - -fn slice_pat() { +pub fn main() { let sl: &[u8] = b"foo"; - match sl { - [first, remainder @ ..] => { - let _: &u8 = first; - assert_eq!(first, &b'f'); - assert_eq!(remainder, b"oo"); - } - [] => panic!(), - } -} - -fn slice_pat_omission() { - match &[0, 1, 2] { - [..] => {} - }; -} - -fn main() { - slice_pat(); - slice_pat_omission(); + match sl { //~ ERROR non-exhaustive patterns + [first, remainder @ ..] => {}, + }; } diff --git a/tests/ui/rfc-2005-default-binding-mode/slice.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr index 5b51dc5ac..5b51dc5ac 100644 --- a/tests/ui/rfc-2005-default-binding-mode/slice.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr |