Skip to content

Commit 4d38622

Browse files
committed
Auto merge of #151634 - matthiaskrgr:rollup-cE0JR24, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #145393 (Add codegen test for removing trailing zeroes from `NonZero`) - #148764 (ptr_aligment_type: add more APIs) - #149869 (std: avoid tearing `dbg!` prints) - #150065 (add CSE optimization tests for iterating over slice) - #150842 (Fix(lib/win/thread): Ensure `Sleep`'s usage passes over the requested duration under Win7) - #151505 (Various refactors to the proc_macro bridge) - #151560 (relnotes: fix 1.93's `as_mut_array` methods) - #151317 (x86 soft-float feature: mark it as forbidden rather than unstable) - #151577 (Rename `DepKindStruct` to `DepKindVTable`) - #151620 (Fix 'the the' typo in library/core/src/array/iter.rs)
2 parents 75963ce + d83f2eb commit 4d38622

File tree

59 files changed

+1060
-823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1060
-823
lines changed

RELEASES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Stabilized APIs
6262
- [`<uN>::unchecked_shl`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unchecked_shl)
6363
- [`<uN>::unchecked_shr`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unchecked_shr)
6464
- [`<[T]>::as_array`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_array)
65-
- [`<[T]>::as_array_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_mut_array)
65+
- [`<[T]>::as_mut_array`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_mut_array)
6666
- [`<*const [T]>::as_array`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_array)
67-
- [`<*mut [T]>::as_array_mut`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_mut_array)
67+
- [`<*mut [T]>::as_mut_array`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_mut_array)
6868
- [`VecDeque::pop_front_if`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.pop_front_if)
6969
- [`VecDeque::pop_back_if`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.pop_back_if)
7070
- [`Duration::from_nanos_u128`](https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_nanos_u128)

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ impl ToInternal<rustc_errors::Level> for Level {
431431
}
432432
}
433433

434-
pub(crate) struct FreeFunctions;
435-
436434
pub(crate) struct Rustc<'a, 'b> {
437435
ecx: &'a mut ExtCtxt<'b>,
438436
def_site: Span,
@@ -461,13 +459,28 @@ impl<'a, 'b> Rustc<'a, 'b> {
461459
}
462460

463461
impl server::Types for Rustc<'_, '_> {
464-
type FreeFunctions = FreeFunctions;
465462
type TokenStream = TokenStream;
466463
type Span = Span;
467464
type Symbol = Symbol;
468465
}
469466

470-
impl server::FreeFunctions for Rustc<'_, '_> {
467+
impl server::Server for Rustc<'_, '_> {
468+
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
469+
ExpnGlobals {
470+
def_site: self.def_site,
471+
call_site: self.call_site,
472+
mixed_site: self.mixed_site,
473+
}
474+
}
475+
476+
fn intern_symbol(string: &str) -> Self::Symbol {
477+
Symbol::intern(string)
478+
}
479+
480+
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
481+
f(symbol.as_str())
482+
}
483+
471484
fn injected_env_var(&mut self, var: &str) -> Option<String> {
472485
self.ecx.sess.opts.logical_env.get(var).cloned()
473486
}
@@ -552,14 +565,20 @@ impl server::FreeFunctions for Rustc<'_, '_> {
552565
}
553566
diag.emit();
554567
}
555-
}
556568

557-
impl server::TokenStream for Rustc<'_, '_> {
558-
fn is_empty(&mut self, stream: &Self::TokenStream) -> bool {
569+
fn ts_drop(&mut self, stream: Self::TokenStream) {
570+
drop(stream);
571+
}
572+
573+
fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
574+
stream.clone()
575+
}
576+
577+
fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
559578
stream.is_empty()
560579
}
561580

562-
fn from_str(&mut self, src: &str) -> Self::TokenStream {
581+
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
563582
unwrap_or_emit_fatal(source_str_to_stream(
564583
self.psess(),
565584
FileName::proc_macro_source_code(src),
@@ -568,11 +587,11 @@ impl server::TokenStream for Rustc<'_, '_> {
568587
))
569588
}
570589

571-
fn to_string(&mut self, stream: &Self::TokenStream) -> String {
590+
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
572591
pprust::tts_to_string(stream)
573592
}
574593

575-
fn expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
594+
fn ts_expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
576595
// Parse the expression from our tokenstream.
577596
let expr: PResult<'_, _> = try {
578597
let mut p = Parser::new(self.psess(), stream.clone(), Some("proc_macro expand expr"));
@@ -633,14 +652,14 @@ impl server::TokenStream for Rustc<'_, '_> {
633652
}
634653
}
635654

636-
fn from_token_tree(
655+
fn ts_from_token_tree(
637656
&mut self,
638657
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
639658
) -> Self::TokenStream {
640659
Self::TokenStream::new((tree, &mut *self).to_internal().into_iter().collect::<Vec<_>>())
641660
}
642661

643-
fn concat_trees(
662+
fn ts_concat_trees(
644663
&mut self,
645664
base: Option<Self::TokenStream>,
646665
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
@@ -654,7 +673,7 @@ impl server::TokenStream for Rustc<'_, '_> {
654673
stream
655674
}
656675

657-
fn concat_streams(
676+
fn ts_concat_streams(
658677
&mut self,
659678
base: Option<Self::TokenStream>,
660679
streams: Vec<Self::TokenStream>,
@@ -666,24 +685,22 @@ impl server::TokenStream for Rustc<'_, '_> {
666685
stream
667686
}
668687

669-
fn into_trees(
688+
fn ts_into_trees(
670689
&mut self,
671690
stream: Self::TokenStream,
672691
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> {
673692
FromInternal::from_internal((stream, self))
674693
}
675-
}
676694

677-
impl server::Span for Rustc<'_, '_> {
678-
fn debug(&mut self, span: Self::Span) -> String {
695+
fn span_debug(&mut self, span: Self::Span) -> String {
679696
if self.ecx.ecfg.span_debug {
680697
format!("{span:?}")
681698
} else {
682699
format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
683700
}
684701
}
685702

686-
fn file(&mut self, span: Self::Span) -> String {
703+
fn span_file(&mut self, span: Self::Span) -> String {
687704
self.psess()
688705
.source_map()
689706
.lookup_char_pos(span.lo())
@@ -693,7 +710,7 @@ impl server::Span for Rustc<'_, '_> {
693710
.to_string()
694711
}
695712

696-
fn local_file(&mut self, span: Self::Span) -> Option<String> {
713+
fn span_local_file(&mut self, span: Self::Span) -> Option<String> {
697714
self.psess()
698715
.source_map()
699716
.lookup_char_pos(span.lo())
@@ -708,41 +725,41 @@ impl server::Span for Rustc<'_, '_> {
708725
})
709726
}
710727

711-
fn parent(&mut self, span: Self::Span) -> Option<Self::Span> {
728+
fn span_parent(&mut self, span: Self::Span) -> Option<Self::Span> {
712729
span.parent_callsite()
713730
}
714731

715-
fn source(&mut self, span: Self::Span) -> Self::Span {
732+
fn span_source(&mut self, span: Self::Span) -> Self::Span {
716733
span.source_callsite()
717734
}
718735

719-
fn byte_range(&mut self, span: Self::Span) -> Range<usize> {
736+
fn span_byte_range(&mut self, span: Self::Span) -> Range<usize> {
720737
let source_map = self.psess().source_map();
721738

722739
let relative_start_pos = source_map.lookup_byte_offset(span.lo()).pos;
723740
let relative_end_pos = source_map.lookup_byte_offset(span.hi()).pos;
724741

725742
Range { start: relative_start_pos.0 as usize, end: relative_end_pos.0 as usize }
726743
}
727-
fn start(&mut self, span: Self::Span) -> Self::Span {
744+
fn span_start(&mut self, span: Self::Span) -> Self::Span {
728745
span.shrink_to_lo()
729746
}
730747

731-
fn end(&mut self, span: Self::Span) -> Self::Span {
748+
fn span_end(&mut self, span: Self::Span) -> Self::Span {
732749
span.shrink_to_hi()
733750
}
734751

735-
fn line(&mut self, span: Self::Span) -> usize {
752+
fn span_line(&mut self, span: Self::Span) -> usize {
736753
let loc = self.psess().source_map().lookup_char_pos(span.lo());
737754
loc.line
738755
}
739756

740-
fn column(&mut self, span: Self::Span) -> usize {
757+
fn span_column(&mut self, span: Self::Span) -> usize {
741758
let loc = self.psess().source_map().lookup_char_pos(span.lo());
742759
loc.col.to_usize() + 1
743760
}
744761

745-
fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span> {
762+
fn span_join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span> {
746763
let self_loc = self.psess().source_map().lookup_char_pos(first.lo());
747764
let other_loc = self.psess().source_map().lookup_char_pos(second.lo());
748765

@@ -753,7 +770,7 @@ impl server::Span for Rustc<'_, '_> {
753770
Some(first.to(second))
754771
}
755772

756-
fn subspan(
773+
fn span_subspan(
757774
&mut self,
758775
span: Self::Span,
759776
start: Bound<usize>,
@@ -789,11 +806,11 @@ impl server::Span for Rustc<'_, '_> {
789806
Some(span.with_lo(new_lo).with_hi(new_hi))
790807
}
791808

792-
fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
809+
fn span_resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
793810
span.with_ctxt(at.ctxt())
794811
}
795812

796-
fn source_text(&mut self, span: Self::Span) -> Option<String> {
813+
fn span_source_text(&mut self, span: Self::Span) -> Option<String> {
797814
self.psess().source_map().span_to_snippet(span).ok()
798815
}
799816

@@ -821,41 +838,21 @@ impl server::Span for Rustc<'_, '_> {
821838
/// span from the metadata of `my_proc_macro` (which we have access to,
822839
/// since we've loaded `my_proc_macro` from disk in order to execute it).
823840
/// In this way, we have obtained a span pointing into `my_proc_macro`
824-
fn save_span(&mut self, span: Self::Span) -> usize {
841+
fn span_save_span(&mut self, span: Self::Span) -> usize {
825842
self.psess().save_proc_macro_span(span)
826843
}
827844

828-
fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span {
845+
fn span_recover_proc_macro_span(&mut self, id: usize) -> Self::Span {
829846
let (resolver, krate, def_site) = (&*self.ecx.resolver, self.krate, self.def_site);
830847
*self.rebased_spans.entry(id).or_insert_with(|| {
831848
// FIXME: `SyntaxContext` for spans from proc macro crates is lost during encoding,
832849
// replace it with a def-site context until we are encoding it properly.
833850
resolver.get_proc_macro_quoted_span(krate, id).with_ctxt(def_site.ctxt())
834851
})
835852
}
836-
}
837853

838-
impl server::Symbol for Rustc<'_, '_> {
839-
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
854+
fn symbol_normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
840855
let sym = nfc_normalize(string);
841856
if rustc_lexer::is_ident(sym.as_str()) { Ok(sym) } else { Err(()) }
842857
}
843858
}
844-
845-
impl server::Server for Rustc<'_, '_> {
846-
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
847-
ExpnGlobals {
848-
def_site: self.def_site,
849-
call_site: self.call_site,
850-
mixed_site: self.mixed_site,
851-
}
852-
}
853-
854-
fn intern_symbol(string: &str) -> Self::Symbol {
855-
Symbol::intern(string)
856-
}
857-
858-
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
859-
f(symbol.as_str())
860-
}
861-
}

compiler/rustc_interface/src/callbacks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) ->
7272
pub fn dep_kind_debug(kind: DepKind, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7373
tls::with_opt(|opt_tcx| {
7474
if let Some(tcx) = opt_tcx {
75-
write!(f, "{}", tcx.dep_kind_info(kind).name)
75+
write!(f, "{}", tcx.dep_kind_vtable(kind).name)
7676
} else {
7777
default_dep_kind_debug(kind, f)
7878
}

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
992992
hir_arena,
993993
untracked,
994994
dep_graph,
995-
rustc_query_impl::query_callbacks(arena),
995+
rustc_query_impl::make_dep_kind_vtables(arena),
996996
rustc_query_impl::query_system(
997997
providers.queries,
998998
providers.extern_queries,

compiler/rustc_middle/src/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ macro_rules! arena_types {
104104
[decode] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::ItemLocalId>,
105105
[decode] impl_source: rustc_middle::traits::ImplSource<'tcx, ()>,
106106

107-
[] dep_kind: rustc_middle::dep_graph::DepKindStruct<'tcx>,
107+
[] dep_kind_vtable: rustc_middle::dep_graph::DepKindVTable<'tcx>,
108108

109109
[decode] trait_impl_trait_tys:
110110
rustc_data_structures::unord::UnordMap<

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use rustc_query_system::dep_graph::{
1818

1919
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
2020

21-
pub type DepKindStruct<'tcx> = rustc_query_system::dep_graph::DepKindStruct<TyCtxt<'tcx>>;
21+
pub type DepKindVTable<'tcx> = rustc_query_system::dep_graph::DepKindVTable<TyCtxt<'tcx>>;
2222

2323
pub struct DepsType;
2424

@@ -79,8 +79,8 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
7979
}
8080

8181
#[inline]
82-
fn dep_kind_info(&self, dk: DepKind) -> &DepKindStruct<'tcx> {
83-
&self.query_kinds[dk.as_usize()]
82+
fn dep_kind_vtable(&self, dk: DepKind) -> &DepKindVTable<'tcx> {
83+
&self.dep_kind_vtables[dk.as_usize()]
8484
}
8585

8686
fn with_reduced_queries<T>(self, f: impl FnOnce() -> T) -> T {

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use rustc_type_ir::{
5959
use tracing::{debug, instrument};
6060

6161
use crate::arena::Arena;
62-
use crate::dep_graph::{DepGraph, DepKindStruct};
62+
use crate::dep_graph::{DepGraph, DepKindVTable};
6363
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind, CanonicalVarKinds};
6464
use crate::lint::lint_level;
6565
use crate::metadata::ModChild;
@@ -1580,7 +1580,7 @@ pub struct GlobalCtxt<'tcx> {
15801580
untracked: Untracked,
15811581

15821582
pub query_system: QuerySystem<'tcx>,
1583-
pub(crate) query_kinds: &'tcx [DepKindStruct<'tcx>],
1583+
pub(crate) dep_kind_vtables: &'tcx [DepKindVTable<'tcx>],
15841584

15851585
// Internal caches for metadata decoding. No need to track deps on this.
15861586
pub ty_rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
@@ -1801,7 +1801,7 @@ impl<'tcx> TyCtxt<'tcx> {
18011801
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
18021802
untracked: Untracked,
18031803
dep_graph: DepGraph,
1804-
query_kinds: &'tcx [DepKindStruct<'tcx>],
1804+
dep_kind_vtables: &'tcx [DepKindVTable<'tcx>],
18051805
query_system: QuerySystem<'tcx>,
18061806
hooks: crate::hooks::Providers,
18071807
current_gcx: CurrentGcx,
@@ -1831,7 +1831,7 @@ impl<'tcx> TyCtxt<'tcx> {
18311831
consts: common_consts,
18321832
untracked,
18331833
query_system,
1834-
query_kinds,
1834+
dep_kind_vtables,
18351835
ty_rcache: Default::default(),
18361836
selection_cache: Default::default(),
18371837
evaluation_cache: Default::default(),

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use rustc_data_structures::stable_hasher::HashStable;
1010
use rustc_data_structures::sync::AtomicU64;
1111
use rustc_middle::arena::Arena;
12-
use rustc_middle::dep_graph::{self, DepKind, DepKindStruct, DepNodeIndex};
12+
use rustc_middle::dep_graph::{self, DepKind, DepKindVTable, DepNodeIndex};
1313
use rustc_middle::query::erase::{Erase, erase, restore};
1414
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
1515
use rustc_middle::query::plumbing::{DynamicQuery, QuerySystem, QuerySystemFns};

0 commit comments

Comments
 (0)