- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Stabilize unrestricted_attribute_tokens
          #57367
        
          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 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| // compile-pass | ||
| #![feature(custom_attribute)] | ||
|  | ||
| #![feature(custom_attribute, unrestricted_attribute_tokens)] | ||
|  | ||
| #[my_attr = !] // OK under feature gate | ||
| #[my_attr = !] //~ ERROR unexpected token: `!` | ||
| 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,8 @@ | ||
| error: unexpected token: `!` | ||
| --> $DIR/attr-eq-token-tree.rs:3:11 | ||
| | | ||
| LL | #[my_attr = !] //~ ERROR unexpected token: `!` | ||
| | ^ | ||
|  | ||
| error: aborting due to previous error | ||
|  | 
        
          
          
            7 changes: 0 additions & 7 deletions
          
          7 
        
  src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            20 changes: 0 additions & 20 deletions
          
          20 
        
  src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr
  
  
      
      
   
        
      
      
    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,4 +1,2 @@ | ||
| #![feature(unrestricted_attribute_tokens)] | ||
|  | ||
| #[doc = $not_there] //~ ERROR expected `]`, found `not_there` | ||
| #[doc = $not_there] //~ ERROR unexpected token: `$` | ||
| 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 | 
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| error: expected `]`, found `not_there` | ||
| --> $DIR/macro-attribute.rs:3:10 | ||
| error: unexpected token: `$` | ||
| --> $DIR/macro-attribute.rs:1:7 | ||
| | | ||
| LL | #[doc = $not_there] //~ ERROR expected `]`, found `not_there` | ||
| | ^^^^^^^^^ expected `]` | ||
| LL | #[doc = $not_there] //~ ERROR unexpected token: `$` | ||
| | ^ | ||
|  | ||
| error: aborting due to 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,18 @@ | ||
| #![feature(custom_attribute)] | ||
|  | ||
| macro_rules! check { | ||
| ($expr: expr) => ( | ||
| #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in attributes | ||
| //~| ERROR unexpected token: `-0` | ||
| //~| ERROR unexpected token: `0 + 0` | ||
| use main as _; | ||
| ); | ||
| } | ||
|  | ||
| check!("0"); // OK | ||
| check!(0); // OK | ||
| check!(0u8); // ERROR, see above | ||
| check!(-0); // ERROR, see above | ||
| check!(0 + 0); // ERROR, see above | ||
|  | ||
| 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,31 @@ | ||
| error: suffixed literals are not allowed in attributes | ||
| --> $DIR/malformed-interpolated.rs:5:21 | ||
| | | ||
| LL | #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in attributes | ||
| | ^^^^^ | ||
| ... | ||
| LL | check!(0u8); // ERROR, see above | ||
| | ------------ in this macro invocation | ||
| | | ||
| = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). | ||
|  | ||
| error: unexpected token: `-0` | ||
| --> $DIR/malformed-interpolated.rs:5:19 | ||
| | | ||
| LL | #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in attributes | ||
| | ^ | ||
| ... | ||
| LL | check!(-0); // ERROR, see above | ||
| | ----------- in this macro invocation | ||
|  | ||
| error: unexpected token: `0 + 0` | ||
| --> $DIR/malformed-interpolated.rs:5:19 | ||
| | | ||
| LL | #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in attributes | ||
| | ^ | ||
| ... | ||
| LL | check!(0 + 0); // ERROR, see above | ||
| | -------------- in this macro invocation | ||
|  | ||
| error: aborting due to 3 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
    
  
  
    
              
        
          
          
            12 changes: 6 additions & 6 deletions
          
          12 
        
  src/test/ui/marker_trait_attr/marker-attribute-with-values.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,20 +1,20 @@ | ||
| error: attribute must be of the form `#[marker]` | ||
| --> $DIR/marker-attribute-with-values.rs:4:1 | ||
| --> $DIR/marker-attribute-with-values.rs:3:1 | ||
| | | ||
| LL | #[marker(always)] | ||
| | ^^^^^^^^^^^^^^^^^ | ||
|  | ||
| error: attribute must be of the form `#[marker]` | ||
| --> $DIR/marker-attribute-with-values.rs:8:1 | ||
| --> $DIR/marker-attribute-with-values.rs:7:1 | ||
| | | ||
| LL | #[marker("never")] | ||
| | ^^^^^^^^^^^^^^^^^^ | ||
|  | ||
| error: expected unsuffixed literal or identifier, found value | ||
| --> $DIR/marker-attribute-with-values.rs:12:10 | ||
| error: attribute must be of the form `#[marker]` | ||
| --> $DIR/marker-attribute-with-values.rs:11:1 | ||
| | | ||
| LL | #[marker(key = value)] | ||
| | ^^^ | ||
| LL | #[marker(key = "value")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|  | ||
| error: aborting due to 3 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 | 
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| error: unexpected token: `]` | ||
| --> $DIR/attr-bad-meta-2.rs:1:9 | ||
| --> $DIR/attr-bad-meta-2.rs:1:8 | ||
| | | ||
| LL | #[path =] //~ ERROR unexpected token: `]` | ||
| | ^ unexpected token after this | ||
| | ^ | ||
|  | ||
| error: aborting due to 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 | 
|---|---|---|
| @@ -1,4 +1,2 @@ | ||
| #![feature(unrestricted_attribute_tokens)] | ||
|  | ||
| #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` | ||
| mod m {} | 
  
    
      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 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| // compile-pass | ||
|  | ||
| #![feature(custom_attribute, unrestricted_attribute_tokens)] | ||
| #![feature(custom_attribute)] | ||
|  | ||
| #[my_attr(a b c d)] | ||
| #[my_attr[a b c d]] | ||
| #[my_attr{a b c d}] | ||
| fn main() {} | 
  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.