- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Accept tuple.0.0 as tuple indexing (take 2) #71322
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
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8e256b1
              
                parser: Break float tokens into parts in tuple field positions
              
              
                petrochenkov 40a2170
              
                Add test of tuple nested indexing
              
              
                dtolnay 0432f63
              
                Test even deeper nested indexing
              
              
                dtolnay 776deb6
              
                Test a range, which is not nested indexing
              
              
                dtolnay 6dfa549
              
                Add tests in which the token really is a float
              
              
                dtolnay 3814eec
              
                Add test for tuple indexed with float in macro input
              
              
                dtolnay 63f95a4
              
                Add test for errors triggered on parts of decomposed index
              
              
                dtolnay 64a88db
              
                Update dtolnay's tests that now work
              
              
                petrochenkov 52bdaaa
              
                Add some requested tests
              
              
                petrochenkov 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| struct S(u8, (u8, u8)); | ||
| 
     | 
||
| macro_rules! generate_field_accesses { | ||
| ($a:tt, $b:literal, $c:expr) => { | ||
| let s = S(0, (0, 0)); | ||
| 
     | 
||
| s.$a; // OK | ||
| { s.$b; } //~ ERROR unexpected token: `1.1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1` | ||
| { s.$c; } //~ ERROR unexpected token: `1.1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1` | ||
| }; | ||
| } | ||
| 
     | 
||
| fn main() { | ||
| generate_field_accesses!(1.1, 1.1, 1.1); | ||
| } | 
  
    
      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,46 @@ | ||
| error: unexpected token: `1.1` | ||
| --> $DIR/float-field-interpolated.rs:8:13 | ||
| | | ||
| LL | { s.$b; } | ||
| | ^^ | ||
| ... | ||
| LL | generate_field_accesses!(1.1, 1.1, 1.1); | ||
| | ---------------------------------------- in this macro invocation | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| 
     | 
||
| error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1` | ||
| --> $DIR/float-field-interpolated.rs:8:13 | ||
| | | ||
| LL | { s.$b; } | ||
| | ^^ expected one of `.`, `;`, `?`, `}`, or an operator | ||
| ... | ||
| LL | generate_field_accesses!(1.1, 1.1, 1.1); | ||
| | ---------------------------------------- in this macro invocation | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| 
     | 
||
| error: unexpected token: `1.1` | ||
| --> $DIR/float-field-interpolated.rs:10:13 | ||
| | | ||
| LL | { s.$c; } | ||
| | ^^ | ||
| ... | ||
| LL | generate_field_accesses!(1.1, 1.1, 1.1); | ||
| | ---------------------------------------- in this macro invocation | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| 
     | 
||
| error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1` | ||
| --> $DIR/float-field-interpolated.rs:10:13 | ||
| | | ||
| LL | { s.$c; } | ||
| | ^^ expected one of `.`, `;`, `?`, `}`, or an operator | ||
| ... | ||
| LL | generate_field_accesses!(1.1, 1.1, 1.1); | ||
| | ---------------------------------------- in this macro invocation | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| 
     | 
||
| error: aborting due to 4 previous errors | ||
| 
     | 
  
    
      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,62 @@ | ||
| struct S(u8, (u8, u8)); | ||
| 
     | 
||
| fn main() { | ||
| let s = S(0, (0, 0)); | ||
| 
     | 
||
| s.1e1; //~ ERROR no field `1e1` on type `S` | ||
| s.1.; //~ ERROR unexpected token: `;` | ||
| s.1.1; | ||
| s.1.1e1; //~ ERROR no field `1e1` on type `(u8, u8)` | ||
| { s.1e+; } //~ ERROR unexpected token: `1e+` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+` | ||
| //~| ERROR expected at least one digit in exponent | ||
| { s.1e-; } //~ ERROR unexpected token: `1e-` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-` | ||
| //~| ERROR expected at least one digit in exponent | ||
| { s.1e+1; } //~ ERROR unexpected token: `1e+1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+1` | ||
| { s.1e-1; } //~ ERROR unexpected token: `1e-1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-1` | ||
| { s.1.1e+1; } //~ ERROR unexpected token: `1.1e+1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e+1` | ||
| { s.1.1e-1; } //~ ERROR unexpected token: `1.1e-1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e-1` | ||
| s.0x1e1; //~ ERROR no field `0x1e1` on type `S` | ||
| s.0x1.; //~ ERROR no field `0x1` on type `S` | ||
| //~| ERROR hexadecimal float literal is not supported | ||
| //~| ERROR unexpected token: `;` | ||
| s.0x1.1; //~ ERROR no field `0x1` on type `S` | ||
| //~| ERROR hexadecimal float literal is not supported | ||
| s.0x1.1e1; //~ ERROR no field `0x1` on type `S` | ||
| //~| ERROR hexadecimal float literal is not supported | ||
| { s.0x1e+; } //~ ERROR expected expression, found `;` | ||
| { s.0x1e-; } //~ ERROR expected expression, found `;` | ||
| s.0x1e+1; //~ ERROR no field `0x1e` on type `S` | ||
| s.0x1e-1; //~ ERROR no field `0x1e` on type `S` | ||
| { s.0x1.1e+1; } //~ ERROR unexpected token: `0x1.1e+1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e+1` | ||
| //~| ERROR hexadecimal float literal is not supported | ||
| { s.0x1.1e-1; } //~ ERROR unexpected token: `0x1.1e-1` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e-1` | ||
| //~| ERROR hexadecimal float literal is not supported | ||
| s.1e1f32; //~ ERROR no field `1e1` on type `S` | ||
| //~| ERROR suffixes on a tuple index are invalid | ||
| s.1.f32; //~ ERROR no field `f32` on type `(u8, u8)` | ||
| s.1.1f32; //~ ERROR suffixes on a tuple index are invalid | ||
| s.1.1e1f32; //~ ERROR no field `1e1` on type `(u8, u8)` | ||
| //~| ERROR suffixes on a tuple index are invalid | ||
| { s.1e+f32; } //~ ERROR unexpected token: `1e+f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+f32` | ||
| //~| ERROR expected at least one digit in exponent | ||
| { s.1e-f32; } //~ ERROR unexpected token: `1e-f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-f32` | ||
| //~| ERROR expected at least one digit in exponent | ||
| { s.1e+1f32; } //~ ERROR unexpected token: `1e+1f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+1f32` | ||
| { s.1e-1f32; } //~ ERROR unexpected token: `1e-1f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-1f32` | ||
| { s.1.1e+1f32; } //~ ERROR unexpected token: `1.1e+1f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e+1f32` | ||
| { s.1.1e-1f32; } //~ ERROR unexpected token: `1.1e-1f32` | ||
| //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e-1f32` | ||
| } | ||
      
      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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.