Skip to content

Commit 0c5a75a

Browse files
committed
Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
1 parent 1d1989f commit 0c5a75a

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

src/parse/macros/cfg_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn parse_cfg_if_inner<'a>(
6767
Ok(None) => continue,
6868
Err(err) => {
6969
err.cancel();
70-
parser.psess.dcx.reset_err_count();
70+
parser.psess.dcx().reset_err_count();
7171
return Err(
7272
"Expected item inside cfg_if block, but failed to parse it as an item",
7373
);

src/parse/macros/lazy_static.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ pub(crate) fn parse_lazy_static(
1616
($method:ident $(,)* $($arg:expr),* $(,)*) => {
1717
match parser.$method($($arg,)*) {
1818
Ok(val) => {
19-
if parser.psess.dcx.has_errors().is_some() {
20-
parser.psess.dcx.reset_err_count();
19+
if parser.psess.dcx().has_errors().is_some() {
20+
parser.psess.dcx().reset_err_count();
2121
return None;
2222
} else {
2323
val
2424
}
2525
}
2626
Err(err) => {
2727
err.cancel();
28-
parser.psess.dcx.reset_err_count();
28+
parser.psess.dcx().reset_err_count();
2929
return None;
3030
}
3131
}

src/parse/macros/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
2929
if Parser::nonterminal_may_begin_with($nt_kind, &cloned_parser.token) {
3030
match $try_parse(&mut cloned_parser) {
3131
Ok(x) => {
32-
if parser.psess.dcx.has_errors().is_some() {
33-
parser.psess.dcx.reset_err_count();
32+
if parser.psess.dcx().has_errors().is_some() {
33+
parser.psess.dcx().reset_err_count();
3434
} else {
3535
// Parsing succeeded.
3636
*parser = cloned_parser;
@@ -39,7 +39,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
3939
}
4040
Err(e) => {
4141
e.cancel();
42-
parser.psess.dcx.reset_err_count();
42+
parser.psess.dcx().reset_err_count();
4343
}
4444
}
4545
}

src/parse/session.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ impl ParseSess {
210210
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
211211
false,
212212
);
213-
self.raw_psess.dcx.make_silent(fallback_bundle, None, false);
213+
self.raw_psess
214+
.dcx()
215+
.make_silent(fallback_bundle, None, false);
214216
}
215217

216218
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
@@ -286,11 +288,11 @@ impl ParseSess {
286288
}
287289

288290
pub(super) fn has_errors(&self) -> bool {
289-
self.raw_psess.dcx.has_errors().is_some()
291+
self.raw_psess.dcx().has_errors().is_some()
290292
}
291293

292294
pub(super) fn reset_errors(&self) {
293-
self.raw_psess.dcx.reset_err_count();
295+
self.raw_psess.dcx().reset_err_count();
294296
}
295297
}
296298

0 commit comments

Comments
 (0)