Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_span::Span;
use tracing::{debug, instrument};

use super::{DefineOpaqueTypes, RegionVariableOrigin};
use crate::errors::OpaqueHiddenTypeDiag;
use crate::diagnostics::OpaqueHiddenTypeDiag;
use crate::infer::{InferCtxt, InferOk};
use crate::traits::{self, Obligation, PredicateObligations};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#![recursion_limit = "512"] // For rustdoc
// tidy-alphabetical-end

mod errors;
mod diagnostics;
pub mod infer;
pub mod traits;
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// tidy-alphabetical-end

mod callbacks;
pub mod errors;
pub mod diagnostics;
pub mod interface;
mod limits;
pub mod passes;
Expand Down
38 changes: 22 additions & 16 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use rustc_trait_selection::{solve, traits};
use tracing::{info, instrument};

use crate::interface::Compiler;
use crate::{errors, limits, proc_macro_decls, util};
use crate::{diagnostics, limits, proc_macro_decls, util};

pub fn parse<'a>(sess: &'a Session) -> ast::Crate {
let mut krate = sess
Expand Down Expand Up @@ -271,18 +271,18 @@ fn configure_and_expand(

if crate_types.len() > 1 {
if is_executable_crate {
sess.dcx().emit_err(errors::MixedBinCrate);
sess.dcx().emit_err(diagnostics::MixedBinCrate);
}
if is_proc_macro_crate {
sess.dcx().emit_err(errors::MixedProcMacroCrate);
sess.dcx().emit_err(diagnostics::MixedProcMacroCrate);
}
}
if crate_types.contains(&CrateType::Sdylib) && !tcx.features().export_stable() {
feature_err(sess, sym::export_stable, DUMMY_SP, "`sdylib` crate type is unstable").emit();
}

if is_proc_macro_crate && !sess.panic_strategy().unwinds() {
sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort);
sess.dcx().emit_warn(diagnostics::ProcMacroCratePanicAbort);
}

sess.time("maybe_create_a_macro_crate", || {
Expand Down Expand Up @@ -458,9 +458,13 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
})
.as_str();

sess.dcx().emit_err(errors::FerrisIdentifier { spans, first_span, ferris_fix });
sess.dcx().emit_err(diagnostics::FerrisIdentifier {
spans,
first_span,
ferris_fix,
});
} else {
sess.dcx().emit_err(errors::EmojiIdentifier { spans, ident });
sess.dcx().emit_err(diagnostics::EmojiIdentifier { spans, ident });
}
}
});
Expand Down Expand Up @@ -773,7 +777,8 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}
Err(error) => {
sess.dcx().emit_fatal(errors::ErrorWritingDependencies { path: deps_filename, error });
sess.dcx()
.emit_fatal(diagnostics::ErrorWritingDependencies { path: deps_filename, error });
}
}
}
Expand Down Expand Up @@ -824,10 +829,11 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) {
if let Some(input_path) = sess.io.input.opt_path() {
if sess.opts.will_create_output_file() {
if output_contains_path(&output_paths, input_path) {
sess.dcx().emit_fatal(errors::InputFileWouldBeOverWritten { path: input_path });
sess.dcx()
.emit_fatal(diagnostics::InputFileWouldBeOverWritten { path: input_path });
}
if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
sess.dcx().emit_fatal(errors::GeneratedFileConflictsWithDirectory {
sess.dcx().emit_fatal(diagnostics::GeneratedFileConflictsWithDirectory {
input_path,
dir_path,
});
Expand All @@ -837,7 +843,7 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) {

if let Some(ref dir) = sess.io.temps_dir {
if fs::create_dir_all(dir).is_err() {
sess.dcx().emit_fatal(errors::TempsDirError);
sess.dcx().emit_fatal(diagnostics::TempsDirError);
}
}

Expand All @@ -849,7 +855,7 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) {
if !only_dep_info {
if let Some(ref dir) = sess.io.output_dir {
if fs::create_dir_all(dir).is_err() {
sess.dcx().emit_fatal(errors::OutDirError);
sess.dcx().emit_fatal(diagnostics::OutDirError);
}
}
}
Expand Down Expand Up @@ -1353,7 +1359,7 @@ pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol
if let Some((attr_crate_name, span)) = attr_crate_name
&& attr_crate_name != crate_name
{
sess.dcx().emit_err(errors::CrateNameDoesNotMatch {
sess.dcx().emit_err(diagnostics::CrateNameDoesNotMatch {
span,
crate_name,
attr_crate_name,
Expand All @@ -1370,7 +1376,7 @@ pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol
&& let Some(file_stem) = path.file_stem().and_then(|s| s.to_str())
{
if file_stem.starts_with('-') {
sess.dcx().emit_err(errors::CrateNameInvalid { crate_name: file_stem });
sess.dcx().emit_err(diagnostics::CrateNameInvalid { crate_name: file_stem });
} else {
return validate(Symbol::intern(&file_stem.replace('-', "_")), None);
}
Expand Down Expand Up @@ -1413,7 +1419,7 @@ pub fn collect_crate_types(
// styles at all other locations
if session.opts.test {
if !session.target.executables {
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForTarget {
crate_type: CrateType::Executable,
target_triple: &session.opts.target_triple,
});
Expand Down Expand Up @@ -1459,13 +1465,13 @@ pub fn collect_crate_types(

base.retain(|crate_type| {
if invalid_output_for_target(session, *crate_type) {
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForTarget {
crate_type: *crate_type,
target_triple: &session.opts.target_triple,
});
false
} else if !backend_crate_types.contains(crate_type) {
session.dcx().emit_warn(errors::UnsupportedCrateTypeForCodegenBackend {
session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForCodegenBackend {
crate_type: *crate_type,
codegen_backend: codegen_backend_name,
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_session::config::{self, OutputFilenames, OutputType};

use crate::errors::FailedWritingFile;
use crate::diagnostics::FailedWritingFile;
use crate::passes;

pub struct Linker {
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rustc_span::{SessionGlobals, Symbol, sym};
use rustc_target::spec::Target;
use tracing::info;

use crate::errors;
use crate::diagnostics;
use crate::passes::parse_crate_name;

/// Function pointer type that constructs a new CodegenBackend.
Expand Down Expand Up @@ -90,12 +90,14 @@ pub(crate) fn check_abi_required_features(sess: &Session) {

for feature in abi_feature_constraints.required {
if !sess.unstable_target_features.contains(&Symbol::intern(feature)) {
sess.dcx().emit_warn(errors::AbiRequiredTargetFeature { feature, enabled: "enabled" });
sess.dcx()
.emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "enabled" });
}
}
for feature in abi_feature_constraints.incompatible {
if sess.unstable_target_features.contains(&Symbol::intern(feature)) {
sess.dcx().emit_warn(errors::AbiRequiredTargetFeature { feature, enabled: "disabled" });
sess.dcx()
.emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "disabled" });
}
}
}
Expand Down Expand Up @@ -609,7 +611,7 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
&sess.opts.output_types,
sess.io.output_file == Some(OutFileName::Stdout),
) {
sess.dcx().emit_fatal(errors::MultipleOutputTypesToStdout);
sess.dcx().emit_fatal(diagnostics::MultipleOutputTypesToStdout);
}

let crate_name =
Expand Down Expand Up @@ -650,16 +652,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.dcx().emit_warn(errors::MultipleOutputTypesAdaption);
sess.dcx().emit_warn(diagnostics::MultipleOutputTypesAdaption);
None
} else {
if !sess.opts.cg.extra_filename.is_empty() {
sess.dcx().emit_warn(errors::IgnoringExtraFilename);
sess.dcx().emit_warn(diagnostics::IgnoringExtraFilename);
}
Some(out_file.clone())
};
if sess.io.output_dir.is_some() {
sess.dcx().emit_warn(errors::IgnoringOutDir);
sess.dcx().emit_warn(diagnostics::IgnoringOutDir);
}

let out_filestem =
Expand Down
Loading