Skip to content

Commit

Permalink
Rename AstValidator::session as AstValidator::sess.
Browse files Browse the repository at this point in the history
Because `sess` is the standard name used everywhere else.
  • Loading branch information
nnethercote committed Sep 15, 2024
1 parent 55670d2 commit 7ad1fcd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl TraitOrTraitImpl {
}

struct AstValidator<'a> {
session: &'a Session,
sess: &'a Session,
features: &'a Features,

/// The span of the `extern` in an `extern { ... }` block, if any.
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<'a> AstValidator<'a> {
}

fn dcx(&self) -> DiagCtxtHandle<'a> {
self.session.dcx()
self.sess.dcx()
}

fn visibility_not_permitted(&self, vis: &Visibility, note: errors::VisibilityNotPermittedNote) {
Expand Down Expand Up @@ -359,7 +359,7 @@ impl<'a> AstValidator<'a> {
in_impl: matches!(parent, TraitOrTraitImpl::TraitImpl { .. }),
const_context_label: parent_constness,
remove_const_sugg: (
self.session.source_map().span_extend_while_whitespace(span),
self.sess.source_map().span_extend_while_whitespace(span),
match parent_constness {
Some(_) => rustc_errors::Applicability::MachineApplicable,
None => rustc_errors::Applicability::MaybeIncorrect,
Expand Down Expand Up @@ -472,15 +472,15 @@ impl<'a> AstValidator<'a> {

fn check_defaultness(&self, span: Span, defaultness: Defaultness) {
if let Defaultness::Default(def_span) = defaultness {
let span = self.session.source_map().guess_head_span(span);
let span = self.sess.source_map().guess_head_span(span);
self.dcx().emit_err(errors::ForbiddenDefault { span, def_span });
}
}

/// If `sp` ends with a semicolon, returns it as a `Span`
/// Otherwise, returns `sp.shrink_to_hi()`
fn ending_semi_or_hi(&self, sp: Span) -> Span {
let source_map = self.session.source_map();
let source_map = self.sess.source_map();
let end = source_map.end_point(sp);

if source_map.span_to_snippet(end).is_ok_and(|s| s == ";") {
Expand Down Expand Up @@ -552,7 +552,7 @@ impl<'a> AstValidator<'a> {
}

fn current_extern_span(&self) -> Span {
self.session.source_map().guess_head_span(self.extern_mod.unwrap())
self.sess.source_map().guess_head_span(self.extern_mod.unwrap())
}

/// An `fn` in `extern { ... }` cannot have qualifiers, e.g. `async fn`.
Expand Down Expand Up @@ -648,7 +648,7 @@ impl<'a> AstValidator<'a> {
if ident.name.as_str().is_ascii() {
return;
}
let span = self.session.source_map().guess_head_span(item_span);
let span = self.sess.source_map().guess_head_span(item_span);
self.dcx().emit_err(errors::NoMangleAscii { span });
}

Expand Down Expand Up @@ -753,7 +753,7 @@ impl<'a> AstValidator<'a> {
self.dcx().emit_err(errors::PatternFnPointer { span });
});
if let Extern::Implicit(_) = bfty.ext {
let sig_span = self.session.source_map().next_point(ty.span.shrink_to_lo());
let sig_span = self.sess.source_map().next_point(ty.span.shrink_to_lo());
self.maybe_lint_missing_abi(sig_span, ty.id);
}
}
Expand Down Expand Up @@ -795,7 +795,7 @@ impl<'a> AstValidator<'a> {
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
// call site which do not have a macro backtrace. See #61963.
if self
.session
.sess
.source_map()
.span_to_snippet(span)
.is_ok_and(|snippet| !snippet.starts_with("#["))
Expand Down Expand Up @@ -885,7 +885,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara

impl<'a> Visitor<'a> for AstValidator<'a> {
fn visit_attribute(&mut self, attr: &Attribute) {
validate_attr::check_attr(&self.session.psess, attr);
validate_attr::check_attr(&self.sess.psess, attr);
}

fn visit_ty(&mut self, ty: &'a Ty) {
Expand Down Expand Up @@ -1192,7 +1192,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} else if where_clauses.after.has_where_token {
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
span: where_clauses.after.span,
help: self.session.is_nightly_build(),
help: self.sess.is_nightly_build(),
});
}
}
Expand Down Expand Up @@ -1328,7 +1328,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
(BoundKind::SuperTraits, BoundConstness::Never, BoundPolarity::Maybe(_))
if !self.features.more_maybe_bounds =>
{
self.session
self.sess
.create_feature_err(
errors::OptionalTraitSupertrait {
span: trait_ref.span,
Expand All @@ -1341,7 +1341,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
(BoundKind::TraitObject, BoundConstness::Never, BoundPolarity::Maybe(_))
if !self.features.more_maybe_bounds =>
{
self.session
self.sess
.create_feature_err(
errors::OptionalTraitObject { span: trait_ref.span },
sym::more_maybe_bounds,
Expand Down Expand Up @@ -1752,13 +1752,13 @@ fn deny_equality_constraints(
}

pub fn check_crate(
session: &Session,
sess: &Session,
features: &Features,
krate: &Crate,
lints: &mut LintBuffer,
) -> bool {
let mut validator = AstValidator {
session,
sess,
features,
extern_mod: None,
outer_trait_or_trait_impl: None,
Expand Down

0 comments on commit 7ad1fcd

Please sign in to comment.