Skip to content

Commit 73e4e3b

Browse files
committed
Auto merge of #156153 - JonathanBrouwer:rollup-yxbgv3R, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #155543 (docs(unstable-book): Document const generics features) - #155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_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 + 29fb137 commit 73e4e3b

56 files changed

Lines changed: 759 additions & 101 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_codegen_ssa/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,10 @@ pub(crate) struct UnknownCTargetFeature<'a> {
12121212

12131213
#[derive(Diagnostic)]
12141214
#[diag("unstable feature specified for `-Ctarget-feature`: `{$feature}`")]
1215-
#[note("this feature is not stably supported; its behavior can change in the future")]
1215+
#[note("{$note}; its behavior can change in the future")]
12161216
pub(crate) struct UnstableCTargetFeature<'a> {
12171217
pub feature: &'a str,
1218+
pub note: &'a str,
12181219
}
12191220

12201221
#[derive(Diagnostic)]

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ pub(crate) fn from_target_feature_attr(
6262
feature: feature_str,
6363
reason,
6464
});
65-
} else if let Some(nightly_feature) = stability.requires_nightly()
65+
} else if let Some(nightly_feature) = stability.requires_nightly(/* in_cfg */ false)
6666
&& !rust_features.enabled(nightly_feature)
6767
{
68-
feature_err(
69-
&tcx.sess,
70-
nightly_feature,
71-
feature_span,
72-
format!("the target feature `{feature}` is currently unstable"),
73-
)
74-
.emit();
68+
let explain = if stability.is_cfg_stable_toggle_unstable() {
69+
format!("the target feature `{feature}` is allowed in cfg but unstable otherwise")
70+
} else {
71+
format!("the target feature `{feature}` is currently unstable")
72+
};
73+
feature_err(&tcx.sess, nightly_feature, feature_span, explain).emit();
7574
} else {
7675
// Add this and the implied features.
7776
for &name in tcx.implied_target_features(feature) {
@@ -315,12 +314,19 @@ pub fn cfg_target_feature<'a, const N: usize>(
315314
enabled: if enable { "enabled" } else { "disabled" },
316315
reason,
317316
});
318-
} else if stability.requires_nightly().is_some() {
317+
} else if stability.requires_nightly(/* in_cfg */ false).is_some() {
319318
// An unstable feature. Warn about using it. It makes little sense
320319
// to hard-error here since we just warn about fully unknown
321320
// features above.
322-
sess.dcx()
323-
.emit_warn(errors::UnstableCTargetFeature { feature: base_feature });
321+
let note = if stability.is_cfg_stable_toggle_unstable() {
322+
"this feature is allowed in cfg but unstable otherwise"
323+
} else {
324+
"this feature is not stably supported"
325+
};
326+
sess.dcx().emit_warn(errors::UnstableCTargetFeature {
327+
feature: base_feature,
328+
note,
329+
});
324330
}
325331
}
326332
}
@@ -346,7 +352,8 @@ pub fn cfg_target_feature<'a, const N: usize>(
346352
// "forbidden" features.
347353
if allow_unstable
348354
|| (gate.in_cfg()
349-
&& (sess.is_nightly_build() || gate.requires_nightly().is_none()))
355+
&& (sess.is_nightly_build()
356+
|| gate.requires_nightly(/* in_cfg */ true).is_none()))
350357
{
351358
Some(Symbol::intern(feature))
352359
} else {

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,

0 commit comments

Comments
 (0)