- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Recover and suggest to use ; to construct array type
          #143905
        
          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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| fn main() { | ||
| let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` | ||
| let x: [isize 3]; //~ ERROR expected `;` or `]`, found `3` | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` | ||
| error: expected `;` or `]`, found `3` | ||
| --> $DIR/better-expected.rs:2:19 | ||
| | | ||
| LL | let x: [isize 3]; | ||
| | - ^ expected one of 7 possible tokens | ||
| | | | ||
| | while parsing the type for `x` | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL | let x: [isize ;3]; | ||
| | + | ||
|  | ||
| error: aborting due to 1 previous error | ||
|  | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // There is a regression introduced for issue #143828 | ||
| //@ edition: 2015 | ||
|  | ||
| #![allow(dead_code)] | ||
| trait Foo { | ||
| fn foo([a, b]: [i32; 2]) {} | ||
| //~^ ERROR: expected `;` or `]`, found `,` | ||
| //~| ERROR: patterns aren't allowed in methods without bodies | ||
| } | ||
|  | ||
| fn main() {} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| error: expected `;` or `]`, found `,` | ||
| --> $DIR/error-pattern-issue-50571.rs:6:14 | ||
| | | ||
| LL | fn foo([a, b]: [i32; 2]) {} | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL - fn foo([a, b]: [i32; 2]) {} | ||
| LL + fn foo([a; b]: [i32; 2]) {} | ||
| | | ||
|  | ||
| error[E0642]: patterns aren't allowed in methods without bodies | ||
| --> $DIR/error-pattern-issue-50571.rs:6:12 | ||
| | | ||
| LL | fn foo([a, b]: [i32; 2]) {} | ||
| | ^^^^^^ | ||
| | | ||
| help: give this argument a name or use an underscore to ignore it | ||
| | | ||
| LL - fn foo([a, b]: [i32; 2]) {} | ||
| LL + fn foo(_: [i32; 2]) {} | ||
| | | ||
|  | ||
| error: aborting due to 2 previous errors | ||
|  | ||
| For more information about this error, try `rustc --explain E0642`. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // when the next token is not a semicolon, | ||
| // we should suggest to use semicolon if recovery is allowed | ||
| // See issue #143828 | ||
|  | ||
| fn main() { | ||
| let x = 5; | ||
| let b: [i32, 5]; | ||
| //~^ ERROR expected `;` or `]`, found `,` | ||
| let a: [i32, ]; | ||
| //~^ ERROR expected `;` or `]`, found `,` | ||
| //~| ERROR expected value, found builtin type `i32` [E0423] | ||
| let c: [i32, x]; | ||
| //~^ ERROR expected `;` or `]`, found `,` | ||
| //~| ERROR attempt to use a non-constant value in a constant [E0435] | ||
| let e: [i32 5]; | ||
| //~^ ERROR expected `;` or `]`, found `5` | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| error: expected `;` or `]`, found `,` | ||
| --> $DIR/array-type-no-semi.rs:7:16 | ||
| | | ||
| LL | let b: [i32, 5]; | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL - let b: [i32, 5]; | ||
| LL + let b: [i32; 5]; | ||
| | | ||
|  | ||
| error: expected `;` or `]`, found `,` | ||
| --> $DIR/array-type-no-semi.rs:9:16 | ||
| | | ||
| LL | let a: [i32, ]; | ||
| | - ^ expected `;` or `]` | ||
| | | | ||
| | while parsing the type for `a` | ||
| | help: use `=` if you meant to assign | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
|  | ||
| error: expected `;` or `]`, found `,` | ||
| --> $DIR/array-type-no-semi.rs:12:16 | ||
| | | ||
| LL | let c: [i32, x]; | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL - let c: [i32, x]; | ||
| LL + let c: [i32; x]; | ||
| | | ||
|  | ||
| error: expected `;` or `]`, found `5` | ||
| --> $DIR/array-type-no-semi.rs:15:17 | ||
| | | ||
| LL | let e: [i32 5]; | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL | let e: [i32 ;5]; | ||
| | + | ||
|  | ||
| error[E0435]: attempt to use a non-constant value in a constant | ||
| --> $DIR/array-type-no-semi.rs:12:18 | ||
| | | ||
| LL | let c: [i32, x]; | ||
| | ^ non-constant value | ||
| | | ||
| help: consider using `const` instead of `let` | ||
| | | ||
| LL - let x = 5; | ||
| LL + const x: /* Type */ = 5; | ||
| | | ||
|  | ||
| error[E0423]: expected value, found builtin type `i32` | ||
| --> $DIR/array-type-no-semi.rs:9:13 | ||
| | | ||
| LL | let a: [i32, ]; | ||
| | ^^^ not a value | ||
|  | ||
| error: aborting due to 6 previous errors | ||
|  | ||
| Some errors have detailed explanations: E0423, E0435. | ||
| For more information about an error, try `rustc --explain E0423`. | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1 +1,6 @@ | ||
| type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` | ||
| type v = [isize * 3]; | ||
| //~^ ERROR expected `;` or `]`, found `*` | ||
| //~| WARN type `v` should have an upper camel case name [non_camel_case_types] | ||
|  | ||
|  | ||
| fn main() {} | 
        
          
          
            21 changes: 18 additions & 3 deletions
          
          21 
        
  tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,8 +1,23 @@ | ||
| error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` | ||
| error: expected `;` or `]`, found `*` | ||
| --> $DIR/removed-syntax-fixed-vec.rs:1:17 | ||
| | | ||
| LL | type v = [isize * 3]; | ||
| | ^ expected one of 7 possible tokens | ||
| | ^ expected `;` or `]` | ||
| | | ||
| = note: you might have meant to write a slice or array type | ||
| help: you might have meant to use `;` as the separator | ||
| | | ||
| LL - type v = [isize * 3]; | ||
| LL + type v = [isize ; 3]; | ||
| | | ||
|  | ||
| warning: type `v` should have an upper camel case name | ||
| --> $DIR/removed-syntax-fixed-vec.rs:1:6 | ||
| | | ||
| LL | type v = [isize * 3]; | ||
| | ^ help: convert the identifier to upper camel case (notice the capitalization): `V` | ||
| | | ||
| = note: `#[warn(non_camel_case_types)]` on by default | ||
|  | ||
| error: aborting due to 1 previous error | ||
| error: aborting due to 1 previous error; 1 warning emitted | ||
|  | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the new case like
[i32 5].