use rustc_ast::ast;
-use rustc_ast::with_globals;
use rustc_data_structures::sync::Lrc;
use rustc_errors::ErrorReported;
use rustc_feature::UnstableFeatures;
pub attrs: Vec<String>,
}
-pub fn run(options: Options) -> Result<(), String> {
+pub fn run(options: Options) -> Result<(), ErrorReported> {
let input = config::Input::File(options.input.clone());
- let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name;
+ let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
- // In addition to those specific lints, we also need to whitelist those given through
+ // In addition to those specific lints, we also need to allow those given through
// command line, otherwise they'll get ignored and we don't want that.
- let whitelisted_lints = vec![invalid_codeblock_attribute_name.to_owned()];
+ let allowed_lints = vec![invalid_codeblock_attributes_name.to_owned()];
- let (lint_opts, lint_caps) = init_lints(whitelisted_lints, options.lint_opts.clone(), |lint| {
- if lint.name == invalid_codeblock_attribute_name {
+ let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| {
+ if lint.name == invalid_codeblock_attributes_name {
None
} else {
Some((lint.name_lower(), lint::Allow))
});
let tests = match tests {
Ok(tests) => tests,
- Err(ErrorReported) => return Err(String::new()),
+ Err(ErrorReported) => return Err(ErrorReported),
};
test_args.insert(0, "rustdoctest".to_string());
.item
.attrs
.iter()
- .filter(|a| a.check_name(sym::doc))
+ .filter(|a| a.has_name(sym::doc))
.flat_map(|a| a.meta_item_list().unwrap_or_else(Vec::new))
- .filter(|a| a.check_name(sym::test))
+ .filter(|a| a.has_name(sym::test))
.collect();
let attrs = test_attrs.iter().flat_map(|a| a.meta_item_list().unwrap_or(&[]));
for attr in attrs {
- if attr.check_name(sym::no_crate_inject) {
+ if attr.has_name(sym::no_crate_inject) {
opts.no_crate_inject = true;
}
- if attr.check_name(sym::attr) {
+ if attr.has_name(sym::attr) {
if let Some(l) = attr.meta_item_list() {
for item in l {
opts.attrs.push(pprust::meta_list_item_to_string(item));
// Uses librustc_ast to parse the doctest and find if there's a main fn and the extern
// crate already is included.
let result = rustc_driver::catch_fatal_errors(|| {
- with_globals(edition, || {
+ rustc_ast::with_session_globals(edition, || {
use rustc_errors::emitter::EmitterWriter;
use rustc_errors::Handler;
use rustc_parse::maybe_new_parser_from_source_str;