8000 Rollup of 12 pull requests by Centril · Pull Request #69795 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 12 pull requests #69795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
940f657
Parse & reject postfix operators after casts
daboross Feb 9, 2020
5ce9b80
Refactor out error case & apply suggestions.
daboross Feb 16, 2020
4fc0532
Type ascription outputs a Type, not Cast
daboross Feb 16, 2020
0cf2049
Keep better fix suggestion if type ascription is likely unintended
daboross Feb 16, 2020
f82ca8b
Add more error cases to issue 35813 tests
daboross Feb 16, 2020
5dd6464
Fix related type ascription tests.
daboross Feb 16, 2020
e3eefe2
Remove extra debug print in unreachable!
daboross Feb 16, 2020
c2d7ffb
Remove trailing whitespace
daboross Feb 16, 2020
8ef3da0
Fix test stderr after rebasing on master.
daboross Feb 16, 2020
fa1f547
Add more double cast + method call tests
daboross Feb 22, 2020
f434c6e
Use multipart suggestion
daboross Feb 22, 2020
453c505
Replace ptr hashing with ptr casting
daboross Feb 25, 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
d3e5177
Use .next() instead of .nth(0) on iterators.
matthiaskrgr Mar 3, 2020
98c7ed6
DefKind::Method -> DefKind::AssocFn
mark-i-m Mar 3, 2020
3aeb9f0
rename TraitItemKind::Method -> Fn
mark-i-m 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
5456114
test(pattern): add tests for combinations of pattern features
thekuom Mar 4, 2020
b4788a7
test(pattern): harden tests for or-patterns with slice-patterns
thekuom Mar 4, 2020
ea7b3c3
fix tidy error
thekuom Mar 4, 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
53be0cc
Use subslice patterns in slice methods
cuviper 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
9afbf28
Update deprecation version to 1.42 for Error::description
dylnuge Mar 6, 2020
5d308ae
ast: `Mac`/`Macro` -> `MacCall`
petrochenkov Feb 29, 2020
2d0c5b4
rustc_expand: Factor out `Annotatable::into_tokens` to a separate method
petrochenkov Mar 3, 2020
83980ac
Don't redundantly repeat field names (clippy::redundant_field_names)
matthiaskrgr Mar 6, 2020
1631b4d
Avoid using `unwrap()` in suggestions
JohnTitor Mar 5, 2020
3d67649
Add a regression test
JohnTitor Mar 6, 2020
125159f
When encountering an Item in a pat context, point at the item def
estebank Dec 30, 2019
39ca644
Rollup merge of #67741 - estebank:point-at-pat-def, r=Centril
Centril Mar 7, 2020
bb0959d
Rollup merge of #68985 - daboross:fix-35813, r=Centril
Centril Mar 7, 2020
4e6fddf
Rollup merge of #69589 - petrochenkov:maccall, r=Centril
Centril Mar 7, 2020
11f08b2
Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obk
Centril Mar 7, 2020
e3def0e
Rollup merge of #69674 - mark-i-m:assoc-fn, r=Centril
Centril Mar 7, 2020
d1bb2a6
Rollup merge of #69680 - petrochenkov:nont4, r=Centril
Centril Mar 7, 2020
4f87d9f
Rollup merge of #69690 - thekuom:test/67311-extend-bindings-after-at-…
Centril Mar 7, 2020
2a87b39
Rollup merge of #69706 - cuviper:subslice-methods, r=Centril
Centril Mar 7, 2020
2603a19
Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obk
Centril Mar 7, 2020
6a9ec75
Rollup merge of #69727 - JohnTitor:sugg-unwrap, r=estebank
Centril Mar 7, 2020
49eae8a
Rollup merge of #69754 - Dylnuge:dylnuge/dep-version, r=Mark-Simulacrum
Centril Mar 7, 2020
46266c1
Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cra…
Centril Mar 7, 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
Add more double cast + method call tests
  • Loading branch information
daboross committed Feb 22, 2020
commit fa1f547f82d66f986af2c33220199b042fcb5f99
23 changes: 23 additions & 0 deletions src/test/ui/parser/issue-35813-postfix-after-cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ pub fn cast_after_cast() {
let _ = 0i32: i32: i32 as u32 as i32;
}

pub fn cast_cast_method_call() {
let _ = 0i32: i32: i32.count_ones();
//~^ ERROR: casts cannot be followed by a method call
let _ = 0 as i32: i32.count_ones();
//~^ ERROR: casts cannot be followed by a method call
let _ = 0i32: i32 as i32.count_ones();
//~^ ERROR: casts cannot be followed by a method call
let _ = 0 as i32 as i32.count_ones();
//~^ ERROR: casts cannot be followed by a method call
let _ = 0i32: i32: i32 as u32 as i32.count_ones();
//~^ ERROR: casts cannot be followed by a method call
let _ = 0i32: i32.count_ones(): u32;
//~^ ERROR: casts cannot be followed by a method call
let _ = 0 as i32.count_ones(): u32;
//~^ ERROR: casts cannot be followed by a method call
let _ = 0i32: i32.count_ones() as u32;
//~^ ERROR: casts cannot be followed by a method call
let _ = 0 as i32.count_ones() as u32;
//~^ ERROR: casts cannot be followed by a method call
let _ = 0i32: i32: i32.count_ones() as u32 as i32;
//~^ ERROR: casts cannot be followed by a method call
}

// this tests that the precedence for `!x as Y.Z` is still what we expect
pub fn precedence() {
let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
Expand Down
104 changes: 82 additions & 22 deletions src/test/ui/parser/issue-35813-postfix-after-cast.stderr
8000
Original file line number Diff line number Diff line change
Expand Up @@ -22,68 +22,128 @@ error: casts cannot be followed by indexing
LL | (&[0i32]): &[i32; 1][0];
| ^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `((&[0i32]): &[i32; 1])`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:39:13
|
LL | let _ = 0i32: i32: i32.count_ones();
| ^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32: i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:41:13
|
LL | let _ = 0 as i32: i32.count_ones();
| ^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0 as i32: i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:43:13
|
LL | let _ = 0i32: i32 as i32.count_ones();
| ^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:45:13
|
LL | let _ = 0 as i32 as i32.count_ones();
| ^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0 as i32 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:47:13
|
LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32: i32 as u32 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:49:13
|
LL | let _ = 0i32: i32.count_ones(): u32;
| ^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:51:13
|
LL | let _ = 0 as i32.count_ones(): u32;
| ^^^^^^^^ help: try surrounding the expression in parentheses: `(0 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:53:13
|
LL | let _ = 0i32: i32.count_ones() as u32;
| ^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:55:13
|
LL | let _ = 0 as i32.count_ones() as u32;
| ^^^^^^^^ help: try surrounding the expression in parentheses: `(0 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:57:13
|
LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
| ^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(0i32: i32: i32)`

error: casts cannot be followed by indexing
--> $DIR/issue-35813-postfix-after-cast.rs:40:18
--> $DIR/issue-35813-postfix-after-cast.rs:63:18
|
LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(&vec![1, 2, 3] as &Vec<i32>)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:45:5
--> $DIR/issue-35813-postfix-after-cast.rs:68:5
|
LL | 0 as i32.max(0);
| ^^^^^^^^ help: try surrounding the expression in parentheses: `(0 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:47:5
--> $DIR/issue-35813-postfix-after-cast.rs:70:5
|
LL | 0: i32.max(0);
| ^^^^^^ help: try surrounding the expression in parentheses: `(0: i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:62:8
--> $DIR/issue-35813-postfix-after-cast.rs:85:8
|
LL | if 5u64 as i32.max(0) == 0 {
| ^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(5u64 as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:65:8
--> $DIR/issue-35813-postfix-after-cast.rs:88:8
|
LL | if 5u64: u64.max(0) == 0 {
| ^^^^^^^^^ help: try surrounding the expression in parentheses: `(5u64: u64)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:72:9
--> $DIR/issue-35813-postfix-after-cast.rs:95:9
|
LL | 5u64 as u32.max(0) == 0
| ^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(5u64 as u32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:76:9
--> $DIR/issue-35813-postfix-after-cast.rs:99:9
|
LL | 5u64: u64.max(0) == 0
| ^^^^^^^^^ help: try surrounding the expression in parentheses: `(5u64: u64)`

error: casts cannot be followed by indexing
--> $DIR/issue-35813-postfix-after-cast.rs:81:24
--> $DIR/issue-35813-postfix-after-cast.rs:104:24
|
LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
| ^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(&[1,2,3] as &[i32])`

error: casts cannot be followed by indexing
--> $DIR/issue-35813-postfix-after-cast.rs:84:25
--> $DIR/issue-35813-postfix-after-cast.rs:107:25
|
LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(&[1i32,2,3]: &[i32; 3])`

error: casts cannot be followed by ?
--> $DIR/issue-35813-postfix-after-cast.rs:89:5
--> $DIR/issue-35813-postfix-after-cast.rs:112:5
|
LL | Err(0u64) as Result<u64,u64>?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(Err(0u64) as Result<u64,u64>)`

error: casts cannot be followed by ?
--> $DIR/issue-35813-postfix-after-cast.rs:91:5
--> $DIR/issue-35813-postfix-after-cast.rs:114:5
|
LL | Err(0u64): Result<u64,u64>?;
| ^^^^^^^^^-^^^^^^^^^^^^^^^^
Expand All @@ -94,25 +154,25 @@ LL | Err(0u64): Result<u64,u64>?;
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information

error: casts cannot be followed by a function call
--> $DIR/issue-35813-postfix-after-cast.rs:115:5
--> $DIR/issue-35813-postfix-after-cast.rs:138:5
|
LL | drop as fn(u8)(0);
| ^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(drop as fn(u8))`

error: casts cannot be followed by a function call
--> $DIR/issue-35813-postfix-after-cast.rs:117:5
--> $DIR/issue-35813-postfix-after-cast.rs:140:5
|
LL | drop_ptr: fn(u8)(0);
| ^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(drop_ptr: fn(u8))`

error: casts cannot be followed by `.await`
--> $DIR/issue-35813-postfix-after-cast.rs:122:5
--> $DIR/issue-35813-postfix-after-cast.rs:145:5
|
LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>)`

error: casts cannot be followed by `.await`
--> $DIR/issue-35813-postfix-after-cast.rs:125:5
--> $DIR/issue-35813-postfix-after-cast.rs:148:5
|
LL | Box::pin(noop()): Pin<Box<_>>.await;
| ^^^^^^^^^^^^^^^^-^^^^^^^^^^^^
Expand All @@ -123,41 +183,41 @@ LL | Box::pin(noop()): Pin<Box<_>>.await;
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information

error: casts cannot be followed by a field access
--> $DIR/issue-35813-postfix-after-cast.rs:137:5
--> $DIR/issue-35813-postfix-after-cast.rs:160:5
|
LL | Foo::default() as Foo.bar;
| ^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(Foo::default() as Foo)`

error: casts cannot be followed by a field access
--> $DIR/issue-35813-postfix-after-cast.rs:139:5
--> $DIR/issue-35813-postfix-after-cast.rs:162:5
|
LL | Foo::default(): Foo.bar;
| ^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(Foo::default(): Foo)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:54:9
--> $DIR/issue-35813-postfix-after-cast.rs:77:9
|
LL | if true { 33 } else { 44 } as i32.max(0),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(if true { 33 } else { 44 } as i32)`

error: casts cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:56:9
--> $DIR/issue-35813-postfix-after-cast.rs:79:9
|
LL | if true { 33 } else { 44 }: i32.max(0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try surrounding the expression in parentheses: `(if true { 33 } else { 44 }: i32)`

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/issue-35813-postfix-after-cast.rs:101:13
--> $DIR/issue-35813-postfix-after-cast.rs:124:13
|
LL | drop as F();
| ^^^ only `Fn` traits may use parentheses

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/issue-35813-postfix-after-cast.rs:103:15
--> $DIR/issue-35813-postfix-after-cast.rs:126:15
|
LL | drop_ptr: F();
| ^^^ only `Fn` traits may use parentheses

error: aborting due to 25 previous errors
error: aborting due to 35 previous errors

For more information about this error, try `rustc --explain E0214`.
0