Skip to content

Commit dc8cac8

Browse files
Nits
1 parent 0ad96c1 commit dc8cac8

File tree

11 files changed

+16
-20
lines changed

11 files changed

+16
-20
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4195,7 +4195,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
41954195
let return_ty = sig.output();
41964196
match return_ty.skip_binder().kind() {
41974197
ty::Ref(return_region, _, _)
4198-
if return_region.has_name(self.infcx.tcx) && !is_closure =>
4198+
if return_region.is_named(self.infcx.tcx) && !is_closure =>
41994199
{
42004200
// This is case 1 from above, return type is a named reference so we need to
42014201
// search for relevant arguments.

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
853853
};
854854

855855
let lifetime =
856-
if f.has_name(self.infcx.tcx) { fr_name.name } else { kw::UnderscoreLifetime };
856+
if f.is_named(self.infcx.tcx) { fr_name.name } else { kw::UnderscoreLifetime };
857857

858858
let arg = match param.param.pat.simple_ident() {
859859
Some(simple_ident) => format!("argument `{simple_ident}`"),

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,7 @@ fn lint_redundant_lifetimes<'tcx>(
23382338
lifetimes.push(ty::Region::new_late_param(tcx, owner_id.to_def_id(), kind));
23392339
}
23402340
}
2341-
lifetimes.retain(|candidate| candidate.has_name(tcx));
2341+
lifetimes.retain(|candidate| candidate.is_named(tcx));
23422342

23432343
// Keep track of lifetimes which have already been replaced with other lifetimes.
23442344
// This makes sure that if `'a = 'b = 'c`, we don't say `'c` should be replaced by

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,7 @@ fn get_new_lifetime_name<'tcx>(
578578
let existing_lifetimes = tcx
579579
.collect_referenced_late_bound_regions(poly_trait_ref)
580580
.into_iter()
581-
.filter_map(|lt| {
582-
if let Some(name) = lt.get_name(tcx) { Some(name.as_str().to_string()) } else { None }
583-
})
581+
.filter_map(|lt| lt.get_name(tcx).map(|name| name.as_str().to_string()))
584582
.chain(generics.params.iter().filter_map(|param| {
585583
if let hir::GenericParamKind::Lifetime { .. } = &param.kind {
586584
Some(param.name.ident().as_str().to_string())

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::ty::{
1212
self as ty, IsSuggestable, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
1313
TypeVisitor, Upcast,
1414
};
15-
use rustc_span::{ErrorGuaranteed, Ident, Span, kw};
15+
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
1616
use rustc_trait_selection::traits;
1717
use smallvec::SmallVec;
1818
use tracing::{debug, instrument};

compiler/rustc_middle/src/ty/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'tcx> Region<'tcx> {
182182
}
183183

184184
/// Is this region named by the user?
185-
pub fn has_name(self, tcx: TyCtxt<'tcx>) -> bool {
185+
pub fn is_named(self, tcx: TyCtxt<'tcx>) -> bool {
186186
match self.kind() {
187187
ty::ReEarlyParam(ebr) => ebr.is_named(),
188188
ty::ReBound(_, br) => br.kind.is_named(tcx),

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2525
// only introduced anonymous regions in parameters) as well as a
2626
// version new_ty of its type where the anonymous region is replaced
2727
// with the named one.
28-
let (named, anon, anon_param_info, region_info) = if sub.has_name(self.tcx())
28+
let (named, anon, anon_param_info, region_info) = if sub.is_named(self.tcx())
2929
&& let Some(region_info) = self.tcx().is_suitable_region(self.generic_param_scope, sup)
3030
&& let Some(anon_param_info) = self.find_param_with_region(sup, sub)
3131
{
3232
(sub, sup, anon_param_info, region_info)
33-
} else if sup.has_name(self.tcx())
33+
} else if sup.is_named(self.tcx())
3434
&& let Some(region_info) = self.tcx().is_suitable_region(self.generic_param_scope, sub)
3535
&& let Some(anon_param_info) = self.find_param_with_region(sub, sup)
3636
{
@@ -56,9 +56,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5656
let scope_def_id = region_info.scope;
5757
let is_impl_item = region_info.is_impl_item;
5858

59-
if !anon_param_info.kind.is_named(self.tcx()) {
60-
// Anon region
61-
} else {
59+
if anon_param_info.kind.is_named(self.tcx()) {
6260
/* not an anonymous region */
6361
debug!("try_report_named_anon_conflict: not an anonymous region");
6462
return None;

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
164164
sub_region @ Region(Interned(RePlaceholder(_), _)),
165165
sup_region,
166166
)) => self.try_report_trait_placeholder_mismatch(
167-
(!sup_region.has_name(self.tcx())).then_some(*sup_region),
167+
(!sup_region.is_named(self.tcx())).then_some(*sup_region),
168168
cause,
169169
Some(*sub_region),
170170
None,
@@ -176,7 +176,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
176176
sub_region,
177177
sup_region @ Region(Interned(RePlaceholder(_), _)),
178178
)) => self.try_report_trait_placeholder_mismatch(
179-
(!sub_region.has_name(self.tcx())).then_some(*sub_region),
179+
(!sub_region.is_named(self.tcx())).then_some(*sub_region),
180180
cause,
181181
None,
182182
Some(*sup_region),

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
4646
let param = self.find_param_with_region(*sup_r, *sub_r)?;
4747
let simple_ident = param.param.pat.simple_ident();
4848
let lifetime_name =
49-
if sup_r.has_name(self.tcx()) { sup_r.to_string() } else { "'_".to_owned() };
49+
if sup_r.is_named(self.tcx()) { sup_r.to_string() } else { "'_".to_owned() };
5050

5151
let (mention_influencer, influencer_point) =
5252
if sup_origin.span().overlaps(param.param_ty_span) {
@@ -100,7 +100,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
100100
// We don't need a note, it's already at the end, it can be shown as a `span_label`.
101101
require_span_as_label: (!require_as_note).then_some(require_span),
102102

103-
has_lifetime: sup_r.has_name(self.tcx()),
103+
has_lifetime: sup_r.is_named(self.tcx()),
104104
lifetime: lifetime_name.clone(),
105105
has_param_name: simple_ident.is_some(),
106106
param_name: simple_ident.map(|x| x.to_string()).unwrap_or_default(),

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
7676

7777
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for HighlightBuilder<'tcx> {
7878
fn visit_region(&mut self, r: ty::Region<'tcx>) {
79-
if !r.has_name(self.tcx) && self.counter <= 3 {
79+
if !r.is_named(self.tcx) && self.counter <= 3 {
8080
self.highlight.highlighting_region(r, self.counter);
8181
self.counter += 1;
8282
}

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
729729
.dcx()
730730
.struct_span_err(span, format!("{labeled_user_string} may not live long enough"));
731731
err.code(match sub.kind() {
732-
ty::ReEarlyParam(_) | ty::ReLateParam(_) if sub.has_name(self.tcx) => E0309,
732+
ty::ReEarlyParam(_) | ty::ReLateParam(_) if sub.is_named(self.tcx) => E0309,
733733
ty::ReStatic => E0310,
734734
_ => E0311,
735735
});
@@ -877,7 +877,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
877877

878878
let (lifetime_def_id, lifetime_scope) =
879879
match self.tcx.is_suitable_region(generic_param_scope, lifetime) {
880-
Some(info) if !lifetime.has_name(self.tcx) => {
880+
Some(info) if !lifetime.is_named(self.tcx) => {
881881
(info.region_def_id.expect_local(), info.scope)
882882
}
883883
_ => return lifetime.get_name_or_anon(self.tcx).to_string(),

0 commit comments

Comments
 (0)