Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8a850cd
std/time: avoid divisions in Duration::new
utkarshgupta137 Jan 24, 2024
0ac1195
Invert diagnostic lints.
nnethercote Feb 5, 2024
ad3d04c
A drive-by rewrite of give_region_a_name()
amandasystems Feb 6, 2024
0f323b2
Associated types in traits don't necessarily have a type that we can …
oli-obk Feb 7, 2024
0b97d18
extern types don't have any types to visit
oli-obk Feb 7, 2024
b998b51
Actually walk fields of Adt definitions
oli-obk Feb 7, 2024
4389a1c
Stop using `hir_ty_to_ty` in rustc_privacy
oli-obk Jul 18, 2023
5c25de6
Remove now-useless method override
oli-obk Feb 7, 2024
e867886
Remove dead code
oli-obk Feb 7, 2024
795be51
Make `RegionName` `Copy` by (transitively) interning the few string v…
amandasystems Feb 7, 2024
d80d7ea
Add some tests for associated type normalization edge cases
oli-obk Feb 8, 2024
d70d320
Use `transmute_unchecked` in `NonZero::new`.
reitermarkus Feb 8, 2024
698a3c7
Don't ICE in ByMoveBody when coroutine is tainted
compiler-errors Feb 8, 2024
e32c1dd
Don't ice in validation when error body is created
compiler-errors Feb 9, 2024
7619792
Fix `ErrorGuaranteed` unsoundness with stash/steal.
nnethercote Feb 8, 2024
575e0aa
Startup objects disappearing from sysroot
Nikokrock Feb 9, 2024
f41d0d9
Rollup merge of #113671 - oli-obk:normalize_weak_tys, r=petrochenkov
matthiaskrgr Feb 9, 2024
8b8adfd
Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se
matthiaskrgr Feb 9, 2024
46a0448
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davi…
matthiaskrgr Feb 9, 2024
df2281b
Rollup merge of #120704 - amandasystems:silly-region-name-rewrite, r=…
matthiaskrgr Feb 9, 2024
475c47a
Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, …
matthiaskrgr Feb 9, 2024
116efb5
Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obk
matthiaskrgr Feb 9, 2024
2f1ac41
Rollup merge of #120828 - nnethercote:fix-stash-steal, r=oli-obk
matthiaskrgr Feb 9, 2024
4a46914
Rollup merge of #120831 - Nikokrock:pr/disappearing_startup_objects, …
matthiaskrgr Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make RegionName Copy by (transitively) interning the few string v…
…ariants
  • Loading branch information
amandasystems committed Feb 8, 2024
commit 795be51dd931848b8cbf3dc84c526ca92634803c
26 changes: 13 additions & 13 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{universal_regions::DefiningTy, MirBorrowckCtxt};

/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) struct RegionName {
/// The name of the region (interned).
pub(crate) name: Symbol,
Expand All @@ -26,7 +26,7 @@ pub(crate) struct RegionName {
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`.
/// This helps to print the right kinds of diagnostics.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) enum RegionNameSource {
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
NamedEarlyParamRegion(Span),
Expand All @@ -43,7 +43,7 @@ pub(crate) enum RegionNameSource {
/// The region corresponding to the return type of a closure.
AnonRegionFromOutput(RegionNameHighlight, &'static str),
/// The region from a type yielded by a coroutine.
AnonRegionFromYieldTy(Span, String),
AnonRegionFromYieldTy(Span, Symbol),
/// An anonymous region from an async fn.
AnonRegionFromAsyncFn(Span),
/// An anonymous region from an impl self type or trait
Expand All @@ -52,19 +52,19 @@ pub(crate) enum RegionNameSource {

/// Describes what to highlight to explain to the user that we're giving an anonymous region a
/// synthesized name, and how to highlight it.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub(crate) enum RegionNameHighlight {
/// The anonymous region corresponds to a reference that was found by traversing the type in the HIR.
MatchedHirTy(Span),
/// The anonymous region corresponds to a `'_` in the generics list of a struct/enum/union.
MatchedAdtAndSegment(Span),
/// The anonymous region corresponds to a region where the type annotation is completely missing
/// from the code, e.g. in a closure arguments `|x| { ... }`, where `x` is a reference.
CannotMatchHirTy(Span, String),
CannotMatchHirTy(Span, Symbol),
/// The anonymous region corresponds to a region where the type annotation is completely missing
/// from the code, and *even if* we print out the full name of the type, the region name won't
/// be included. This currently occurs for opaque types like `impl Future`.
Occluded(Span, String),
Occluded(Span, Symbol),
}

impl RegionName {
Expand Down Expand Up @@ -249,7 +249,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
assert!(self.regioncx.universal_regions().is_universal_region(fr));

match self.region_names.borrow_mut().entry(fr) {
IndexEntry::Occupied(precomputed_name) => Some(precomputed_name.get().clone()),
IndexEntry::Occupied(precomputed_name) => Some(*precomputed_name.get()),
IndexEntry::Vacant(slot) => {
let new_name = self
.give_name_from_error_region(fr)
Expand All @@ -262,8 +262,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr)
});

if let Some(new_name) = &new_name {
slot.insert(new_name.clone());
if let Some(new_name) = new_name {
slot.insert(new_name);
}
debug!("give_region_a_name: gave name {:?}", new_name);

Expand Down Expand Up @@ -460,9 +460,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
);
if type_name.contains(&format!("'{counter}")) {
// Only add a label if we can confirm that a region was labelled.
RegionNameHighlight::CannotMatchHirTy(span, type_name)
RegionNameHighlight::CannotMatchHirTy(span, Symbol::intern(&type_name))
} else {
RegionNameHighlight::Occluded(span, type_name)
RegionNameHighlight::Occluded(span, Symbol::intern(&type_name))
}
}

Expand Down Expand Up @@ -882,7 +882,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

Some(RegionName {
name: self.synthesize_region_name(),
source: RegionNameSource::AnonRegionFromYieldTy(yield_span, type_name),
source: RegionNameSource::AnonRegionFromYieldTy(yield_span, Symbol::intern(&type_name)),
})
}

Expand Down Expand Up @@ -974,7 +974,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
Some(RegionName {
name: region_name,
source: RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?.to_string()),
RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?),
),
})
} else {
Expand Down