1
Fork 0

fix most compiler/ doctests

This commit is contained in:
Elliot Roberts 2022-04-15 15:04:34 -07:00
parent bf611439e3
commit 7907385999
116 changed files with 666 additions and 609 deletions

View file

@ -371,9 +371,10 @@ impl<'a> Parser<'a> {
}
/// Matches the following grammar (per RFC 1559).
///
/// meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ;
/// meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ;
/// ```ebnf
/// meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ;
/// meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ;
/// ```
pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> {
let nt_meta = match self.token.kind {
token::Interpolated(ref nt) => match **nt {

View file

@ -485,7 +485,7 @@ impl<'a> Parser<'a> {
/// Parses an implementation item.
///
/// ```
/// ```ignore (illustrative)
/// impl<'a, T> TYPE { /* impl items */ }
/// impl<'a, T> TRAIT for TYPE { /* impl items */ }
/// impl<'a, T> !TRAIT for TYPE { /* impl items */ }
@ -493,7 +493,7 @@ impl<'a> Parser<'a> {
/// ```
///
/// We actually parse slightly more relaxed grammar for better error reporting and recovery.
/// ```
/// ```ebnf
/// "impl" GENERICS "const"? "!"? TYPE "for"? (TYPE | "..") ("where" PREDICATES)? "{" BODY "}"
/// "impl" GENERICS "const"? "!"? TYPE ("where" PREDICATES)? "{" BODY "}"
/// ```
@ -806,7 +806,7 @@ impl<'a> Parser<'a> {
}
/// Parses a `type` alias with the following grammar:
/// ```
/// ```ebnf
/// TypeAlias = "type" Ident Generics {":" GenericBounds}? {"=" Ty}? ";" ;
/// ```
/// The `"type"` has already been eaten.
@ -930,7 +930,7 @@ impl<'a> Parser<'a> {
///
/// # Examples
///
/// ```
/// ```ignore (illustrative)
/// extern crate foo;
/// extern crate bar as foo;
/// ```
@ -1630,7 +1630,7 @@ impl<'a> Parser<'a> {
/// Parses a declarative macro 2.0 definition.
/// The `macro` keyword has already been parsed.
/// ```
/// ```ebnf
/// MacBody = "{" TOKEN_STREAM "}" ;
/// MacParams = "(" TOKEN_STREAM ")" ;
/// DeclMac = "macro" Ident MacParams? MacBody ;

View file

@ -52,7 +52,7 @@ pub(super) enum RecoverQuestionMark {
/// Signals whether parsing a type should recover `->`.
///
/// More specifically, when parsing a function like:
/// ```rust
/// ```compile_fail
/// fn foo() => u8 { 0 }
/// fn bar(): u8 { 0 }
/// ```
@ -499,12 +499,12 @@ impl<'a> Parser<'a> {
}
/// Parses a function pointer type (`TyKind::BareFn`).
/// ```
/// [unsafe] [extern "ABI"] fn (S) -> T
/// ^~~~~^ ^~~~^ ^~^ ^
/// | | | |
/// | | | Return type
/// Function Style ABI Parameter types
/// ```ignore (illustrative)
/// [unsafe] [extern "ABI"] fn (S) -> T
/// // ^~~~~^ ^~~~^ ^~^ ^
/// // | | | |
/// // | | | Return type
/// // Function Style ABI Parameter types
/// ```
/// We actually parse `FnHeader FnDecl`, but we error on `const` and `async` qualifiers.
fn parse_ty_bare_fn(
@ -707,7 +707,7 @@ impl<'a> Parser<'a> {
}
/// Parses a bound according to the grammar:
/// ```
/// ```ebnf
/// BOUND = TY_BOUND | LT_BOUND
/// ```
fn parse_generic_bound(&mut self) -> PResult<'a, Result<GenericBound, Span>> {
@ -729,7 +729,7 @@ impl<'a> Parser<'a> {
}
/// Parses a lifetime ("outlives") bound, e.g. `'a`, according to:
/// ```
/// ```ebnf
/// LT_BOUND = LIFETIME
/// ```
fn parse_generic_lt_bound(
@ -787,7 +787,7 @@ impl<'a> Parser<'a> {
///
/// If no modifiers are present, this does not consume any tokens.
///
/// ```
/// ```ebnf
/// TY_BOUND_MODIFIERS = ["~const"] ["?"]
/// ```
fn parse_ty_bound_modifiers(&mut self) -> PResult<'a, BoundModifiers> {
@ -807,7 +807,7 @@ impl<'a> Parser<'a> {
}
/// Parses a type bound according to:
/// ```
/// ```ebnf
/// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
/// TY_BOUND_NOPAREN = [TY_BOUND_MODIFIERS] [for<LT_PARAM_DEFS>] SIMPLE_PATH
/// ```