Skip to content

Commit b74b4b0

Browse files
committed
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`.
1 parent 550b276 commit b74b4b0

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

clippy_lints/src/disallowed_script_idents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl EarlyLintPass for DisallowedScriptIdents {
7272
return;
7373
}
7474

75-
let symbols = cx.sess().parse_sess.symbol_gallery.symbols.lock();
75+
let symbols = cx.sess().psess.symbol_gallery.symbols.lock();
7676
// Sort by `Span` so that error messages make sense with respect to the
7777
// order of identifier locations in the code.
7878
let mut symbols: Vec<_> = symbols.iter().collect();

clippy_lints/src/doc/needless_doctest_main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub fn check(
4848
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
4949
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
5050
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
51-
let sess = ParseSess::with_dcx(dcx, sm);
51+
let psess = ParseSess::with_dcx(dcx, sm);
5252

53-
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {
53+
let mut parser = match maybe_new_parser_from_source_str(&psess, filename, code) {
5454
Ok(p) => p,
5555
Err(errs) => {
5656
errs.into_iter().for_each(Diag::cancel);

src/driver.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ fn test_arg_value() {
6868
assert_eq!(arg_value(args, "--foo", |_| true), None);
6969
}
7070

71-
fn track_clippy_args(parse_sess: &mut ParseSess, args_env_var: &Option<String>) {
72-
parse_sess.env_depinfo.get_mut().insert((
71+
fn track_clippy_args(psess: &mut ParseSess, args_env_var: &Option<String>) {
72+
psess.env_depinfo.get_mut().insert((
7373
Symbol::intern("CLIPPY_ARGS"),
7474
args_env_var.as_deref().map(Symbol::intern),
7575
));
7676
}
7777

7878
/// Track files that may be accessed at runtime in `file_depinfo` so that cargo will re-run clippy
7979
/// when any of them are modified
80-
fn track_files(parse_sess: &mut ParseSess) {
81-
let file_depinfo = parse_sess.file_depinfo.get_mut();
80+
fn track_files(psess: &mut ParseSess) {
81+
let file_depinfo = psess.file_depinfo.get_mut();
8282

8383
// Used by `clippy::cargo` lints and to determine the MSRV. `cargo clippy` executes `clippy-driver`
8484
// with the current directory set to `CARGO_MANIFEST_DIR` so a relative path is fine
@@ -115,8 +115,8 @@ struct RustcCallbacks {
115115
impl rustc_driver::Callbacks for RustcCallbacks {
116116
fn config(&mut self, config: &mut interface::Config) {
117117
let clippy_args_var = self.clippy_args_var.take();
118-
config.parse_sess_created = Some(Box::new(move |parse_sess| {
119-
track_clippy_args(parse_sess, &clippy_args_var);
118+
config.psess_created = Some(Box::new(move |psess| {
119+
track_clippy_args(psess, &clippy_args_var);
120120
}));
121121
}
122122
}
@@ -132,13 +132,13 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
132132
let conf_path = clippy_config::lookup_conf_file();
133133
let previous = config.register_lints.take();
134134
let clippy_args_var = self.clippy_args_var.take();
135-
config.parse_sess_created = Some(Box::new(move |parse_sess| {
136-
track_clippy_args(parse_sess, &clippy_args_var);
137-
track_files(parse_sess);
135+
config.psess_created = Some(Box::new(move |psess| {
136+
track_clippy_args(psess, &clippy_args_var);
137+
track_files(psess);
138138

139139
// Trigger a rebuild if CLIPPY_CONF_DIR changes. The value must be a valid string so
140140
// changes between dirs that are invalid UTF-8 will not trigger rebuilds
141-
parse_sess.env_depinfo.get_mut().insert((
141+
psess.env_depinfo.get_mut().insert((
142142
Symbol::intern("CLIPPY_CONF_DIR"),
143143
env::var("CLIPPY_CONF_DIR").ok().map(|dir| Symbol::intern(&dir)),
144144
));

0 commit comments

Comments
 (0)