- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Stabilize Frontmatter #148051
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
          
     Open
      
      
            epage
  wants to merge
  1
  commit into
  rust-lang:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
epage:frontmatter
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Stabilize Frontmatter #148051
Changes from all commits
      Commits
    
    
  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
    
  
  
    
              
              |         
                  jieyouxu marked this conversation as resolved.
              Show resolved
            Hide resolved | 
  
    
      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
    
  
  
    
              
        
          
          
            25 changes: 0 additions & 25 deletions
          
          25 
        
  src/doc/unstable-book/src/language-features/frontmatter.md
  
  
      
      
   
        
      
      
    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
    
  
  
    
              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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
|  | @@ -5,6 +5,4 @@ x ---🚧️ | |
| // Regression test for #141483 | ||
| //@check-pass | ||
|  | ||
| #![feature(frontmatter)] | ||
|  | ||
| 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 | 
|---|---|---|
|  | @@ -6,6 +6,4 @@ x ---y | |
| // non-whitespace character preceding them. | ||
| //@check-pass | ||
|  | ||
| #![feature(frontmatter)] | ||
|  | ||
| 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
    
  
  
    
              
              
  
    
      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,14 +1,13 @@ | ||
| ---cargo | ||
| //~^ ERROR: unclosed frontmatter | ||
|  | ||
| //@ compile-flags: --crate-type lib | ||
|  | ||
| #![feature(frontmatter)] | ||
|  | ||
| fn foo(x: i32) -> i32 { | ||
| ---x | ||
| //~^ WARNING: use of a double negation [double_negations] | ||
| //~^ ERROR invalid preceding whitespace for frontmatter close | ||
| //~^^ ERROR extra characters after frontmatter close are not allowed | ||
| } | ||
| //~^ ERROR unexpected closing delimiter: `}` | ||
|  | ||
| // this test is for the weird case that valid Rust code can have three dashes | ||
| // within them and get treated as a frontmatter close. | 
  
    
      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,30 +1,26 @@ | ||
| error: unclosed frontmatter | ||
| --> $DIR/fence-indented-mismatch.rs:1:1 | ||
| error: invalid preceding whitespace for frontmatter close | ||
| --> $DIR/fence-indented-mismatch.rs:6:1 | ||
| | | ||
| LL | / ---cargo | ||
| ... | | ||
| LL | | | ||
| | |_^ | ||
| LL | ---x | ||
| | ^^^^^^^^ | ||
| | | ||
| note: frontmatter opening here was not closed | ||
| --> $DIR/fence-indented-mismatch.rs:1:1 | ||
| note: frontmatter close should not be preceded by whitespace | ||
| --> $DIR/fence-indented-mismatch.rs:6:1 | ||
| | | ||
| LL | ---cargo | ||
| | ^^^ | ||
| LL | ---x | ||
| | ^^^^ | ||
|  | ||
| warning: use of a double negation | ||
| --> $DIR/fence-indented-mismatch.rs:9:6 | ||
| error: extra characters after frontmatter close are not allowed | ||
| --> $DIR/fence-indented-mismatch.rs:6:1 | ||
| | | ||
| LL | ---x | ||
| | ^^^ | ||
| | | ||
| = note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages | ||
| = note: use `-= 1` if you meant to decrement the value | ||
| = note: `#[warn(double_negations)]` on by default | ||
| help: add parentheses for clarity | ||
| | ^^^^^^^^ | ||
|  | ||
| error: unexpected closing delimiter: `}` | ||
| --> $DIR/fence-indented-mismatch.rs:9:1 | ||
| | | ||
| LL | --(-x) | ||
| | + + | ||
| LL | } | ||
| | ^ unexpected closing delimiter | ||
|  | ||
| error: aborting due to 1 previous error; 1 warning emitted | ||
| 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
    
  
  
    
              
  
    
      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,15 +1,12 @@ | ||
| ----cargo | ||
| //~^ ERROR: unclosed frontmatter | ||
| //~| ERROR: frontmatters are experimental | ||
|  | ||
| //@ compile-flags: --crate-type lib | ||
|  | ||
| // Leading whitespace on the feature line prevents recovery. However | ||
| // the dashes quoted will not be used for recovery and the entire file | ||
| // should be treated as within the frontmatter block. | ||
|  | ||
| #![feature(frontmatter)] | ||
|  | ||
| fn foo() -> &str { | ||
| "----" | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      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.
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.
(Commenting on an arbitrary line to make this discussion threaded)
From the PR description (emphasis and ellipses mine):
In #146340 I actually struck a (temporary) compromise: We do still strip/lex/recognize frontmatter (and shebang) in item-context
include!s. However, we no longer strip frontmatter in expression/statement-contextinclude!s like inlet _ = include!(…);(to prevent the manifold negation backcompat issue you've rightly mentioned).Now, I don't know what's best here. I'm eager to know your and T-lang's stance on the matter. Note that we do strip shebang in expression/statement-context
include!s which I consider to be quite odd (but still understandable on a lexical level). I have an open PR #146377 which would stop stripping shebang in that position, too. I still need to rebase+polish, lang-nominate and possibly crater it. The outcome of that T-lang discussion likely affects the decision mentioned in the first paragraph (†).(†): If that PR was accepted it would mean that we would strip shebang+frontmatter in item-ctxt includes and wouldn't strip either(!) shebang or frontmatter in expr/stmt-ctxt includes which would make the behavior of shebang+frontmatter consistent thereby fulfilling the original goal of "This applies anywhere shebang stripping is performed." in this specific case (obviously the goal wasn't achieved in other cases, like in the proc_macro API case).
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.
Thanks! I've updated the stabilization report as well as linked to your comment as a place for discussing it.