Skip to content

Commit 6ef8ad3

Browse files
committed
Auto merge of #156150 - JonathanBrouwer:rollup-4mvqynT, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #156062 (Added command-line argument support for `wasm32-wali-linux-musl`) - #155543 (docs(unstable-book): Document const generics features) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156128 (.mailmap: prefer matching just based on commit emails) - #156135 (Remove most uses of def_id_to_node_id)
2 parents cb40c25 + e41cb15 commit 6ef8ad3

56 files changed

Lines changed: 767 additions & 88 deletions

File tree

Some content is hidden

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

.mailmap

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,9 @@ Gregor Peach <gregorpeach@gmail.com>
259259
Grzegorz Bartoszek <grzegorz.bartoszek@thaumatec.com>
260260
Guanqun Lu <guanqun.lu@gmail.com>
261261
Guillaume Gomez <contact@guillaume-gomez.fr>
262-
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume1.gomez@gmail.com>
263-
Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <guillaume1.gomez@gmail.com>
264-
Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <ggomez@ggo.ifr.lan>
265-
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <ggomez@ggo.ifr.lan>
266-
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume.gomez@huawei.com>
262+
Guillaume Gomez <contact@guillaume-gomez.fr> <guillaume1.gomez@gmail.com>
263+
Guillaume Gomez <contact@guillaume-gomez.fr> <ggomez@ggo.ifr.lan>
264+
Guillaume Gomez <contact@guillaume-gomez.fr> <guillaume.gomez@huawei.com>
267265
gnzlbg <gonzalobg88@gmail.com> <gnzlbg@users.noreply.github.com>
268266
hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
269267
Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com>

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
562562

563563
// Don't hash unless necessary, because it's expensive.
564564
let opt_hir_hash =
565-
if tcx.needs_crate_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None };
565+
if tcx.needs_hir_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None };
566566

567567
let delayed_resolver = Steal::new((resolver, krate));
568568
mid_hir::Crate::new(owners, delayed_ids, delayed_resolver, opt_hir_hash)

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::ffi::c_uint;
33
use std::{assert_matches, iter, ptr};
44

55
use rustc_abi::{
6-
AddressSpace, Align, BackendRepr, Float, HasDataLayout, Integer, NumScalableVectors, Primitive,
7-
Size, WrappingRange,
6+
AddressSpace, Align, BackendRepr, CVariadicStatus, Float, HasDataLayout, Integer,
7+
NumScalableVectors, Primitive, Size, WrappingRange,
88
};
99
use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh};
1010
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
@@ -23,6 +23,7 @@ use rustc_middle::ty::{
2323
};
2424
use rustc_middle::{bug, span_bug};
2525
use rustc_session::config::CrateType;
26+
use rustc_session::errors::feature_err;
2627
use rustc_session::lint::builtin::DEPRECATED_LLVM_INTRINSIC;
2728
use rustc_span::{Span, Symbol, sym};
2829
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
@@ -288,6 +289,16 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
288289
}
289290
sym::breakpoint => self.call_intrinsic("llvm.debugtrap", &[], &[]),
290291
sym::va_arg => {
292+
let target = &self.cx.tcx.sess.target;
293+
let stability = target.supports_c_variadic_definitions();
294+
if let CVariadicStatus::Unstable { feature } = stability
295+
&& !self.tcx.features().enabled(feature)
296+
{
297+
let msg =
298+
format!("C-variadic function definitions on this target are unstable");
299+
feature_err(&*self.sess(), feature, span, msg).emit();
300+
}
301+
291302
let BackendRepr::Scalar(scalar) = result.layout.backend_repr else {
292303
bug!("the va_arg intrinsic does not support non-scalar types")
293304
};

compiler/rustc_feature/src/unstable.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,9 @@ declare_features! (
563563
/// Allows defining gen blocks and `gen fn`.
564564
(unstable, gen_blocks, "1.75.0", Some(117078)),
565565
/// Allows using generics in more complex const expressions, based on definitional equality.
566-
(unstable, generic_const_args, "1.95.0", Some(151972)),
567-
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
566+
(incomplete, generic_const_args, "1.95.0", Some(151972)),
567+
/// Allows non-trivial generic constants which have to be shown to successfully evaluate
568+
/// to a value by being part of an item signature.
568569
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
569570
/// Allows generic parameters and where-clauses on free & associated const items.
570571
(incomplete, generic_const_items, "1.73.0", Some(113521)),
@@ -626,7 +627,8 @@ declare_features! (
626627
/// Allows additional const parameter types, such as [u8; 10] or user defined types.
627628
/// User defined types must not have fields more private than the type itself.
628629
(unstable, min_adt_const_params, "1.96.0", Some(154042)),
629-
/// Enables the generic const args MVP (only bare paths, not arbitrary computation).
630+
/// Enables the generic const args MVP (paths to type const items and constructors
631+
/// for ADTs and primitives).
630632
(incomplete, min_generic_const_args, "1.84.0", Some(132980)),
631633
/// A minimal, sound subset of specialization intended to be used by the
632634
/// standard library until the soundness issues with specialization

compiler/rustc_interface/src/queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Linker {
3636
Linker {
3737
dep_graph: tcx.dep_graph.clone(),
3838
output_filenames: Arc::clone(tcx.output_filenames(())),
39-
crate_hash: if tcx.needs_crate_hash() {
39+
crate_hash: if tcx.sess.opts.incremental.is_some() {
4040
Some(tcx.crate_hash(LOCAL_CRATE))
4141
} else {
4242
None

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'tcx> TyCtxt<'tcx> {
237237
attrs: &SortedMap<ItemLocalId, &[Attribute]>,
238238
define_opaque: Option<&[(Span, LocalDefId)]>,
239239
) -> Hashes {
240-
if !self.needs_crate_hash() {
240+
if !self.needs_hir_hash() {
241241
return Hashes { opt_hash_including_bodies: None, attrs_hash: None };
242242
}
243243

compiler/rustc_middle/src/ty/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,12 +1127,12 @@ impl<'tcx> TyCtxt<'tcx> {
11271127
})
11281128
}
11291129

1130-
pub fn needs_crate_hash(self) -> bool {
1131-
// Why is the crate hash needed for these configurations?
1130+
pub fn needs_hir_hash(self) -> bool {
1131+
// Why is the hir hash needed for these configurations?
11321132
// - debug_assertions: for the "fingerprint the result" check in
11331133
// `rustc_query_impl::execution::execute_job`.
11341134
// - incremental: for query lookups.
1135-
// - needs_metadata: for putting into crate metadata.
1135+
// - needs_metadata: it is included in the crate metadata through the crate_hash query
11361136
// - instrument_coverage: for putting into coverage data (see
11371137
// `hash_mir_source`).
11381138
// - metrics_dir: metrics use the strict version hash in the filenames

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use std::sync::Arc;
99

1010
use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind};
1111
use rustc_ast::{
12-
self as ast, AssocItem, AssocItemKind, Block, ConstItem, Delegation, Fn, ForeignItem,
13-
ForeignItemKind, Inline, Item, ItemKind, NodeId, StaticItem, StmtKind, TraitAlias, TyAlias,
12+
self as ast, AssocItem, AssocItemKind, Block, ConstItem, DUMMY_NODE_ID, Delegation, Fn,
13+
ForeignItem, ForeignItemKind, Inline, Item, ItemKind, NodeId, StaticItem, StmtKind, TraitAlias,
14+
TyAlias,
1415
};
1516
use rustc_attr_parsing::AttributeParser;
1617
use rustc_expand::base::ResolverExpand;
@@ -168,7 +169,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
168169
let expn_id = self.cstore().expn_that_defined_untracked(self.tcx, def_id);
169170
let module = self.new_extern_module(
170171
parent,
171-
ModuleKind::Def(def_kind, def_id, Some(self.tcx.item_name(def_id))),
172+
ModuleKind::Def(
173+
def_kind,
174+
def_id,
175+
DUMMY_NODE_ID,
176+
Some(self.tcx.item_name(def_id)),
177+
),
172178
expn_id,
173179
self.def_span(def_id),
174180
// FIXME: Account for `#[no_implicit_prelude]` attributes.
@@ -251,7 +257,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
251257
// Any inherited visibility resolved directly inside an enum or trait
252258
// (i.e. variants, fields, and trait items) inherits from the visibility
253259
// of the enum or trait.
254-
ModuleKind::Def(DefKind::Enum | DefKind::Trait, def_id, _) => {
260+
ModuleKind::Def(DefKind::Enum | DefKind::Trait, def_id, _, _) => {
255261
self.tcx.visibility(def_id).expect_local()
256262
}
257263
// Otherwise, the visibility is restricted to the nearest parent `mod` item.
@@ -848,7 +854,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
848854
}
849855
let module = self.r.new_local_module(
850856
Some(parent),
851-
ModuleKind::Def(def_kind, def_id, Some(ident.name)),
857+
ModuleKind::Def(def_kind, def_id, item.id, Some(ident.name)),
852858
expansion.to_expn_id(),
853859
item.span,
854860
parent.no_implicit_prelude
@@ -882,7 +888,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
882888

883889
let module = self.r.new_local_module(
884890
Some(parent),
885-
ModuleKind::Def(def_kind, def_id, Some(ident.name)),
891+
ModuleKind::Def(def_kind, def_id, item.id, Some(ident.name)),
886892
expansion.to_expn_id(),
887893
item.span,
888894
parent.no_implicit_prelude,

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use std::ops::ControlFlow;
55
use itertools::Itertools as _;
66
use rustc_ast::visit::{self, Visitor};
77
use rustc_ast::{
8-
self as ast, CRATE_NODE_ID, Crate, ItemKind, ModKind, NodeId, Path, join_path_idents,
8+
self as ast, CRATE_NODE_ID, Crate, DUMMY_NODE_ID, ItemKind, ModKind, NodeId, Path,
9+
join_path_idents,
910
};
1011
use rustc_ast_pretty::pprust;
1112
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -192,11 +193,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
192193
}
193194

194195
fn report_with_use_injections(&mut self, krate: &Crate) {
195-
for UseError { mut err, candidates, def_id, instead, suggestion, path, is_call } in
196+
for UseError { mut err, candidates, node_id, instead, suggestion, path, is_call } in
196197
mem::take(&mut self.use_injections)
197198
{
198-
let (span, found_use) = if let Some(def_id) = def_id.as_local() {
199-
UsePlacementFinder::check(krate, self.def_id_to_node_id(def_id))
199+
let (span, found_use) = if node_id != DUMMY_NODE_ID {
200+
UsePlacementFinder::check(krate, node_id)
200201
} else {
201202
(None, FoundUse::No)
202203
};
@@ -242,7 +243,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
242243
let container = match old_binding.parent_module.unwrap().kind {
243244
// Avoid using TyCtxt::def_kind_descr in the resolver, because it
244245
// indirectly *calls* the resolver, and would cause a query cycle.
245-
ModuleKind::Def(kind, def_id, _) => kind.descr(def_id),
246+
ModuleKind::Def(kind, def_id, _, _) => kind.descr(def_id),
246247
ModuleKind::Block => "block",
247248
};
248249

@@ -1705,9 +1706,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17051706

17061707
let import_suggestions =
17071708
self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected);
1708-
let (span, found_use) = match parent_scope.module.nearest_parent_mod().as_local() {
1709-
Some(def_id) => UsePlacementFinder::check(krate, self.def_id_to_node_id(def_id)),
1710-
None => (None, FoundUse::No),
1709+
let (span, found_use) = match parent_scope.module.nearest_parent_mod_node_id() {
1710+
DUMMY_NODE_ID => (None, FoundUse::No),
1711+
node_id => UsePlacementFinder::check(krate, node_id),
17111712
};
17121713
show_candidates(
17131714
self.tcx,
@@ -1764,7 +1765,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17641765
}
17651766

17661767
if ident.name == kw::Default
1767-
&& let ModuleKind::Def(DefKind::Enum, def_id, _) = parent_scope.module.kind
1768+
&& let ModuleKind::Def(DefKind::Enum, def_id, _, _) = parent_scope.module.kind
17681769
{
17691770
let span = self.def_span(def_id);
17701771
let source_map = self.tcx.sess.source_map();
@@ -1892,19 +1893,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18921893
missing a `derive` attribute",
18931894
ident.name,
18941895
);
1895-
let sugg_span = if let ModuleKind::Def(DefKind::Enum, id, _) = parent_scope.module.kind
1896-
{
1897-
let span = self.def_span(id);
1898-
if span.from_expansion() {
1899-
None
1896+
let sugg_span =
1897+
if let ModuleKind::Def(DefKind::Enum, id, _, _) = parent_scope.module.kind {
1898+
let span = self.def_span(id);
1899+
if span.from_expansion() {
1900+
None
1901+
} else {
1902+
// For enum variants sugg_span is empty but we can get the enum's Span.
1903+
Some(span.shrink_to_lo())
1904+
}
19001905
} else {
1901-
// For enum variants sugg_span is empty but we can get the enum's Span.
1902-
Some(span.shrink_to_lo())
1903-
}
1904-
} else {
1905-
// For items this `Span` will be populated, everything else it'll be None.
1906-
sugg_span
1907-
};
1906+
// For items this `Span` will be populated, everything else it'll be None.
1907+
sugg_span
1908+
};
19081909
match sugg_span {
19091910
Some(span) => {
19101911
err.span_suggestion_verbose(

compiler/rustc_resolve/src/ident.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
644644
}
645645
}
646646
Scope::ModuleGlobs(module, _)
647-
if let ModuleKind::Def(_, def_id, _) = module.kind
647+
if let ModuleKind::Def(_, def_id, _, _) = module.kind
648648
&& !def_id.is_local() =>
649649
{
650650
// Fast path: external module decoding only creates non-glob declarations.

0 commit comments

Comments
 (0)