Skip to content

Commit f58ffc9

Browse files
committed
Auto merge of rust-lang#78334 - jonas-schievink:rollup-z0gzbmm, r=jonas-schievink
Rollup of 12 pull requests Successful merges: - rust-lang#75115 (`#[deny(unsafe_op_in_unsafe_fn)]` in sys/cloudabi) - rust-lang#76614 (change the order of type arguments on ControlFlow) - rust-lang#77610 (revise Hermit's mutex interface to support the behaviour of StaticMutex) - rust-lang#77830 (Simplify query proc-macros) - rust-lang#77930 (Do not ICE with TraitPredicates containing [type error]) - rust-lang#78069 (Fix const core::panic!(non_literal_str).) - rust-lang#78072 (Cleanup constant matching in exhaustiveness checking) - rust-lang#78119 (Throw core::panic!("message") as &str instead of String.) - rust-lang#78191 (Introduce a temporary for discriminant value in MatchBranchSimplification) - rust-lang#78272 (const_evaluatable_checked: deal with unused nodes + div) - rust-lang#78318 (TyCtxt: generate single impl block with `slice_interners` macro) - rust-lang#78327 (resolve: Relax macro resolution consistency check to account for any errors) Failed merges: r? `@ghost`
2 parents ffa2e7a + 58ae889 commit f58ffc9

File tree

66 files changed

+1418
-820
lines changed

Some content is hidden

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

66 files changed

+1418
-820
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,9 @@ dependencies = [
13661366

13671367
[[package]]
13681368
name = "hermit-abi"
1369-
version = "0.1.15"
1369+
version = "0.1.17"
13701370
source = "registry+https://github.com/rust-lang/crates.io-index"
1371-
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
1371+
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
13721372
dependencies = [
13731373
"compiler_builtins",
13741374
"libc",

compiler/rustc_data_structures/src/graph/iterate/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::{DirectedGraph, WithNumNodes, WithStartNode, WithSuccessors};
22
use rustc_index::bit_set::BitSet;
33
use rustc_index::vec::IndexVec;
4+
use std::ops::ControlFlow;
45

56
#[cfg(test)]
67
mod tests;
@@ -86,10 +87,6 @@ where
8687
}
8788
}
8889

89-
/// Allows searches to terminate early with a value.
90-
// FIXME (#75744): remove the alias once the generics are in a better order and `C=()`.
91-
pub type ControlFlow<T> = std::ops::ControlFlow<(), T>;
92-
9390
/// The status of a node in the depth-first search.
9491
///
9592
/// See the documentation of `TriColorDepthFirstSearch` to see how a node's status is updated

compiler/rustc_data_structures/src/profiling.rs

-11
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,6 @@ cfg_if! {
111111

112112
type Profiler = measureme::Profiler<SerializationSink>;
113113

114-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
115-
pub enum ProfileCategory {
116-
Parsing,
117-
Expansion,
118-
TypeChecking,
119-
BorrowChecking,
120-
Codegen,
121-
Linking,
122-
Other,
123-
}
124-
125114
bitflags::bitflags! {
126115
struct EventFilter: u32 {
127116
const GENERIC_ACTIVITIES = 1 << 0;

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ language_item_table! {
263263
// is required to define it somewhere. Additionally, there are restrictions on crates that use
264264
// a weak lang item, but do not have it defined.
265265
Panic, sym::panic, panic_fn, Target::Fn;
266+
PanicStr, sym::panic_str, panic_str, Target::Fn;
266267
PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn;
267268
PanicInfo, sym::panic_info, panic_info, Target::Struct;
268269
PanicLocation, sym::panic_location, panic_location, Target::Struct;

compiler/rustc_macros/src/query.rs

+6-66
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ impl<T: Parse> Parse for List<T> {
190190
}
191191

192192
/// A named group containing queries.
193+
///
194+
/// For now, the name is not used any more, but the capability remains interesting for future
195+
/// developments of the query system.
193196
struct Group {
197+
#[allow(unused)]
194198
name: Ident,
195199
queries: List<Query>,
196200
}
@@ -417,12 +421,9 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
417421
let mut query_stream = quote! {};
418422
let mut query_description_stream = quote! {};
419423
let mut dep_node_def_stream = quote! {};
420-
let mut dep_node_force_stream = quote! {};
421-
let mut try_load_from_on_disk_cache_stream = quote! {};
422424
let mut cached_queries = quote! {};
423425

424426
for group in groups.0 {
425-
let mut group_stream = quote! {};
426427
for mut query in group.queries.0 {
427428
let modifiers = process_modifiers(&mut query);
428429
let name = &query.name;
@@ -437,22 +438,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
437438
cached_queries.extend(quote! {
438439
#name,
439440
});
440-
441-
try_load_from_on_disk_cache_stream.extend(quote! {
442-
::rustc_middle::dep_graph::DepKind::#name => {
443-
if <#arg as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
444-
debug_assert!($tcx.dep_graph
445-
.node_color($dep_node)
446-
.map(|c| c.is_green())
447-
.unwrap_or(false));
448-
449-
let key = <#arg as DepNodeParams<TyCtxt<'_>>>::recover($tcx, $dep_node).unwrap();
450-
if queries::#name::cache_on_disk($tcx, &key, None) {
451-
let _ = $tcx.#name(key);
452-
}
453-
}
454-
}
455-
});
456441
}
457442

458443
let mut attributes = Vec::new();
@@ -485,47 +470,20 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
485470
let attribute_stream = quote! {#(#attributes),*};
486471
let doc_comments = query.doc_comments.iter();
487472
// Add the query to the group
488-
group_stream.extend(quote! {
473+
query_stream.extend(quote! {
489474
#(#doc_comments)*
490-
[#attribute_stream] fn #name: #name(#arg) #result,
475+
[#attribute_stream] fn #name(#arg) #result,
491476
});
492477

493478
// Create a dep node for the query
494479
dep_node_def_stream.extend(quote! {
495480
[#attribute_stream] #name(#arg),
496481
});
497482

498-
// Add a match arm to force the query given the dep node
499-
dep_node_force_stream.extend(quote! {
500-
::rustc_middle::dep_graph::DepKind::#name => {
501-
if <#arg as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
502-
if let Some(key) = <#arg as DepNodeParams<TyCtxt<'_>>>::recover($tcx, $dep_node) {
503-
force_query::<crate::ty::query::queries::#name<'_>, _>(
504-
$tcx,
505-
key,
506-
DUMMY_SP,
507-
*$dep_node
508-
);
509-
return true;
510-
}
511-
}
512-
}
513-
});
514-
515483
add_query_description_impl(&query, modifiers, &mut query_description_stream);
516484
}
517-
let name = &group.name;
518-
query_stream.extend(quote! {
519-
#name { #group_stream },
520-
});
521485
}
522486

523-
dep_node_force_stream.extend(quote! {
524-
::rustc_middle::dep_graph::DepKind::Null => {
525-
bug!("Cannot force dep node: {:?}", $dep_node)
526-
}
527-
});
528-
529487
TokenStream::from(quote! {
530488
macro_rules! rustc_query_append {
531489
([$($macro:tt)*][$($other:tt)*]) => {
@@ -546,30 +504,12 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
546504
);
547505
}
548506
}
549-
macro_rules! rustc_dep_node_force {
550-
([$dep_node:expr, $tcx:expr] $($other:tt)*) => {
551-
match $dep_node.kind {
552-
$($other)*
553-
554-
#dep_node_force_stream
555-
}
556-
}
557-
}
558507
macro_rules! rustc_cached_queries {
559508
($($macro:tt)*) => {
560509
$($macro)*(#cached_queries);
561510
}
562511
}
563512

564513
#query_description_stream
565-
566-
macro_rules! rustc_dep_node_try_load_from_on_disk_cache {
567-
($dep_node:expr, $tcx:expr) => {
568-
match $dep_node.kind {
569-
#try_load_from_on_disk_cache_stream
570-
_ => (),
571-
}
572-
}
573-
}
574514
})
575515
}

compiler/rustc_middle/src/ty/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2036,13 +2036,13 @@ direct_interners! {
20362036

20372037
macro_rules! slice_interners {
20382038
($($field:ident: $method:ident($ty:ty)),+ $(,)?) => (
2039-
$(impl<'tcx> TyCtxt<'tcx> {
2040-
pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
2039+
impl<'tcx> TyCtxt<'tcx> {
2040+
$(pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
20412041
self.interners.$field.intern_ref(v, || {
20422042
Interned(List::from_arena(&*self.arena, v))
20432043
}).0
2044-
}
2045-
})+
2044+
})+
2045+
}
20462046
);
20472047
}
20482048

compiler/rustc_middle/src/ty/query/mod.rs

+57-13
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use crate::ty::util::AlwaysRequiresDrop;
3434
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
3535
use rustc_data_structures::fingerprint::Fingerprint;
3636
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
37-
use rustc_data_structures::profiling::ProfileCategory::*;
3837
use rustc_data_structures::stable_hasher::StableVec;
3938
use rustc_data_structures::svh::Svh;
4039
use rustc_data_structures::sync::Lrc;
@@ -169,26 +168,71 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
169168
return false;
170169
}
171170

172-
rustc_dep_node_force!([dep_node, tcx]
173-
// These are inputs that are expected to be pre-allocated and that
174-
// should therefore always be red or green already.
175-
DepKind::CrateMetadata |
171+
macro_rules! force_from_dep_node {
172+
($($(#[$attr:meta])* [$($modifiers:tt)*] $name:ident($K:ty),)*) => {
173+
match dep_node.kind {
174+
// These are inputs that are expected to be pre-allocated and that
175+
// should therefore always be red or green already.
176+
DepKind::CrateMetadata |
176177

177-
// These are anonymous nodes.
178-
DepKind::TraitSelect |
178+
// These are anonymous nodes.
179+
DepKind::TraitSelect |
179180

180-
// We don't have enough information to reconstruct the query key of
181-
// these.
182-
DepKind::CompileCodegenUnit => {
183-
bug!("force_from_dep_node: encountered {:?}", dep_node)
181+
// We don't have enough information to reconstruct the query key of
182+
// these.
183+
DepKind::CompileCodegenUnit |
184+
185+
// Forcing this makes no sense.
186+
DepKind::Null => {
187+
bug!("force_from_dep_node: encountered {:?}", dep_node)
188+
}
189+
190+
$(DepKind::$name => {
191+
debug_assert!(<$K as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key());
192+
193+
if let Some(key) = <$K as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node) {
194+
force_query::<queries::$name<'_>, _>(
195+
tcx,
196+
key,
197+
DUMMY_SP,
198+
*dep_node
199+
);
200+
return true;
201+
}
202+
})*
203+
}
184204
}
185-
);
205+
}
206+
207+
rustc_dep_node_append! { [force_from_dep_node!][] }
186208

187209
false
188210
}
189211

190212
pub(crate) fn try_load_from_on_disk_cache<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) {
191-
rustc_dep_node_try_load_from_on_disk_cache!(dep_node, tcx)
213+
macro_rules! try_load_from_on_disk_cache {
214+
($($name:ident,)*) => {
215+
match dep_node.kind {
216+
$(DepKind::$name => {
217+
if <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
218+
debug_assert!(tcx.dep_graph
219+
.node_color(dep_node)
220+
.map(|c| c.is_green())
221+
.unwrap_or(false));
222+
223+
let key = <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node).unwrap();
224+
if queries::$name::cache_on_disk(tcx, &key, None) {
225+
let _ = tcx.$name(key);
226+
}
227+
}
228+
})*
229+
230+
_ => (),
231+
}
232+
}
233+
}
234+
235+
rustc_cached_queries!(try_load_from_on_disk_cache!);
192236
}
193237

194238
mod sealed {

compiler/rustc_middle/src/ty/query/plumbing.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -242,33 +242,22 @@ macro_rules! hash_result {
242242
};
243243
}
244244

245-
macro_rules! define_queries {
246-
(<$tcx:tt> $($category:tt {
247-
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*
248-
},)*) => {
249-
define_queries_inner! { <$tcx>
250-
$($( $(#[$attr])* category<$category> [$($modifiers)*] fn $name: $node($($K)*) -> $V,)*)*
251-
}
252-
}
253-
}
254-
255245
macro_rules! query_helper_param_ty {
256246
(DefId) => { impl IntoQueryParam<DefId> };
257247
($K:ty) => { $K };
258248
}
259249

260-
macro_rules! define_queries_inner {
250+
macro_rules! define_queries {
261251
(<$tcx:tt>
262-
$($(#[$attr:meta])* category<$category:tt>
263-
[$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*) => {
252+
$($(#[$attr:meta])*
253+
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
264254

265255
use std::mem;
266256
use crate::{
267257
rustc_data_structures::stable_hasher::HashStable,
268258
rustc_data_structures::stable_hasher::StableHasher,
269259
ich::StableHashingContext
270260
};
271-
use rustc_data_structures::profiling::ProfileCategory;
272261

273262
define_queries_struct! {
274263
tcx: $tcx,
@@ -362,13 +351,12 @@ macro_rules! define_queries_inner {
362351
as QueryStorage
363352
>::Stored;
364353
const NAME: &'static str = stringify!($name);
365-
const CATEGORY: ProfileCategory = $category;
366354
}
367355

368356
impl<$tcx> QueryAccessors<TyCtxt<$tcx>> for queries::$name<$tcx> {
369357
const ANON: bool = is_anon!([$($modifiers)*]);
370358
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
371-
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
359+
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$name;
372360

373361
type Cache = query_storage!([$($modifiers)*][$($K)*, $V]);
374362

compiler/rustc_middle/src/ty/query/stats.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ pub fn print_stats(tcx: TyCtxt<'_>) {
120120
}
121121

122122
macro_rules! print_stats {
123-
(<$tcx:tt> $($category:tt {
124-
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*
125-
},)*) => {
123+
(<$tcx:tt>
124+
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($K:ty) -> $V:ty,)*
125+
) => {
126126
fn query_stats(tcx: TyCtxt<'_>) -> Vec<QueryStats> {
127127
let mut queries = Vec::new();
128128

129-
$($(
129+
$(
130130
queries.push(stats::<
131131
crate::dep_graph::DepKind,
132132
<TyCtxt<'_> as QueryContext>::Query,
@@ -135,7 +135,7 @@ macro_rules! print_stats {
135135
stringify!($name),
136136
&tcx.queries.$name,
137137
));
138-
)*)*
138+
)*
139139

140140
queries
141141
}

compiler/rustc_mir/src/const_eval/machine.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
7070
) -> InterpResult<'tcx> {
7171
let def_id = instance.def_id();
7272
if Some(def_id) == self.tcx.lang_items().panic_fn()
73+
|| Some(def_id) == self.tcx.lang_items().panic_str()
7374
|| Some(def_id) == self.tcx.lang_items().begin_panic_fn()
7475
{
75-
// &'static str
76+
// &str
7677
assert!(args.len() == 1);
7778

7879
let msg_place = self.deref_operand(args[0])?;

compiler/rustc_mir/src/transform/check_consts/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ impl ConstCx<'mir, 'tcx> {
7474

7575
/// Returns `true` if this `DefId` points to one of the official `panic` lang items.
7676
pub fn is_lang_panic_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
77-
Some(def_id) == tcx.lang_items().panic_fn() || Some(def_id) == tcx.lang_items().begin_panic_fn()
77+
Some(def_id) == tcx.lang_items().panic_fn()
78+
|| Some(def_id) == tcx.lang_items().panic_str()
79+
|| Some(def_id) == tcx.lang_items().begin_panic_fn()
7880
}
7981

8082
pub fn allow_internal_unstable(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbol) -> bool {

0 commit comments

Comments
 (0)