Skip to content

Commit dd104ef

Browse files
committedJun 18, 2024
Auto merge of #126623 - oli-obk:do_not_count_errors, r=davidtwco
Replace all `&DiagCtxt` with a `DiagCtxtHandle<'_>` wrapper type r? `@davidtwco` This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle Basically I will add a field to the `DiagCtxtHandle` that refers back to the `InferCtxt`'s (and others) `Option<ErrorHandled>`, allowing us to immediately taint these contexts when emitting an error and not needing manual tainting anymore (which is easy to forget and we don't do in general anyway)
2 parents 8814b92 + 3f34196 commit dd104ef

File tree

118 files changed

+773
-915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+773
-915
lines changed
 

‎compiler/rustc_ast_lowering/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use rustc_data_structures::fx::FxIndexSet;
5050
use rustc_data_structures::sorted_map::SortedMap;
5151
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5252
use rustc_data_structures::sync::Lrc;
53-
use rustc_errors::{DiagArgFromDisplay, DiagCtxt, StashKey};
53+
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
5454
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5555
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
5656
use rustc_hir::{self as hir};
@@ -188,7 +188,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
188188
}
189189
}
190190

191-
pub(crate) fn dcx(&self) -> &'hir DiagCtxt {
191+
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir> {
192192
self.tcx.dcx()
193193
}
194194
}

‎compiler/rustc_ast_passes/src/ast_validation.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}
1212
use rustc_ast::*;
1313
use rustc_ast_pretty::pprust::{self, State};
1414
use rustc_data_structures::fx::FxIndexMap;
15+
use rustc_errors::DiagCtxtHandle;
1516
use rustc_feature::Features;
1617
use rustc_parse::validate_attr;
1718
use rustc_session::lint::builtin::{
@@ -269,7 +270,7 @@ impl<'a> AstValidator<'a> {
269270
}
270271
}
271272

272-
fn dcx(&self) -> &rustc_errors::DiagCtxt {
273+
fn dcx(&self) -> DiagCtxtHandle<'a> {
273274
self.session.dcx()
274275
}
275276

@@ -809,11 +810,7 @@ impl<'a> AstValidator<'a> {
809810

810811
/// Checks that generic parameters are in the correct order,
811812
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
812-
fn validate_generic_param_order(
813-
dcx: &rustc_errors::DiagCtxt,
814-
generics: &[GenericParam],
815-
span: Span,
816-
) {
813+
fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericParam], span: Span) {
817814
let mut max_param: Option<ParamKindOrd> = None;
818815
let mut out_of_order = FxIndexMap::default();
819816
let mut param_idents = Vec::with_capacity(generics.len());

0 commit comments

Comments
 (0)
Please sign in to comment.