1
Fork 0

Rename all ParseSess variables/fields/lifetimes as psess.

Existing names for values of this type are `sess`, `parse_sess`,
`parse_session`, and `ps`. `sess` is particularly annoying because
that's also used for `Session` values, which are often co-located, and
it can be difficult to know which type a value named `sess` refers to.
(That annoyance is the main motivation for this change.) `psess` is nice
and short, which is good for a name used this much.

The commit also renames some `parse_sess_created` values as
`psess_created`.
This commit is contained in:
Nicholas Nethercote 2024-03-04 16:31:49 +11:00
parent 4260f7ec67
commit 80d2bdb619
98 changed files with 653 additions and 687 deletions

View file

@ -346,7 +346,7 @@ pub(crate) struct BinaryFloatLiteralNotSupported {
}
pub fn report_lit_error(
sess: &ParseSess,
psess: &ParseSess,
err: LitError,
lit: token::Lit,
span: Span,
@ -378,7 +378,7 @@ pub fn report_lit_error(
valid.then(|| format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..]))
}
let dcx = &sess.dcx;
let dcx = &psess.dcx;
match err {
LitError::InvalidSuffix(suffix) => {
dcx.emit_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })

View file

@ -106,13 +106,12 @@ pub fn feature_err_issue(
// Cancel an earlier warning for this same error, if it exists.
if let Some(span) = span.primary_span() {
if let Some(err) = sess.parse_sess.dcx.steal_non_err(span, StashKey::EarlySyntaxWarning) {
if let Some(err) = sess.psess.dcx.steal_non_err(span, StashKey::EarlySyntaxWarning) {
err.cancel()
}
}
let mut err =
sess.parse_sess.dcx.create_err(FeatureGateError { span, explain: explain.into() });
let mut err = sess.psess.dcx.create_err(FeatureGateError { span, explain: explain.into() });
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
err
}
@ -141,7 +140,7 @@ pub fn feature_warn_issue(
issue: GateIssue,
explain: &'static str,
) {
let mut err = sess.parse_sess.dcx.struct_span_warn(span, explain);
let mut err = sess.psess.dcx.struct_span_warn(span, explain);
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level
@ -181,7 +180,7 @@ pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
}
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
if sess.parse_sess.unstable_features.is_nightly_build() {
if sess.psess.unstable_features.is_nightly_build() {
if feature_from_cli {
err.subdiagnostic(sess.dcx(), CliFeatureDiagnosticHelp { feature });
} else {

View file

@ -146,7 +146,7 @@ pub struct Session {
pub opts: config::Options,
pub host_tlib_path: Lrc<SearchPath>,
pub target_tlib_path: Lrc<SearchPath>,
pub parse_sess: ParseSess,
pub psess: ParseSess,
pub sysroot: PathBuf,
/// Input, input file path and output file path to this compilation process.
pub io: CompilerIO,
@ -336,12 +336,12 @@ impl Session {
#[inline]
pub fn dcx(&self) -> &DiagCtxt {
&self.parse_sess.dcx
&self.psess.dcx
}
#[inline]
pub fn source_map(&self) -> &SourceMap {
self.parse_sess.source_map()
self.psess.source_map()
}
/// Returns `true` if internal lints should be added to the lint store - i.e. if
@ -1114,8 +1114,8 @@ pub fn build_session(
None
};
let mut parse_sess = ParseSess::with_dcx(dcx, source_map);
parse_sess.assume_incomplete_release = sopts.unstable_opts.assume_incomplete_release;
let mut psess = ParseSess::with_dcx(dcx, source_map);
psess.assume_incomplete_release = sopts.unstable_opts.assume_incomplete_release;
let host_triple = config::host_triple();
let target_triple = sopts.target_triple.triple();
@ -1154,7 +1154,7 @@ pub fn build_session(
opts: sopts,
host_tlib_path,
target_tlib_path,
parse_sess,
psess,
sysroot,
io,
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),