rustc_errors: let DiagnosticBuilder::emit
return a "guarantee of emission".
This commit is contained in:
parent
0b9d70cf6d
commit
b7e95dee65
83 changed files with 842 additions and 471 deletions
|
@ -3,7 +3,7 @@ use rustc_ast::ptr::P;
|
|||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, PResult};
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_parse_format as parse;
|
||||
|
@ -30,7 +30,7 @@ fn parse_args<'a>(
|
|||
sp: Span,
|
||||
tts: TokenStream,
|
||||
is_global_asm: bool,
|
||||
) -> Result<AsmArgs, DiagnosticBuilder<'a>> {
|
||||
) -> PResult<'a, AsmArgs> {
|
||||
let mut p = ecx.new_parser_from_tts(tts);
|
||||
let sess = &ecx.sess.parse_sess;
|
||||
parse_asm_args(&mut p, sess, sp, is_global_asm)
|
||||
|
@ -43,7 +43,7 @@ pub fn parse_asm_args<'a>(
|
|||
sess: &'a ParseSess,
|
||||
sp: Span,
|
||||
is_global_asm: bool,
|
||||
) -> Result<AsmArgs, DiagnosticBuilder<'a>> {
|
||||
) -> PResult<'a, AsmArgs> {
|
||||
let diag = &sess.span_diagnostic;
|
||||
|
||||
if p.token == token::Eof {
|
||||
|
@ -390,7 +390,7 @@ fn parse_options<'a>(
|
|||
p: &mut Parser<'a>,
|
||||
args: &mut AsmArgs,
|
||||
is_global_asm: bool,
|
||||
) -> Result<(), DiagnosticBuilder<'a>> {
|
||||
) -> PResult<'a, ()> {
|
||||
let span_start = p.prev_token.span;
|
||||
|
||||
p.expect(&token::OpenDelim(token::DelimToken::Paren))?;
|
||||
|
@ -431,10 +431,7 @@ fn parse_options<'a>(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_clobber_abi<'a>(
|
||||
p: &mut Parser<'a>,
|
||||
args: &mut AsmArgs,
|
||||
) -> Result<(), DiagnosticBuilder<'a>> {
|
||||
fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a, ()> {
|
||||
let span_start = p.prev_token.span;
|
||||
|
||||
p.expect(&token::OpenDelim(token::DelimToken::Paren))?;
|
||||
|
@ -501,7 +498,7 @@ fn parse_clobber_abi<'a>(
|
|||
fn parse_reg<'a>(
|
||||
p: &mut Parser<'a>,
|
||||
explicit_reg: &mut bool,
|
||||
) -> Result<ast::InlineAsmRegOrRegClass, DiagnosticBuilder<'a>> {
|
||||
) -> PResult<'a, ast::InlineAsmRegOrRegClass> {
|
||||
p.expect(&token::OpenDelim(token::DelimToken::Paren))?;
|
||||
let result = match p.token.uninterpolate().kind {
|
||||
token::Ident(name, false) => ast::InlineAsmRegOrRegClass::RegClass(name),
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustc_ast::token;
|
|||
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, PResult};
|
||||
use rustc_expand::base::*;
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
|
@ -83,11 +83,7 @@ struct Assert {
|
|||
custom_message: Option<TokenStream>,
|
||||
}
|
||||
|
||||
fn parse_assert<'a>(
|
||||
cx: &mut ExtCtxt<'a>,
|
||||
sp: Span,
|
||||
stream: TokenStream,
|
||||
) -> Result<Assert, DiagnosticBuilder<'a>> {
|
||||
fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<'a, Assert> {
|
||||
let mut parser = cx.new_parser_from_tts(stream);
|
||||
|
||||
if parser.token == token::Eof {
|
||||
|
|
|
@ -6,7 +6,7 @@ use rustc_ast as ast;
|
|||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_attr as attr;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::PResult;
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -29,11 +29,7 @@ pub fn expand_cfg(
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_cfg<'a>(
|
||||
cx: &mut ExtCtxt<'a>,
|
||||
sp: Span,
|
||||
tts: TokenStream,
|
||||
) -> Result<ast::MetaItem, DiagnosticBuilder<'a>> {
|
||||
fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
|
||||
if p.token == token::Eof {
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc_ast::tokenstream::TokenStream;
|
|||
use rustc_ast::visit::{self, Visitor};
|
||||
use rustc_ast::{token, BlockCheckMode, UnsafeSource};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{pluralize, Applicability, PResult};
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_parse_format as parse;
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
|
@ -130,7 +130,7 @@ fn parse_args<'a>(
|
|||
ecx: &mut ExtCtxt<'a>,
|
||||
sp: Span,
|
||||
tts: TokenStream,
|
||||
) -> Result<(P<ast::Expr>, Vec<P<ast::Expr>>, FxHashMap<Symbol, usize>), DiagnosticBuilder<'a>> {
|
||||
) -> PResult<'a, (P<ast::Expr>, Vec<P<ast::Expr>>, FxHashMap<Symbol, usize>)> {
|
||||
let mut args = Vec::<P<ast::Expr>>::new();
|
||||
let mut names = FxHashMap::<Symbol, usize>::default();
|
||||
|
||||
|
|
|
@ -376,9 +376,13 @@ fn get_test_runner(
|
|||
match &*meta_list {
|
||||
[single] => match single.meta_item() {
|
||||
Some(meta_item) if meta_item.is_word() => return Some(meta_item.path.clone()),
|
||||
_ => sd.struct_span_err(span, "`test_runner` argument must be a path").emit(),
|
||||
_ => {
|
||||
sd.struct_span_err(span, "`test_runner` argument must be a path").emit();
|
||||
}
|
||||
},
|
||||
_ => sd.struct_span_err(span, "`#![test_runner(..)]` accepts exactly 1 argument").emit(),
|
||||
_ => {
|
||||
sd.struct_span_err(span, "`#![test_runner(..)]` accepts exactly 1 argument").emit();
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue