summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_span
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:25:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:25:56 +0000
commit018c4950b9406055dec02ef0fb52f132e2bb1e2c (patch)
treea835ebdf2088ef88fa681f8fad45f09922c1ae9a /compiler/rustc_span
parentAdding debian version 1.75.0+dfsg1-5. (diff)
downloadrustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.tar.xz
rustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_span')
-rw-r--r--compiler/rustc_span/src/caching_source_map_view.rs6
-rw-r--r--compiler/rustc_span/src/def_id.rs4
-rw-r--r--compiler/rustc_span/src/edit_distance.rs6
-rw-r--r--compiler/rustc_span/src/edition.rs10
-rw-r--r--compiler/rustc_span/src/hygiene.rs8
-rw-r--r--compiler/rustc_span/src/lib.rs13
-rw-r--r--compiler/rustc_span/src/source_map.rs6
-rw-r--r--compiler/rustc_span/src/source_map/tests.rs2
-rw-r--r--compiler/rustc_span/src/symbol.rs90
9 files changed, 69 insertions, 76 deletions
diff --git a/compiler/rustc_span/src/caching_source_map_view.rs b/compiler/rustc_span/src/caching_source_map_view.rs
index fbfc5c22f..4c7029c4e 100644
--- a/compiler/rustc_span/src/caching_source_map_view.rs
+++ b/compiler/rustc_span/src/caching_source_map_view.rs
@@ -117,7 +117,7 @@ impl<'sm> CachingSourceMapView<'sm> {
self.time_stamp += 1;
// Check if lo and hi are in the cached lines.
- let lo_cache_idx = self.cache_entry_index(span_data.lo);
+ let lo_cache_idx: isize = self.cache_entry_index(span_data.lo);
let hi_cache_idx = self.cache_entry_index(span_data.hi);
if lo_cache_idx != -1 && hi_cache_idx != -1 {
@@ -205,7 +205,9 @@ impl<'sm> CachingSourceMapView<'sm> {
(lo_cache_idx as usize, oldest)
}
_ => {
- panic!();
+ panic!(
+ "the case of neither value being equal to -1 was handled above and the function returns."
+ );
}
};
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index 595babc26..b2d51ac6c 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -13,7 +13,7 @@ pub type StableCrateIdMap =
indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>;
rustc_index::newtype_index! {
- #[custom_encodable]
+ #[orderable]
#[debug_format = "crate{}"]
pub struct CrateNum {}
}
@@ -213,7 +213,7 @@ rustc_index::newtype_index! {
/// A DefIndex is an index into the hir-map for a crate, identifying a
/// particular definition. It should really be considered an interned
/// shorthand for a particular DefPath.
- #[custom_encodable] // (only encodable in metadata)
+ #[orderable]
#[debug_format = "DefIndex({})"]
pub struct DefIndex {
/// The crate root is always assigned index 0 by the AST Map code,
diff --git a/compiler/rustc_span/src/edit_distance.rs b/compiler/rustc_span/src/edit_distance.rs
index 96a118e59..14cb1d6d3 100644
--- a/compiler/rustc_span/src/edit_distance.rs
+++ b/compiler/rustc_span/src/edit_distance.rs
@@ -188,7 +188,11 @@ fn find_best_match_for_name_impl(
return Some(*c);
}
- let mut dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3);
+ // `fn edit_distance()` use `chars()` to calculate edit distance, so we must
+ // also use `chars()` (and not `str::len()`) to calculate length here.
+ let lookup_len = lookup.chars().count();
+
+ let mut dist = dist.unwrap_or_else(|| cmp::max(lookup_len, 3) / 3);
let mut best = None;
// store the candidates with the same distance, only for `use_substring_score` current.
let mut next_candidates = vec![];
diff --git a/compiler/rustc_span/src/edition.rs b/compiler/rustc_span/src/edition.rs
index 608b8c24b..78ac61fa3 100644
--- a/compiler/rustc_span/src/edition.rs
+++ b/compiler/rustc_span/src/edition.rs
@@ -1,4 +1,3 @@
-use crate::symbol::{sym, Symbol};
use std::fmt;
use std::str::FromStr;
@@ -58,15 +57,6 @@ impl Edition {
}
}
- pub fn feature_name(self) -> Symbol {
- match self {
- Edition::Edition2015 => sym::rust_2015_preview,
- Edition::Edition2018 => sym::rust_2018_preview,
- Edition::Edition2021 => sym::rust_2021_preview,
- Edition::Edition2024 => sym::rust_2024_preview,
- }
- }
-
pub fn is_stable(self) -> bool {
match self {
Edition::Edition2015 => true,
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
index 36731d0fe..b717229b6 100644
--- a/compiler/rustc_span/src/hygiene.rs
+++ b/compiler/rustc_span/src/hygiene.rs
@@ -60,7 +60,7 @@ pub struct SyntaxContextData {
rustc_index::newtype_index! {
/// A unique ID associated with a macro invocation and expansion.
- #[custom_encodable]
+ #[orderable]
pub struct ExpnIndex {}
}
@@ -80,8 +80,6 @@ impl fmt::Debug for ExpnId {
rustc_index::newtype_index! {
/// A unique ID associated with a macro invocation and expansion.
- #[custom_encodable]
- #[no_ord_impl]
#[debug_format = "expn{}"]
pub struct LocalExpnId {}
}
@@ -569,10 +567,6 @@ impl HygieneData {
}
}
-pub fn clear_syntax_context_map() {
- HygieneData::with(|data| data.syntax_context_map = FxHashMap::default());
-}
-
pub fn walk_chain(span: Span, to: SyntaxContext) -> Span {
HygieneData::with(|data| data.walk_chain(span, to))
}
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index 489c8d189..cc3f0962d 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -17,11 +17,10 @@
// tidy-alphabetical-start
#![allow(internal_features)]
-#![cfg_attr(not(bootstrap), doc(rust_logo))]
-#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
#![deny(rustc::diagnostic_outside_of_impl)]
#![deny(rustc::untranslatable_diagnostic)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
+#![doc(rust_logo)]
#![feature(array_windows)]
#![feature(cfg_match)]
#![feature(core_io_borrowed_buf)]
@@ -33,6 +32,7 @@
#![feature(read_buf)]
#![feature(round_char_boundary)]
#![feature(rustc_attrs)]
+#![feature(rustdoc_internals)]
// tidy-alphabetical-end
#[macro_use]
@@ -139,13 +139,6 @@ pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnO
SESSION_GLOBALS.set(session_globals, f)
}
-pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
-where
- F: FnOnce(&SessionGlobals) -> R,
-{
- create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
-}
-
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
where
F: FnOnce(&SessionGlobals) -> R,
@@ -2254,7 +2247,7 @@ pub struct ErrorGuaranteed(());
impl ErrorGuaranteed {
/// To be used only if you really know what you are doing... ideally, we would find a way to
/// eliminate all calls to this method.
- #[deprecated = "`Session::delay_span_bug` should be preferred over this function"]
+ #[deprecated = "`Session::span_delayed_bug` should be preferred over this function"]
pub fn unchecked_claim_error_was_emitted() -> Self {
ErrorGuaranteed(())
}
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs
index dcf346acb..cb10e6bf2 100644
--- a/compiler/rustc_span/src/source_map.rs
+++ b/compiler/rustc_span/src/source_map.rs
@@ -11,13 +11,11 @@
use crate::*;
use rustc_data_structures::fx::FxHashMap;
-use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher};
-use rustc_data_structures::sync::{IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock};
-use std::cmp;
+use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock};
use std::fs;
use std::hash::Hash;
use std::io::{self, BorrowedBuf, Read};
-use std::path::{self, Path, PathBuf};
+use std::path::{self};
#[cfg(test)]
mod tests;
diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs
index 5697969dd..113ca493d 100644
--- a/compiler/rustc_span/src/source_map/tests.rs
+++ b/compiler/rustc_span/src/source_map/tests.rs
@@ -1,7 +1,5 @@
use super::*;
-use rustc_data_structures::sync::{FreezeLock, Lrc};
-
fn init_source_map() -> SourceMap {
let sm = SourceMap::new(FilePathMapping::empty());
sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string());
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index f287862cc..0333b5f04 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -124,22 +124,24 @@ symbols! {
// There is currently no checking that all symbols are used; that would be
// nice to have.
Symbols {
+ Abi,
AcqRel,
Acquire,
AddToDiagnostic,
- Alignment,
Any,
Arc,
ArcWeak,
Argument,
ArgumentMethods,
- Arguments,
ArrayIntoIter,
AsMut,
AsRef,
AssertParamIsClone,
AssertParamIsCopy,
AssertParamIsEq,
+ AsyncGenFinished,
+ AsyncGenPending,
+ AsyncGenReady,
AtomicBool,
AtomicI128,
AtomicI16,
@@ -163,16 +165,15 @@ symbols! {
Break,
C,
CStr,
- CString,
Capture,
Center,
+ Cleanup,
Clone,
Command,
ConstParamTy,
Context,
Continue,
Copy,
- Count,
Cow,
Debug,
DebugStruct,
@@ -197,7 +198,6 @@ symbols! {
Fn,
FnMut,
FnOnce,
- FormatSpec,
Formatter,
From,
FromIterator,
@@ -206,8 +206,6 @@ symbols! {
FsPermissions,
Future,
FutureOutput,
- FxHashMap,
- FxHashSet,
GlobalAlloc,
Hash,
HashMap,
@@ -215,6 +213,7 @@ symbols! {
HashSet,
Hasher,
Implied,
+ InCleanup,
IndexOutput,
Input,
Instant,
@@ -250,7 +249,6 @@ symbols! {
NonZeroI32,
NonZeroI64,
NonZeroI8,
- NonZeroIsize,
NonZeroU128,
NonZeroU16,
NonZeroU32,
@@ -258,6 +256,7 @@ symbols! {
NonZeroU8,
NonZeroUsize,
None,
+ Normal,
Ok,
Option,
Ord,
@@ -271,7 +270,6 @@ symbols! {
Path,
PathBuf,
Pending,
- Pin,
Pointer,
Poll,
ProcMacro,
@@ -329,7 +327,6 @@ symbols! {
TyCtxt,
TyKind,
Unknown,
- UnsafeArg,
Vec,
VecDeque,
Wrapper,
@@ -385,7 +382,6 @@ symbols! {
allow_fail,
allow_internal_unsafe,
allow_internal_unstable,
- allowed,
alu32,
always,
and,
@@ -401,8 +397,6 @@ symbols! {
arm,
arm_target_feature,
array,
- arrays,
- as_mut_ptr,
as_ptr,
as_ref,
as_str,
@@ -432,6 +426,7 @@ symbols! {
async_closure,
async_fn_in_trait,
async_fn_track_caller,
+ async_iterator,
atomic,
atomic_mod,
atomics,
@@ -525,6 +520,8 @@ symbols! {
cmp,
cmp_max,
cmp_min,
+ cmp_partialeq_eq,
+ cmp_partialeq_ne,
cmpxchg16b_target_feature,
cmse_nonsecure_entry,
coerce_unsized,
@@ -585,7 +582,6 @@ symbols! {
const_try,
constant,
constructor,
- context,
convert_identity,
copy,
copy_closures,
@@ -651,7 +647,6 @@ symbols! {
default_method_body_is_const,
default_type_parameter_fallback,
default_type_params,
- delay_span_bug_from_inside_query,
deny,
deprecated,
deprecated_safe,
@@ -772,8 +767,6 @@ symbols! {
field,
field_init_shorthand,
file,
- fill,
- flags,
float,
float_to_int_unchecked,
floorf32,
@@ -783,6 +776,7 @@ symbols! {
fmt,
fmul_fast,
fn_align,
+ fn_delegation,
fn_must_use,
fn_mut,
fn_once,
@@ -941,10 +935,12 @@ symbols! {
lib,
libc,
lifetime,
+ lifetime_capture_rules_2024,
lifetimes,
likely,
line,
link,
+ link_arg_attribute,
link_args,
link_cfg,
link_llvm_intrinsics,
@@ -984,6 +980,7 @@ symbols! {
managed_boxes,
manually_drop,
map,
+ map_err,
marker,
marker_trait_attr,
masked,
@@ -1023,8 +1020,37 @@ symbols! {
minnumf32,
minnumf64,
mips_target_feature,
+ mir_basic_block,
+ mir_call,
+ mir_cast_transmute,
+ mir_checked,
+ mir_copy_for_deref,
+ mir_debuginfo,
+ mir_deinit,
+ mir_discriminant,
+ mir_drop,
+ mir_field,
+ mir_goto,
+ mir_len,
+ mir_make_place,
+ mir_move,
+ mir_offset,
+ mir_retag,
+ mir_return,
+ mir_set_discriminant,
+ mir_static,
+ mir_static_mut,
+ mir_storage_dead,
+ mir_storage_live,
+ mir_unreachable,
+ mir_unwind_cleanup,
+ mir_unwind_continue,
+ mir_unwind_resume,
+ mir_unwind_terminate,
+ mir_unwind_terminate_reason,
+ mir_unwind_unreachable,
+ mir_variant,
miri,
- misc,
mmx_reg,
modifiers,
module,
@@ -1062,6 +1088,7 @@ symbols! {
negative_impls,
neon,
never,
+ never_patterns,
never_type,
never_type_fallback,
new,
@@ -1118,19 +1145,17 @@ symbols! {
offset,
offset_of,
offset_of_enum,
+ ok_or_else,
omit_gdb_pretty_printer_section,
on,
on_unimplemented,
- oom,
opaque,
- ops,
opt_out_copy,
optimize,
optimize_attribute,
optin_builtin_traits,
option,
option_env,
- option_payload_ptr,
options,
or,
or_patterns,
@@ -1182,7 +1207,7 @@ symbols! {
pointer,
pointer_like,
poll,
- position,
+ poll_next,
post_dash_lto: "post-lto",
powerpc_target_feature,
powf32,
@@ -1191,7 +1216,6 @@ symbols! {
powif64,
pre_dash_lto: "pre-lto",
precise_pointer_size_matching,
- precision,
pref_align_of,
prefetch_read_data,
prefetch_read_instruction,
@@ -1201,7 +1225,6 @@ symbols! {
prelude,
prelude_import,
preserves_flags,
- primitive,
print_macro,
println_macro,
proc_dash_macro: "proc-macro",
@@ -1225,7 +1248,6 @@ symbols! {
ptr_const_is_null,
ptr_copy,
ptr_copy_nonoverlapping,
- ptr_drop_in_place,
ptr_eq,
ptr_from_ref,
ptr_guaranteed_cmp,
@@ -1330,13 +1352,10 @@ symbols! {
rtm_target_feature,
rust,
rust_2015,
- rust_2015_preview,
rust_2018,
rust_2018_preview,
rust_2021,
- rust_2021_preview,
rust_2024,
- rust_2024_preview,
rust_begin_unwind,
rust_cold_cc,
rust_eh_catch_typeinfo,
@@ -1381,7 +1400,6 @@ symbols! {
rustc_expected_cgu_reuse,
rustc_has_incoherent_inherent_impls,
rustc_hidden_type_of_opaques,
- rustc_host,
rustc_if_this_changed,
rustc_inherit_overflow_checks,
rustc_insignificant_dtor,
@@ -1498,6 +1516,8 @@ symbols! {
simd_insert,
simd_le,
simd_lt,
+ simd_masked_load,
+ simd_masked_store,
simd_mul,
simd_ne,
simd_neg,
@@ -1544,6 +1564,7 @@ symbols! {
slice_patterns,
slicing_syntax,
soft,
+ span_delayed_bug_from_inside_query,
specialization,
speed,
spotlight,
@@ -1587,7 +1608,6 @@ symbols! {
structural_match,
structural_peq,
structural_teq,
- sty,
sub,
sub_assign,
sub_with_overflow,
@@ -1709,7 +1729,6 @@ symbols! {
unrestricted_attribute_tokens,
unsafe_block_in_unsafe_fn,
unsafe_cell,
- unsafe_cell_from_mut,
unsafe_cell_raw_get,
unsafe_no_drop_flag,
unsafe_pin_internals,
@@ -1734,7 +1753,6 @@ symbols! {
used_with_arg,
using,
usize,
- v1,
va_arg,
va_copy,
va_end,
@@ -1766,7 +1784,6 @@ symbols! {
wasm_import_module,
wasm_target_feature,
while_let,
- width,
windows,
windows_subsystem,
with_negative_coherence,
@@ -1985,6 +2002,7 @@ impl fmt::Display for MacroRulesNormalizedIdent {
pub struct Symbol(SymbolIndex);
rustc_index::newtype_index! {
+ #[orderable]
struct SymbolIndex {}
}
@@ -2108,11 +2126,7 @@ impl Interner {
return Symbol::new(idx as u32);
}
- // SAFETY: we convert from `&str` to `&[u8]`, clone it into the arena,
- // and immediately convert the clone back to `&[u8]`, all because there
- // is no `inner.arena.alloc_str()` method. This is clearly safe.
- let string: &str =
- unsafe { str::from_utf8_unchecked(inner.arena.alloc_slice(string.as_bytes())) };
+ let string: &str = inner.arena.alloc_str(string);
// SAFETY: we can extend the arena allocation to `'static` because we
// only access these while the arena is still alive.