Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1244ced
Remove "important traits" feature
GuillaumeGomez Feb 27, 2020
13c6d58
Remove spotlight usage
GuillaumeGomez Feb 27, 2020
7859f0e
Make PlaceRef lifetimes of Place::as_ref be both 'tcx
spastorino Mar 3, 2020
812e62f
Make PlaceRef lifetimes of LocalAnalyzer::process_place be both 'tcx
spastorino Mar 3, 2020
1a1dcfa
Make PlaceRef lifetimes of codegen_place be both 'tcx
spastorino Mar 3, 2020
2af5e87
Make PlaceRef lifetimes of monomorphized_place_ty be both 'tcx
spastorino Mar 3, 2020
a20d54f
Make PlaceRef lifetimes of RootPlace be both 'tcx
spastorino Mar 3, 2020
842af36
Make PlaceRef lifetimes of borrow_conflict_place be both 'tcx
spastorino Mar 4, 2020
f54e863
Make PlaceRef lifetimes of move_error_reported be both 'tcx
spastorino Mar 4, 2020
6200f5c
Make PlaceRef lifetimes of uninitialized_error_reported be both 'tcx
spastorino Mar 4, 2020
e32ee55
Make PlaceRef lifetimes of move_path_closest_to be both 'tcx
spastorino Mar 4, 2020
634a167
Make PlaceRef lifetimes of move_path_for_place be both 'tcx
spastorino Mar 4, 2020
c6f1244
Make PlaceRef lifetimes of is_upvar_field_projection be both 'tcx
spastorino Mar 4, 2020
6f23650
Make PlaceRef lifetimes of add_moved_or_invoked_closure_note be both …
spastorino Mar 4, 2020
eb67eca
Make PlaceRef lifetimes of describe_field be both 'tcx
spastorino Mar 4, 2020
a30f55f
Make PlaceRef lifetimes of borrowed_content_source be both 'tcx
spastorino Mar 4, 2020
bd4dad4
Make PlaceRef lifetimes of move_spans be both 'tcx
spastorino Mar 4, 2020
46d85e5
Make PlaceRef lifetimes of closure_span be both 'tcx
spastorino Mar 4, 2020
a32afa3
Make PlaceRef lifetimes of classify_drop_access_kind be both 'tcx
spastorino Mar 4, 2020
a5d1e18
Make PlaceRef lifetimes of is_prefix_of be both 'tcx
spastorino Mar 4, 2020
2cb2559
Make PlaceRef lifetimes of in_projection be both 'tcx
spastorino Mar 4, 2020
b11cd0b
PlaceRef<'a, 'tcx> -> PlaceRef<'tcx>
spastorino Mar 4, 2020
c1df945
rustc_metadata: Give decoder access to whole crate store
petrochenkov Mar 2, 2020
41374d7
rustc_metadata: Move some code from `impl CrateMetadataRef` to `impl …
petrochenkov Mar 3, 2020
f77afc8
Allow ZSTs in `AllocRef`
TimDiekmann Mar 7, 2020
d32924f
Check if output is immediate value
JohnTitor Mar 8, 2020
c06fa0b
clean up E0393 explanation
GuillaumeGomez Mar 9, 2020
b974d6f
test(patterns): add borrowck tests for combination of pattern features
thekuom Mar 8, 2020
6701215
Move `analysis` to the query macro
Zoxc Feb 25, 2020
cbce217
Remove the need for `no_force`
Zoxc Feb 26, 2020
f445077
Remove the `no_force` query attribute
Zoxc Feb 26, 2020
2f12009
Add a comment to `recover`.
Zoxc Mar 9, 2020
7c60405
Add note about localization to std::fmt docs
dylnuge Mar 9, 2020
a561962
Vec::new is const tstable in 1.39 not 1.32
CAD97 Mar 10, 2020
5b08aad
Rollup merge of #69475 - Zoxc:no-no-force, r=michaelwoerister
Centril Mar 10, 2020
6115035
Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnison
Centril Mar 10, 2020
5a62aca
Rollup merge of #69677 - petrochenkov:spancode, r=eddyb
Centril Mar 10, 2020
977d69f
Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obk
Centril Mar 10, 2020
6ad5e69
Rollup merge of #69799 - TimDiekmann:zst, r=Amanieu
Centril Mar 10, 2020
08095f4
Rollup merge of #69817 - thekuom:test/borrow-checking-pattern-feature…
Centril Mar 10, 2020
436f2ec
Rollup merge of #69836 - JohnTitor:immediate-outputs, r=nagisa
Centril Mar 10, 2020
6f1db99
Rollup merge of #69847 - GuillaumeGomez:cleanup-e0393, r=Dylan-DPC
Centril Mar 10, 2020
20361bd
Rollup merge of #69861 - Dylnuge:dylnuge/locale-doc, r=Mark-Simulacrum
Centril Mar 10, 2020
3e9efbd
Rollup merge of #69877 - CAD97:patch-1, r=dtolnay
Centril Mar 10, 2020
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
Prev Previous commit
Next Next commit
test(patterns): add borrowck tests for combination of pattern features
Adds borrowck tests for the following features:
- bindings_after_at
- or_patterns
- slice_patterns
- box_patterns
  • Loading branch information
thekuom committed Mar 9, 2020
commit b974d6fc306d5847ad4b8bb48a99e6ca234cb6d1
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
// Tests using a combination of pattern features has the expected borrow checking behavior
#![feature(bindings_after_at)]
#![feature(or_patterns)]
#![feature(box_patterns)]

#![feature(move_ref_pattern)]

enum Test {
Foo,
Bar,
_Baz,
}

// bindings_after_at + slice_patterns

fn bindings_after_at_slice_patterns_move_binding(x: [String; 4]) {
match x {
a @ [.., _] => (),
_ => (),
};

&x;
//~^ ERROR borrow of moved value
}

fn bindings_after_at_slice_patterns_borrows_binding_mut(mut x: [String; 4]) {
let r = match x {
ref mut foo @ [.., _] => Some(foo),
_ => None,
};

&x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_slice_patterns_borrows_slice_mut1(mut x: [String; 4]) {
let r = match x {
ref foo @ [.., ref mut bar] => (),
//~^ ERROR cannot borrow
_ => (),
};

drop(r);
}

fn bindings_after_at_slice_patterns_borrows_slice_mut2(mut x: [String; 4]) {
let r = match x {
[ref foo @ .., ref bar] => Some(foo),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_slice_patterns_borrows_both(mut x: [String; 4]) {
let r = match x {
ref foo @ [.., ref bar] => Some(foo),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

// bindings_after_at + or_patterns

fn bindings_after_at_or_patterns_move(x: Option<Test>) {
match x {
foo @ Some(Test::Foo | Test::Bar) => (),
_ => (),
}

&x;
//~^ ERROR borrow of moved value
}

fn bindings_after_at_or_patterns_borrows(mut x: Option<Test>) {
let r = match x {
ref foo @ Some(Test::Foo | Test::Bar) => Some(foo),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_or_patterns_borrows_mut(mut x: Option<Test>) {
let r = match x {
ref mut foo @ Some(Test::Foo | Test::Bar) => Some(foo),
_ => None,
};

&x;
//~^ ERROR cannot borrow

drop(r);
}

// bindings_after_at + box_patterns

fn bindings_after_at_box_patterns_borrows_both(mut x: Option<Box<String>>) {
let r = match x {
ref foo @ Some(box ref s) => Some(foo),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_box_patterns_borrows_mut(mut x: Option<Box<String>>) {
match x {
ref foo @ Some(box ref mut s) => (),
//~^ ERROR cannot borrow
_ => (),
};
}

// bindings_after_at + slice_patterns + or_patterns

fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4]) {
match x {
a @ [.., Some(Test::Foo | Test::Bar)] => (),
_ => (),
};

&x;
//~^ ERROR borrow of moved value
}

fn bindings_after_at_slice_patterns_or_patterns_borrows_binding(mut x: [Option<Test>; 4]) {
let r = match x {
ref a @ [ref b @ .., Some(Test::Foo | Test::Bar)] => Some(a),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_slice_patterns_or_patterns_borrows_slice(mut x: [Option<Test>; 4]) {
let r = match x {
ref a @ [ref b @ .., Some(Test::Foo | Test::Bar)] => Some(b),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

// bindings_after_at + slice_patterns + box_patterns

fn bindings_after_at_slice_patterns_box_patterns_borrows(mut x: [Option<Box<String>>; 4]) {
let r = match x {
[_, ref a @ Some(box ref b), ..] => Some(a),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

// bindings_after_at + slice_patterns + or_patterns + box_patterns

fn bindings_after_at_slice_patterns_or_patterns_box_patterns_borrows(
mut x: [Option<Box<Test>>; 4]
) {
let r = match x {
[_, ref a @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_slice_patterns_or_patterns_box_patterns_borrows_mut(
mut x: [Option<Box<Test>>; 4]
) {
let r = match x {
[_, ref mut a @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
_ => None,
};

&x;
//~^ ERROR cannot borrow

drop(r);
}

fn bindings_after_at_slice_patterns_or_patterns_box_patterns_borrows_binding(
mut x: [Option<Box<Test>>; 4]
) {
let r = match x {
ref a @ [_, ref b @ Some(box Test::Foo | box Test::Bar), ..] => Some(a),
_ => None,
};

&mut x;
//~^ ERROR cannot borrow

drop(r);
}

fn main() {}
Loading