Skip to content
Open
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
6 changes: 4 additions & 2 deletions compiler/rustc_lint/src/noop_method_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,21 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
},
);
} else {
// Report the method call's return type before adjustments required by its parent.
let unadjusted_expr_ty = cx.typeck_results().expr_ty(expr);
match name {
// If `type_of(x) == T` and `x.borrow()` is used to get `&T`,
// then that should be allowed
sym::noop_method_borrow => return,
sym::noop_method_clone => cx.emit_span_lint(
SUSPICIOUS_DOUBLE_REF_OP,
span,
SuspiciousDoubleRefCloneDiag { ty: expr_ty },
SuspiciousDoubleRefCloneDiag { ty: unadjusted_expr_ty },
),
sym::noop_method_deref => cx.emit_span_lint(
SUSPICIOUS_DOUBLE_REF_OP,
span,
SuspiciousDoubleRefDerefDiag { ty: expr_ty },
SuspiciousDoubleRefDerefDiag { ty: unadjusted_expr_ty },
),
_ => return,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_errors::{
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
use rustc_pattern_analysis::errors::Uncovered;
use rustc_pattern_analysis::diagnostics::Uncovered;
use rustc_pattern_analysis::rustc::RustcPatCtxt;
use rustc_span::{Ident, Span, Symbol};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_middle::thir::visit::Visitor;
use rustc_middle::thir::*;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
use rustc_pattern_analysis::errors::Uncovered;
use rustc_pattern_analysis::diagnostics::Uncovered;
use rustc_pattern_analysis::rustc::{
Constructor, DeconstructedPat, MatchArm, RedundancyExplanation, RevealedTy,
RustcPatCtxt as PatCtxt, Usefulness, UsefulnessReport, WitnessPat,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/abi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_span::Span;
use rustc_target::callconv::FnAbi;

use super::layout_test::ensure_wf;
use crate::errors::{AbiInvalidAttribute, AbiNe, AbiOf, UnrecognizedArgument};
use crate::diagnostics::{AbiInvalidAttribute, AbiNe, AbiOf, UnrecognizedArgument};

pub fn test_abi(tcx: TyCtxt<'_>) {
if !tcx.features().rustc_attrs() {
Expand Down
143 changes: 76 additions & 67 deletions compiler/rustc_passes/src/check_attr.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc_middle::ty::{
use rustc_session::config::CrateType;
use rustc_span::Span;

use crate::errors::UnexportableItem;
use crate::diagnostics::UnexportableItem;

struct ExportableItemCollector<'tcx> {
tcx: TyCtxt<'tcx>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_session::lint::builtin::{DEAD_CODE, DEAD_CODE_PUB_IN_BINARY};
use rustc_session::lint::{self, Lint, StableLintExpectationId};
use rustc_span::{Symbol, kw};

use crate::errors::{
use crate::diagnostics::{
ChangeFields, DeadCodePubInBinaryNote, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo,
UselessAssignment,
};
Expand Down Expand Up @@ -1233,7 +1233,7 @@ impl<'tcx> DeadVisitor<'tcx> {
&& let Some(variant) =
maybe_enum.variants().iter().find(|i| i.name == dead_item.name)
{
Some(crate::errors::EnumVariantSameName {
Some(crate::diagnostics::EnumVariantSameName {
dead_descr: tcx.def_descr(dead_item.def_id.to_def_id()),
dead_name: dead_item.name,
variant_span: tcx.def_span(variant.def_id),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/debugger_visualizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_span::sym;

use crate::errors::DebugVisualizerUnreadable;
use crate::diagnostics::DebugVisualizerUnreadable;

impl DebuggerVisualizerCollector<'_> {
fn check_for_debugger_visualizer(&mut self, attrs: &[ast::Attribute]) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/delegation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_middle::ty::TyCtxt;

use crate::errors::GlobOrListDelegationUnusedTargetExpr;
use crate::diagnostics::GlobOrListDelegationUnusedTargetExpr;

pub fn check_glob_and_list_delegations_target_expr(tcx: TyCtxt<'_>) {
let mut delegations_by_group_id = FxIndexMap::default();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::Symbol;
use rustc_span::def_id::{DefId, LOCAL_CRATE};

use crate::errors::DuplicateDiagnosticItemInCrate;
use crate::diagnostics::DuplicateDiagnosticItemInCrate;

fn observe_item<'tcx>(tcx: TyCtxt<'tcx>, diagnostic_items: &mut DiagnosticItems, owner: OwnerId) {
let attrs = tcx.hir_attrs(owner.into());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType;

use crate::errors::{DuplicateEiiImpls, EiiWithoutImpl};
use crate::diagnostics::{DuplicateEiiImpls, EiiWithoutImpl};

#[derive(Clone, Copy, Debug)]
enum CheckingMode {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::config::{CrateType, EntryFnType, sigpipe};
use rustc_span::{RemapPathScopeComponents, Span};

use crate::errors::{ExternMain, MultipleRustcMain, NoMainErr};
use crate::diagnostics::{ExternMain, MultipleRustcMain, NoMainErr};

struct EntryContext<'tcx> {
tcx: TyCtxt<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::cstore::ExternCrate;
use rustc_span::{Span, Symbol, sym};

use crate::errors::{
use crate::diagnostics::{
DuplicateLangItem, IncorrectCrateType, IncorrectTarget, LangItemOnIncorrectTarget,
};
use crate::weak_lang_items;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub mod dead;
mod debugger_visualizer;
pub mod delegation;
mod diagnostic_items;
mod diagnostics;
mod eii;
pub mod entry;
mod errors;
pub mod hir_id_validator;
pub mod input_stats;
mod lang_items;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/lib_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_middle::query::{LocalCrate, Providers};
use rustc_middle::ty::TyCtxt;
use rustc_span::{Span, Symbol, sym};

use crate::errors::{FeaturePreviouslyDeclared, FeatureStableTwice};
use crate::diagnostics::{FeaturePreviouslyDeclared, FeatureStableTwice};

struct LibFeatureCollector<'tcx> {
tcx: TyCtxt<'tcx>,
Expand Down
74 changes: 39 additions & 35 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc_session::lint::builtin::{DEPRECATED, INEFFECTIVE_UNSTABLE_TRAIT_IMPL};
use rustc_span::{Span, Symbol, sym};
use tracing::instrument;

use crate::errors;
use crate::diagnostics;

#[derive(PartialEq)]
enum AnnotationKind {
Expand Down Expand Up @@ -337,7 +337,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
&& depr.map_or(false, |d| d.attr.is_since_rustc_version())
&& let Some(span) = find_attr_span!(Deprecated)
{
self.tcx.dcx().emit_err(errors::DeprecatedAttribute { span });
self.tcx.dcx().emit_err(diagnostics::DeprecatedAttribute { span });
}

if let Some(stab) = stab {
Expand All @@ -348,7 +348,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
{
if let Some(span) = find_attr_span!(Stability) {
let item_sp = self.tcx.def_span(def_id);
self.tcx.dcx().emit_err(errors::UselessStability { span, item_sp });
self.tcx.dcx().emit_err(diagnostics::UselessStability { span, item_sp });
}
}

Expand All @@ -364,13 +364,13 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
StableSince::Current => {
self.tcx
.dcx()
.emit_err(errors::CannotStabilizeDeprecated { span, item_sp });
.emit_err(diagnostics::CannotStabilizeDeprecated { span, item_sp });
}
StableSince::Version(stab_since) => {
if dep_since < stab_since {
self.tcx
.dcx()
.emit_err(errors::CannotStabilizeDeprecated { span, item_sp });
.emit_err(diagnostics::CannotStabilizeDeprecated { span, item_sp });
}
}
StableSince::Err(_) => {
Expand All @@ -389,7 +389,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
&& const_stab.is_some()
&& find_attr_span!(RustcConstStability).is_some()
{
self.tcx.dcx().emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span });
self.tcx.dcx().emit_err(diagnostics::MissingConstErr { fn_sig_span: fn_sig.span });
}

// If this is marked const *stable*, it must also be regular-stable.
Expand All @@ -399,17 +399,18 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
&& !stab.is_some_and(|s| s.is_stable())
&& let Some(const_span) = find_attr_span!(RustcConstStability)
{
self.tcx
.dcx()
.emit_err(errors::ConstStableNotStable { fn_sig_span: fn_sig.span, const_span });
self.tcx.dcx().emit_err(diagnostics::ConstStableNotStable {
fn_sig_span: fn_sig.span,
const_span,
});
}

if let Some(stab) = &const_stab
&& stab.is_const_stable()
&& stab.const_stable_indirect
&& let Some(span) = find_attr_span!(RustcConstStability)
{
self.tcx.dcx().emit_err(errors::RustcConstStableIndirectPairing { span });
self.tcx.dcx().emit_err(diagnostics::RustcConstStableIndirectPairing { span });
}
}

Expand All @@ -423,7 +424,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
{
let descr = self.tcx.def_descr(def_id.to_def_id());
let span = self.tcx.def_span(def_id);
self.tcx.dcx().emit_err(errors::MissingStabilityAttr { span, descr });
self.tcx.dcx().emit_err(diagnostics::MissingStabilityAttr { span, descr });
}
}

Expand All @@ -439,7 +440,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
{
let span = self.tcx.def_span(def_id);
let descr = self.tcx.def_descr(def_id.to_def_id());
self.tcx.dcx().emit_err(errors::MissingConstStabAttr { span, descr });
self.tcx.dcx().emit_err(diagnostics::MissingConstStabAttr { span, descr });
}
}
}
Expand Down Expand Up @@ -646,7 +647,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
item.hir_id(),
span,
errors::IneffectiveUnstableImpl,
diagnostics::IneffectiveUnstableImpl,
);
}
}
Expand All @@ -660,9 +661,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
// `#![feature(const_trait_impl)]` is unstable, so any impl declared stable
// needs to have an error emitted.
// Note: Remove this error once `const_trait_impl` is stabilized
self.tcx
.dcx()
.emit_err(errors::TraitImplConstStable { span: item.span });
self.tcx.dcx().emit_err(diagnostics::TraitImplConstStable {
span: item.span,
});
true
}
Some(_) => false,
Expand All @@ -676,21 +677,23 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
let trait_span = self.tcx.def_ident_span(trait_id).unwrap();

let impl_stability = if stable_or_implied_stable {
errors::ImplConstStability::Stable { span: item.span }
diagnostics::ImplConstStability::Stable { span: item.span }
} else {
errors::ImplConstStability::Unstable { span: item.span }
diagnostics::ImplConstStability::Unstable { span: item.span }
};
let trait_stability = if const_stab.is_const_stable() {
errors::TraitConstStability::Stable { span: trait_span }
diagnostics::TraitConstStability::Stable { span: trait_span }
} else {
errors::TraitConstStability::Unstable { span: trait_span }
diagnostics::TraitConstStability::Unstable { span: trait_span }
};

self.tcx.dcx().emit_err(errors::TraitImplConstStabilityMismatch {
span: item.span,
impl_stability,
trait_stability,
});
self.tcx.dcx().emit_err(
diagnostics::TraitImplConstStabilityMismatch {
span: item.span,
impl_stability,
trait_stability,
},
);
}
}
}
Expand Down Expand Up @@ -1044,7 +1047,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
if let FeatureStability::Unstable { old_name: Some(alias) } = stability
&& let Some(span) = remaining_lib_features.swap_remove(&alias)
{
tcx.dcx().emit_err(errors::RenamedFeature { span, feature, alias });
tcx.dcx().emit_err(diagnostics::RenamedFeature { span, feature, alias });
}

if remaining_lib_features.is_empty() && remaining_implications.is_empty() {
Expand Down Expand Up @@ -1118,18 +1121,19 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
if let Some(removed) =
unstable_removed_features.iter().find(|removed| removed.feature == feature)
{
tcx.dcx().emit_err(errors::FeatureRemoved {
tcx.dcx().emit_err(diagnostics::FeatureRemoved {
span,
feature,
reason: removed.reason,
link: removed.link,
since: removed.since.to_string(),
});
} else {
let suggestion = feature
.find_similar(&valid_feature_names)
.map(|(actual_name, _)| errors::MisspelledFeature { span, actual_name });
tcx.dcx().emit_err(errors::UnknownFeature { span, feature, suggestion });
let suggestion =
feature.find_similar(&valid_feature_names).map(|(actual_name, _)| {
diagnostics::MisspelledFeature { span, actual_name }
});
tcx.dcx().emit_err(diagnostics::UnknownFeature { span, feature, suggestion });
}
}
}
Expand All @@ -1142,7 +1146,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
.get(&feature)
.expect("feature that implied another does not exist")
.1;
tcx.dcx().emit_err(errors::ImpliedFeatureNotExist { span, feature, implied_by });
tcx.dcx().emit_err(diagnostics::ImpliedFeatureNotExist { span, feature, implied_by });
}

// FIXME(#44232): the `used_features` table no longer exists, so we
Expand All @@ -1160,7 +1164,7 @@ fn unnecessary_partially_stable_feature_lint(
lint::builtin::STABLE_FEATURES,
hir::CRATE_HIR_ID,
span,
errors::UnnecessaryPartialStableFeature {
diagnostics::UnnecessaryPartialStableFeature {
span,
line: tcx.sess.source_map().span_extend_to_line(span),
feature,
Expand All @@ -1183,7 +1187,7 @@ fn unnecessary_stable_feature_lint(
lint::builtin::STABLE_FEATURES,
hir::CRATE_HIR_ID,
span,
errors::UnnecessaryStableFeature { feature, since },
diagnostics::UnnecessaryStableFeature { feature, since },
);
}

Expand All @@ -1192,6 +1196,6 @@ fn duplicate_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol) {
lint::builtin::DUPLICATE_FEATURES,
hir::CRATE_HIR_ID,
span,
errors::DuplicateFeature { feature },
diagnostics::DuplicateFeature { feature },
);
}
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_middle::middle::lang_items::required;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType;

use crate::errors::{
use crate::diagnostics::{
MissingLangItem, MissingPanicHandler, PanicUnwindWithoutStd, UnknownExternLangItem,
};
use crate::lang_items::extract_ast;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pub(crate) mod checks;
pub mod constructor;
#[cfg(feature = "rustc")]
pub mod errors;
pub mod diagnostics;
#[cfg(feature = "rustc")]
pub(crate) mod lints;
pub mod pat;
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_pattern_analysis/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use tracing::instrument;

use crate::MatchArm;
use crate::constructor::Constructor;
use crate::errors::{NonExhaustiveOmittedPattern, NonExhaustiveOmittedPatternLintOnArm, Uncovered};
use crate::diagnostics::{
NonExhaustiveOmittedPattern, NonExhaustiveOmittedPatternLintOnArm, Uncovered,
};
use crate::pat_column::PatternColumn;
use crate::rustc::{RevealedTy, RustcPatCtxt, WitnessPat};

Expand Down
Loading
Loading