session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
d45004806d
commit
2575b1abc9
33 changed files with 510 additions and 162 deletions
|
@ -49,9 +49,6 @@ rustc_target = { path = "../rustc_target" }
|
|||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
rustc_ty_utils = { path = "../rustc_ty_utils" }
|
||||
|
||||
[dev-dependencies]
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
|
||||
[features]
|
||||
llvm = ['rustc_codegen_llvm']
|
||||
rustc_use_parallel_compiler = ['rayon', 'rustc-rayon-core', 'rustc_query_impl/rustc_use_parallel_compiler', 'rustc_errors/rustc_use_parallel_compiler']
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use rustc_macros::Diagnostic;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_target::spec::TargetTriple;
|
||||
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
@ -91,3 +93,22 @@ pub struct FailedWritingFile<'a> {
|
|||
#[derive(Diagnostic)]
|
||||
#[diag(interface_proc_macro_crate_panic_abort)]
|
||||
pub struct ProcMacroCratePanicAbort;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_unsupported_crate_type_for_target)]
|
||||
pub struct UnsupportedCrateTypeForTarget<'a> {
|
||||
pub crate_type: CrateType,
|
||||
pub target_triple: &'a TargetTriple,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_multiple_output_types_adaption)]
|
||||
pub struct MultipleOutputTypesAdaption;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_ignoring_extra_filename)]
|
||||
pub struct IgnoringExtraFilename;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_ignoring_out_dir)]
|
||||
pub struct IgnoringOutDir;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::errors;
|
||||
use info;
|
||||
use libloading::Library;
|
||||
use rustc_ast as ast;
|
||||
|
@ -472,16 +473,15 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C
|
|||
}
|
||||
|
||||
base.retain(|crate_type| {
|
||||
let res = !output::invalid_output_for_target(session, *crate_type);
|
||||
|
||||
if !res {
|
||||
session.warn(&format!(
|
||||
"dropping unsupported crate type `{}` for target `{}`",
|
||||
*crate_type, session.opts.target_triple
|
||||
));
|
||||
if output::invalid_output_for_target(session, *crate_type) {
|
||||
session.emit_warning(errors::UnsupportedCrateTypeForTarget {
|
||||
crate_type: *crate_type,
|
||||
target_triple: &session.opts.target_triple,
|
||||
});
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
res
|
||||
});
|
||||
|
||||
base
|
||||
|
@ -517,19 +517,16 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
|
|||
let unnamed_output_types =
|
||||
sess.opts.output_types.values().filter(|a| a.is_none()).count();
|
||||
let ofile = if unnamed_output_types > 1 {
|
||||
sess.warn(
|
||||
"due to multiple output types requested, the explicitly specified \
|
||||
output file name will be adapted for each output type",
|
||||
);
|
||||
sess.emit_warning(errors::MultipleOutputTypesAdaption);
|
||||
None
|
||||
} else {
|
||||
if !sess.opts.cg.extra_filename.is_empty() {
|
||||
sess.warn("ignoring -C extra-filename flag due to -o flag");
|
||||
sess.emit_warning(errors::IgnoringExtraFilename);
|
||||
}
|
||||
Some(out_file.clone())
|
||||
};
|
||||
if sess.io.output_dir != None {
|
||||
sess.warn("ignoring --out-dir flag due to -o flag");
|
||||
sess.emit_warning(errors::IgnoringOutDir);
|
||||
}
|
||||
|
||||
OutputFilenames::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue