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:
parent
550b276109
commit
b74b4b09d1
@ -72,7 +72,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let symbols = cx.sess().parse_sess.symbol_gallery.symbols.lock();
|
let symbols = cx.sess().psess.symbol_gallery.symbols.lock();
|
||||||
// Sort by `Span` so that error messages make sense with respect to the
|
// Sort by `Span` so that error messages make sense with respect to the
|
||||||
// order of identifier locations in the code.
|
// order of identifier locations in the code.
|
||||||
let mut symbols: Vec<_> = symbols.iter().collect();
|
let mut symbols: Vec<_> = symbols.iter().collect();
|
||||||
|
@ -48,9 +48,9 @@ fn check_code_sample(code: String, edition: Edition, ignore: bool) -> (bool, Vec
|
|||||||
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
||||||
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let psess = ParseSess::with_dcx(dcx, sm);
|
||||||
|
|
||||||
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {
|
let mut parser = match maybe_new_parser_from_source_str(&psess, filename, code) {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(errs) => {
|
Err(errs) => {
|
||||||
errs.into_iter().for_each(Diag::cancel);
|
errs.into_iter().for_each(Diag::cancel);
|
||||||
|
@ -68,8 +68,8 @@ fn test_arg_value() {
|
|||||||
assert_eq!(arg_value(args, "--foo", |_| true), None);
|
assert_eq!(arg_value(args, "--foo", |_| true), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn track_clippy_args(parse_sess: &mut ParseSess, args_env_var: &Option<String>) {
|
fn track_clippy_args(psess: &mut ParseSess, args_env_var: &Option<String>) {
|
||||||
parse_sess.env_depinfo.get_mut().insert((
|
psess.env_depinfo.get_mut().insert((
|
||||||
Symbol::intern("CLIPPY_ARGS"),
|
Symbol::intern("CLIPPY_ARGS"),
|
||||||
args_env_var.as_deref().map(Symbol::intern),
|
args_env_var.as_deref().map(Symbol::intern),
|
||||||
));
|
));
|
||||||
@ -77,8 +77,8 @@ fn track_clippy_args(parse_sess: &mut ParseSess, args_env_var: &Option<String>)
|
|||||||
|
|
||||||
/// Track files that may be accessed at runtime in `file_depinfo` so that cargo will re-run clippy
|
/// Track files that may be accessed at runtime in `file_depinfo` so that cargo will re-run clippy
|
||||||
/// when any of them are modified
|
/// when any of them are modified
|
||||||
fn track_files(parse_sess: &mut ParseSess) {
|
fn track_files(psess: &mut ParseSess) {
|
||||||
let file_depinfo = parse_sess.file_depinfo.get_mut();
|
let file_depinfo = psess.file_depinfo.get_mut();
|
||||||
|
|
||||||
// Used by `clippy::cargo` lints and to determine the MSRV. `cargo clippy` executes `clippy-driver`
|
// Used by `clippy::cargo` lints and to determine the MSRV. `cargo clippy` executes `clippy-driver`
|
||||||
// with the current directory set to `CARGO_MANIFEST_DIR` so a relative path is fine
|
// with the current directory set to `CARGO_MANIFEST_DIR` so a relative path is fine
|
||||||
@ -115,8 +115,8 @@ struct RustcCallbacks {
|
|||||||
impl rustc_driver::Callbacks for RustcCallbacks {
|
impl rustc_driver::Callbacks for RustcCallbacks {
|
||||||
fn config(&mut self, config: &mut interface::Config) {
|
fn config(&mut self, config: &mut interface::Config) {
|
||||||
let clippy_args_var = self.clippy_args_var.take();
|
let clippy_args_var = self.clippy_args_var.take();
|
||||||
config.parse_sess_created = Some(Box::new(move |parse_sess| {
|
config.psess_created = Some(Box::new(move |psess| {
|
||||||
track_clippy_args(parse_sess, &clippy_args_var);
|
track_clippy_args(psess, &clippy_args_var);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,13 +132,13 @@ fn config(&mut self, config: &mut interface::Config) {
|
|||||||
let conf_path = clippy_config::lookup_conf_file();
|
let conf_path = clippy_config::lookup_conf_file();
|
||||||
let previous = config.register_lints.take();
|
let previous = config.register_lints.take();
|
||||||
let clippy_args_var = self.clippy_args_var.take();
|
let clippy_args_var = self.clippy_args_var.take();
|
||||||
config.parse_sess_created = Some(Box::new(move |parse_sess| {
|
config.psess_created = Some(Box::new(move |psess| {
|
||||||
track_clippy_args(parse_sess, &clippy_args_var);
|
track_clippy_args(psess, &clippy_args_var);
|
||||||
track_files(parse_sess);
|
track_files(psess);
|
||||||
|
|
||||||
// Trigger a rebuild if CLIPPY_CONF_DIR changes. The value must be a valid string so
|
// Trigger a rebuild if CLIPPY_CONF_DIR changes. The value must be a valid string so
|
||||||
// changes between dirs that are invalid UTF-8 will not trigger rebuilds
|
// changes between dirs that are invalid UTF-8 will not trigger rebuilds
|
||||||
parse_sess.env_depinfo.get_mut().insert((
|
psess.env_depinfo.get_mut().insert((
|
||||||
Symbol::intern("CLIPPY_CONF_DIR"),
|
Symbol::intern("CLIPPY_CONF_DIR"),
|
||||||
env::var("CLIPPY_CONF_DIR").ok().map(|dir| Symbol::intern(&dir)),
|
env::var("CLIPPY_CONF_DIR").ok().map(|dir| Symbol::intern(&dir)),
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user