diff options
| author | lukaslueg <lukas.lueg@gmail.com> | 2021-04-06 18:23:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-06 18:23:21 +0200 |
| commit | 72796a7c36d60cd5d32e181dd0fca924399c2a03 (patch) | |
| tree | 157b3a3527632082291a2c17b39d22ab5395cfe1 /compiler/rustc_span/src | |
| parent | 7f32fda78c60bb5b05e610a1c0c0fecaff07f497 (diff) | |
| parent | 5c897d430dcbec6b10a9925f7de054dbc0ad3c52 (diff) | |
| download | rust-72796a7c36d60cd5d32e181dd0fca924399c2a03.tar.gz rust-72796a7c36d60cd5d32e181dd0fca924399c2a03.zip | |
Merge branch 'master' into stab_peek_mut
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/def_id.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_span/src/hygiene.rs | 28 | ||||
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 4 |
4 files changed, 9 insertions, 32 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 885f30ebb4e..95bb0ad7ba2 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -160,6 +160,8 @@ impl DefPathHash { } /// Returns the crate-local part of the [DefPathHash]. + /// + /// Used for tests. #[inline] pub fn local_hash(&self) -> u64 { self.0.as_value().1 diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index eb5b7c4a74a..6805d4f2890 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -413,7 +413,7 @@ pub fn update_dollar_crate_names(mut get_name: impl FnMut(SyntaxContext) -> Symb let names: Vec<_> = range_to_update.clone().map(|idx| get_name(SyntaxContext::from_u32(idx as u32))).collect(); HygieneData::with(|data| { - range_to_update.zip(names.into_iter()).for_each(|(idx, name)| { + range_to_update.zip(names).for_each(|(idx, name)| { data.syntax_context_data[idx].dollar_crate_name = name; }) }) @@ -1176,11 +1176,7 @@ pub fn decode_syntax_context< Ok(new_ctxt) } -pub fn num_syntax_ctxts() -> usize { - HygieneData::with(|data| data.syntax_context_data.len()) -} - -pub fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>( +fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>( ctxts: impl Iterator<Item = SyntaxContext>, mut f: F, ) -> Result<(), E> { @@ -1193,7 +1189,7 @@ pub fn for_all_ctxts_in<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Ok(()) } -pub fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>( +fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>( expns: impl Iterator<Item = ExpnId>, mut f: F, ) -> Result<(), E> { @@ -1206,16 +1202,6 @@ pub fn for_all_expns_in<E, F: FnMut(u32, ExpnId, &ExpnData) -> Result<(), E>>( Ok(()) } -pub fn for_all_data<E, F: FnMut((u32, SyntaxContext, &SyntaxContextData)) -> Result<(), E>>( - mut f: F, -) -> Result<(), E> { - let all_data = HygieneData::with(|data| data.syntax_context_data.clone()); - for (i, data) in all_data.into_iter().enumerate() { - f((i as u32, SyntaxContext(i as u32), &data))?; - } - Ok(()) -} - impl<E: Encoder> Encodable<E> for ExpnId { default fn encode(&self, _: &mut E) -> Result<(), E::Error> { panic!("cannot encode `ExpnId` with `{}`", std::any::type_name::<E>()); @@ -1228,14 +1214,6 @@ impl<D: Decoder> Decodable<D> for ExpnId { } } -pub fn for_all_expn_data<E, F: FnMut(u32, &ExpnData) -> Result<(), E>>(mut f: F) -> Result<(), E> { - let all_data = HygieneData::with(|data| data.expn_data.clone()); - for (i, data) in all_data.into_iter().enumerate() { - f(i as u32, &data.unwrap_or_else(|| panic!("Missing ExpnData!")))?; - } - Ok(()) -} - pub fn raw_encode_syntax_context<E: Encoder>( ctxt: SyntaxContext, context: &HygieneEncodeContext, diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d2790335b5a..6f6ff37c525 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1037,10 +1037,6 @@ pub enum ExternalSourceKind { } impl ExternalSource { - pub fn is_absent(&self) -> bool { - !matches!(self, ExternalSource::Foreign { kind: ExternalSourceKind::Present(_), .. }) - } - pub fn get_source(&self) -> Option<&Lrc<String>> { match self { ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src), @@ -1433,9 +1429,6 @@ impl SourceFile { self.src.is_none() } - pub fn byte_length(&self) -> u32 { - self.end_pos.0 - self.start_pos.0 - } pub fn count_lines(&self) -> usize { self.lines.len() } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 116519855d7..54fea551594 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -477,6 +477,7 @@ symbols! { doc_cfg, doc_keyword, doc_masked, + doc_notable_trait, doc_spotlight, doctest, document_private_items, @@ -560,6 +561,7 @@ symbols! { fmt, fmt_internals, fmul_fast, + fn_align, fn_must_use, fn_mut, fn_once, @@ -801,6 +803,7 @@ symbols! { noreturn, nostack, not, + notable_trait, note, object_safe_for_dispatch, of, @@ -1292,6 +1295,7 @@ symbols! { vreg, vreg_low16, warn, + wasm, wasm_import_module, wasm_target_feature, while_let, |
