2019-02-08 13:53:55 +00:00
|
|
|
//! The main parser interface.
|
2012-11-29 00:20:41 +00:00
|
|
|
|
2020-11-28 23:33:17 +00:00
|
|
|
#![feature(array_windows)]
|
2022-02-28 10:49:56 +00:00
|
|
|
#![feature(box_patterns)]
|
2021-08-16 15:29:49 +00:00
|
|
|
#![feature(if_let_guard)]
|
2022-11-10 01:06:11 +00:00
|
|
|
#![feature(iter_intersperse)]
|
2022-08-20 18:40:08 +00:00
|
|
|
#![feature(let_chains)]
|
2022-03-10 00:11:28 +00:00
|
|
|
#![feature(never_type)]
|
2022-06-22 12:24:35 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2021-03-14 18:12:04 +00:00
|
|
|
#![recursion_limit = "256"]
|
2019-10-15 20:48:13 +00:00
|
|
|
|
2021-09-20 15:24:47 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate tracing;
|
|
|
|
|
2020-04-27 17:56:11 +00:00
|
|
|
use rustc_ast as ast;
|
2022-05-21 12:50:39 +00:00
|
|
|
use rustc_ast::token;
|
|
|
|
use rustc_ast::tokenstream::TokenStream;
|
2022-11-18 00:24:21 +00:00
|
|
|
use rustc_ast::{AttrItem, Attribute, MetaItem};
|
2022-05-21 12:50:39 +00:00
|
|
|
use rustc_ast_pretty::pprust;
|
2020-01-11 14:03:15 +00:00
|
|
|
use rustc_data_structures::sync::Lrc;
|
2023-04-27 00:53:06 +00:00
|
|
|
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
|
2022-10-13 09:13:02 +00:00
|
|
|
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
2023-04-16 12:33:00 +00:00
|
|
|
use rustc_fluent_macro::fluent_messages;
|
2020-01-11 14:03:15 +00:00
|
|
|
use rustc_session::parse::ParseSess;
|
2020-11-23 06:43:55 +00:00
|
|
|
use rustc_span::{FileName, SourceFile, Span};
|
2019-02-06 17:33:01 +00:00
|
|
|
|
2020-03-08 21:10:37 +00:00
|
|
|
use std::path::Path;
|
2012-12-23 22:41:37 +00:00
|
|
|
|
2020-10-18 15:28:00 +00:00
|
|
|
pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
|
2015-03-28 21:58:51 +00:00
|
|
|
|
2015-01-06 17:24:46 +00:00
|
|
|
#[macro_use]
|
2013-01-09 03:37:25 +00:00
|
|
|
pub mod parser;
|
2023-02-22 06:09:57 +00:00
|
|
|
use parser::{make_unclosed_delims_error, Parser};
|
2014-12-19 04:09:57 +00:00
|
|
|
pub mod lexer;
|
2019-10-11 19:00:09 +00:00
|
|
|
pub mod validate_attr;
|
2019-04-25 08:48:25 +00:00
|
|
|
|
2022-08-30 11:19:17 +00:00
|
|
|
mod errors;
|
|
|
|
|
2023-03-02 23:18:38 +00:00
|
|
|
fluent_messages! { "../messages.ftl" }
|
2022-10-13 09:13:02 +00:00
|
|
|
|
2019-09-06 02:56:45 +00:00
|
|
|
// A bunch of utility functions of the form `parse_<thing>_from_<source>`
|
2013-02-11 21:36:24 +00:00
|
|
|
// where <thing> includes crate, expr, item, stmt, tts, and one that
|
|
|
|
// uses a HOF to parse anything, and <source> includes file and
|
2019-09-06 02:56:45 +00:00
|
|
|
// `source_str`.
|
2013-02-11 21:36:24 +00:00
|
|
|
|
2022-10-09 14:15:23 +00:00
|
|
|
/// A variant of 'panictry!' that works on a `Vec<Diagnostic>` instead of a single
|
|
|
|
/// `DiagnosticBuilder`.
|
2019-10-11 16:52:09 +00:00
|
|
|
macro_rules! panictry_buffer {
|
|
|
|
($handler:expr, $e:expr) => {{
|
2019-12-05 05:38:06 +00:00
|
|
|
use rustc_errors::FatalError;
|
2019-10-11 16:52:09 +00:00
|
|
|
use std::result::Result::{Err, Ok};
|
|
|
|
match $e {
|
|
|
|
Ok(e) => e,
|
|
|
|
Err(errs) => {
|
2022-03-20 17:26:09 +00:00
|
|
|
for mut e in errs {
|
|
|
|
$handler.emit_diagnostic(&mut e);
|
2019-10-11 16:52:09 +00:00
|
|
|
}
|
|
|
|
FatalError.raise()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2016-10-27 06:36:56 +00:00
|
|
|
pub fn parse_crate_from_file<'a>(input: &Path, sess: &'a ParseSess) -> PResult<'a, ast::Crate> {
|
2020-03-21 22:10:10 +00:00
|
|
|
let mut parser = new_parser_from_file(sess, input, None);
|
2016-02-13 17:05:16 +00:00
|
|
|
parser.parse_crate_mod()
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 06:36:56 +00:00
|
|
|
pub fn parse_crate_attrs_from_file<'a>(
|
|
|
|
input: &Path,
|
|
|
|
sess: &'a ParseSess,
|
2022-08-17 02:34:33 +00:00
|
|
|
) -> PResult<'a, ast::AttrVec> {
|
2020-03-21 22:10:10 +00:00
|
|
|
let mut parser = new_parser_from_file(sess, input, None);
|
2016-02-13 17:05:16 +00:00
|
|
|
parser.parse_inner_attributes()
|
2013-12-19 20:23:39 +00:00
|
|
|
}
|
|
|
|
|
2017-12-14 07:09:19 +00:00
|
|
|
pub fn parse_crate_from_source_str(
|
|
|
|
name: FileName,
|
|
|
|
source: String,
|
|
|
|
sess: &ParseSess,
|
2019-02-06 17:33:01 +00:00
|
|
|
) -> PResult<'_, ast::Crate> {
|
2016-10-27 06:36:56 +00:00
|
|
|
new_parser_from_source_str(sess, name, source).parse_crate_mod()
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2017-12-14 07:09:19 +00:00
|
|
|
pub fn parse_crate_attrs_from_source_str(
|
|
|
|
name: FileName,
|
|
|
|
source: String,
|
|
|
|
sess: &ParseSess,
|
2022-08-17 02:34:33 +00:00
|
|
|
) -> PResult<'_, ast::AttrVec> {
|
2016-10-27 06:36:56 +00:00
|
|
|
new_parser_from_source_str(sess, name, source).parse_inner_attributes()
|
2013-12-19 20:23:39 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 05:04:50 +00:00
|
|
|
pub fn parse_stream_from_source_str(
|
|
|
|
name: FileName,
|
|
|
|
source: String,
|
|
|
|
sess: &ParseSess,
|
|
|
|
override_span: Option<Span>,
|
2019-03-04 20:59:43 +00:00
|
|
|
) -> TokenStream {
|
2023-02-22 06:09:57 +00:00
|
|
|
source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span)
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:53:55 +00:00
|
|
|
/// Creates a new parser from a source string.
|
2019-01-28 05:04:50 +00:00
|
|
|
pub fn new_parser_from_source_str(sess: &ParseSess, name: FileName, source: String) -> Parser<'_> {
|
2018-11-01 21:01:38 +00:00
|
|
|
panictry_buffer!(&sess.span_diagnostic, maybe_new_parser_from_source_str(sess, name, source))
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:53:55 +00:00
|
|
|
/// Creates a new parser from a source string. Returns any buffered errors from lexing the initial
|
2018-11-01 16:57:29 +00:00
|
|
|
/// token stream.
|
|
|
|
pub fn maybe_new_parser_from_source_str(
|
|
|
|
sess: &ParseSess,
|
|
|
|
name: FileName,
|
|
|
|
source: String,
|
2019-02-06 17:33:01 +00:00
|
|
|
) -> Result<Parser<'_>, Vec<Diagnostic>> {
|
2020-03-08 12:36:20 +00:00
|
|
|
maybe_source_file_to_parser(sess, sess.source_map().new_source_file(name, source))
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 02:56:45 +00:00
|
|
|
/// Creates a new parser, handling errors as appropriate if the file doesn't exist.
|
2020-09-10 09:56:11 +00:00
|
|
|
/// If a span is given, that is used on an error as the source of the problem.
|
2020-03-21 22:10:10 +00:00
|
|
|
pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Span>) -> Parser<'a> {
|
|
|
|
source_file_to_parser(sess, file_to_source_file(sess, path, sp))
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
|
2022-07-24 14:09:04 +00:00
|
|
|
/// Given a session and a `source_file`, returns a parser.
|
2019-02-06 17:33:01 +00:00
|
|
|
fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Parser<'_> {
|
2018-11-01 21:01:38 +00:00
|
|
|
panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file))
|
2013-04-23 17:57:41 +00:00
|
|
|
}
|
|
|
|
|
2022-07-24 14:09:04 +00:00
|
|
|
/// Given a session and a `source_file`, return a parser. Returns any buffered errors from lexing the
|
2018-11-01 16:57:29 +00:00
|
|
|
/// initial token stream.
|
2019-01-28 05:04:50 +00:00
|
|
|
fn maybe_source_file_to_parser(
|
|
|
|
sess: &ParseSess,
|
|
|
|
source_file: Lrc<SourceFile>,
|
|
|
|
) -> Result<Parser<'_>, Vec<Diagnostic>> {
|
2018-08-18 10:13:56 +00:00
|
|
|
let end_pos = source_file.end_pos;
|
2023-02-22 06:09:57 +00:00
|
|
|
let stream = maybe_file_to_stream(sess, source_file, None)?;
|
2019-05-22 00:47:23 +00:00
|
|
|
let mut parser = stream_to_parser(sess, stream, None);
|
2020-02-16 20:19:51 +00:00
|
|
|
if parser.token == token::Eof {
|
2021-04-18 12:27:04 +00:00
|
|
|
parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None);
|
2015-07-06 02:13:19 +00:00
|
|
|
}
|
|
|
|
|
2018-11-01 16:57:29 +00:00
|
|
|
Ok(parser)
|
2013-04-23 17:57:41 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 02:56:45 +00:00
|
|
|
// Base abstractions
|
2013-04-23 17:57:41 +00:00
|
|
|
|
2018-12-09 21:53:00 +00:00
|
|
|
/// Given a session and a path and an optional span (for error reporting),
|
|
|
|
/// add the path to the session's source_map and return the new source_file or
|
|
|
|
/// error when a file can't be read.
|
|
|
|
fn try_file_to_source_file(
|
|
|
|
sess: &ParseSess,
|
|
|
|
path: &Path,
|
|
|
|
spanopt: Option<Span>,
|
|
|
|
) -> Result<Lrc<SourceFile>, Diagnostic> {
|
|
|
|
sess.source_map().load_file(path).map_err(|e| {
|
|
|
|
let msg = format!("couldn't read {}: {}", path.display(), e);
|
Restrict `From<S>` for `{D,Subd}iagnosticMessage`.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.
This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.
As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-04-20 03:26:58 +00:00
|
|
|
let mut diag = Diagnostic::new(Level::Fatal, msg);
|
2018-12-09 21:53:00 +00:00
|
|
|
if let Some(sp) = spanopt {
|
|
|
|
diag.set_span(sp);
|
|
|
|
}
|
|
|
|
diag
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2013-04-23 17:57:41 +00:00
|
|
|
/// Given a session and a path and an optional span (for error reporting),
|
2019-09-06 02:56:45 +00:00
|
|
|
/// adds the path to the session's `source_map` and returns the new `source_file`.
|
2018-08-18 10:13:56 +00:00
|
|
|
fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>) -> Lrc<SourceFile> {
|
2018-12-09 21:53:00 +00:00
|
|
|
match try_file_to_source_file(sess, path, spanopt) {
|
2018-08-18 10:13:56 +00:00
|
|
|
Ok(source_file) => source_file,
|
2022-03-20 17:26:09 +00:00
|
|
|
Err(mut d) => {
|
|
|
|
sess.span_diagnostic.emit_diagnostic(&mut d);
|
2018-12-09 21:53:00 +00:00
|
|
|
FatalError.raise();
|
2014-05-16 17:45:16 +00:00
|
|
|
}
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 02:56:45 +00:00
|
|
|
/// Given a `source_file`, produces a sequence of token trees.
|
2019-01-28 05:04:50 +00:00
|
|
|
pub fn source_file_to_stream(
|
|
|
|
sess: &ParseSess,
|
|
|
|
source_file: Lrc<SourceFile>,
|
|
|
|
override_span: Option<Span>,
|
2023-02-22 06:09:57 +00:00
|
|
|
) -> TokenStream {
|
2018-11-01 21:01:38 +00:00
|
|
|
panictry_buffer!(&sess.span_diagnostic, maybe_file_to_stream(sess, source_file, override_span))
|
2013-04-23 17:57:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:53:55 +00:00
|
|
|
/// Given a source file, produces a sequence of token trees. Returns any buffered errors from
|
2019-05-12 16:55:16 +00:00
|
|
|
/// parsing the token stream.
|
2019-01-28 05:04:50 +00:00
|
|
|
pub fn maybe_file_to_stream(
|
|
|
|
sess: &ParseSess,
|
|
|
|
source_file: Lrc<SourceFile>,
|
|
|
|
override_span: Option<Span>,
|
2023-02-22 06:09:57 +00:00
|
|
|
) -> Result<TokenStream, Vec<Diagnostic>> {
|
2020-09-03 13:37:03 +00:00
|
|
|
let src = source_file.src.as_ref().unwrap_or_else(|| {
|
Restrict `From<S>` for `{D,Subd}iagnosticMessage`.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.
This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.
As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-04-20 03:26:58 +00:00
|
|
|
sess.span_diagnostic.bug(format!(
|
2021-04-19 22:27:02 +00:00
|
|
|
"cannot lex `source_file` without source: {}",
|
2021-08-26 10:46:01 +00:00
|
|
|
sess.source_map().filename_for_diagnostics(&source_file.name)
|
2021-04-19 22:27:02 +00:00
|
|
|
));
|
2020-09-03 13:37:03 +00:00
|
|
|
});
|
|
|
|
|
2023-02-22 10:30:35 +00:00
|
|
|
lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span)
|
2013-04-23 17:57:41 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 02:56:45 +00:00
|
|
|
/// Given a stream and the `ParseSess`, produces a parser.
|
2019-05-22 00:47:23 +00:00
|
|
|
pub fn stream_to_parser<'a>(
|
|
|
|
sess: &'a ParseSess,
|
|
|
|
stream: TokenStream,
|
2019-05-22 05:17:53 +00:00
|
|
|
subparser_name: Option<&'static str>,
|
2019-05-22 00:47:23 +00:00
|
|
|
) -> Parser<'a> {
|
2020-03-08 12:36:20 +00:00
|
|
|
Parser::new(sess, stream, false, subparser_name)
|
2012-11-29 00:20:41 +00:00
|
|
|
}
|
2013-01-30 17:56:33 +00:00
|
|
|
|
2019-10-09 11:19:15 +00:00
|
|
|
/// Runs the given subparser `f` on the tokens of the given `attr`'s item.
|
2019-12-05 05:45:50 +00:00
|
|
|
pub fn parse_in<'a, T>(
|
2019-10-09 11:19:15 +00:00
|
|
|
sess: &'a ParseSess,
|
2019-12-05 05:45:50 +00:00
|
|
|
tts: TokenStream,
|
|
|
|
name: &'static str,
|
2019-10-09 11:19:15 +00:00
|
|
|
mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
|
|
|
|
) -> PResult<'a, T> {
|
2020-03-08 12:36:20 +00:00
|
|
|
let mut parser = Parser::new(sess, tts, false, Some(name));
|
2019-10-09 11:19:15 +00:00
|
|
|
let result = f(&mut parser)?;
|
|
|
|
if parser.token != token::Eof {
|
|
|
|
parser.unexpected()?;
|
|
|
|
}
|
|
|
|
Ok(result)
|
|
|
|
}
|
|
|
|
|
2022-05-21 12:50:39 +00:00
|
|
|
pub fn fake_token_stream_for_item(sess: &ParseSess, item: &ast::Item) -> TokenStream {
|
|
|
|
let source = pprust::item_to_string(item);
|
2020-11-23 06:43:55 +00:00
|
|
|
let filename = FileName::macro_expansion_source_code(&source);
|
2022-05-21 12:50:39 +00:00
|
|
|
parse_stream_from_source_str(filename, source, sess, Some(item.span))
|
2020-08-01 11:59:02 +00:00
|
|
|
}
|
2021-07-29 17:00:41 +00:00
|
|
|
|
2021-10-17 16:32:34 +00:00
|
|
|
pub fn fake_token_stream_for_crate(sess: &ParseSess, krate: &ast::Crate) -> TokenStream {
|
|
|
|
let source = pprust::crate_to_string_for_macros(krate);
|
|
|
|
let filename = FileName::macro_expansion_source_code(&source);
|
2022-03-03 23:45:25 +00:00
|
|
|
parse_stream_from_source_str(filename, source, sess, Some(krate.spans.inner_span))
|
2021-10-17 16:32:34 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 17:00:41 +00:00
|
|
|
pub fn parse_cfg_attr(
|
|
|
|
attr: &Attribute,
|
|
|
|
parse_sess: &ParseSess,
|
|
|
|
) -> Option<(MetaItem, Vec<(AttrItem, Span)>)> {
|
|
|
|
match attr.get_normal_item().args {
|
2022-11-18 00:24:21 +00:00
|
|
|
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, ref tokens })
|
|
|
|
if !tokens.is_empty() =>
|
|
|
|
{
|
2023-04-27 00:53:06 +00:00
|
|
|
crate::validate_attr::check_cfg_attr_bad_delim(parse_sess, dspan, delim);
|
2022-11-18 00:24:21 +00:00
|
|
|
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
2021-07-29 17:00:41 +00:00
|
|
|
Ok(r) => return Some(r),
|
|
|
|
Err(mut e) => {
|
Restrict `From<S>` for `{D,Subd}iagnosticMessage`.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.
This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.
As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-04-20 03:26:58 +00:00
|
|
|
e.help(format!("the valid syntax is `{}`", CFG_ATTR_GRAMMAR_HELP))
|
2021-07-29 17:00:41 +00:00
|
|
|
.note(CFG_ATTR_NOTE_REF)
|
|
|
|
.emit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => error_malformed_cfg_attr_missing(attr.span, parse_sess),
|
|
|
|
}
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
|
|
|
const CFG_ATTR_GRAMMAR_HELP: &str = "#[cfg_attr(condition, attribute, other_attribute, ...)]";
|
|
|
|
const CFG_ATTR_NOTE_REF: &str = "for more information, visit \
|
|
|
|
<https://doc.rust-lang.org/reference/conditional-compilation.html\
|
|
|
|
#the-cfg_attr-attribute>";
|
|
|
|
|
|
|
|
fn error_malformed_cfg_attr_missing(span: Span, parse_sess: &ParseSess) {
|
2023-04-27 00:53:06 +00:00
|
|
|
parse_sess.emit_err(errors::MalformedCfgAttr { span, sugg: CFG_ATTR_GRAMMAR_HELP });
|
2021-07-29 17:00:41 +00:00
|
|
|
}
|