Skip to content

Commit a41abee

Browse files
committed
Auto merge of #156158 - JonathanBrouwer:rollup-fd5s7KQ, r=JonathanBrouwer
Rollup of 12 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`.) - #156103 (Fix E0040 suggestion for explicit `Drop::drop` UFCS calls) - #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) - #156152 (Update books)
2 parents cb40c25 + c966c2b commit a41abee

64 files changed

Lines changed: 833 additions & 109 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_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(crate) fn check_legal_trait_for_method_call(
4242
if tcx.is_lang_item(trait_id, LangItem::Drop) {
4343
let sugg = if let Some(receiver) = receiver.filter(|s| !s.is_empty()) {
4444
errors::ExplicitDestructorCallSugg::Snippet {
45-
lo: expr_span.shrink_to_lo(),
45+
lo: expr_span.shrink_to_lo().to(receiver.shrink_to_lo()),
4646
hi: receiver.shrink_to_hi().to(expr_span.shrink_to_hi()),
4747
}
4848
} else {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10071007
debug!(?def_id, ?container, ?container_id);
10081008
match container {
10091009
ty::AssocContainer::Trait => {
1010+
let arg_span = if let hir::Node::Expr(call_expr) =
1011+
self.tcx.parent_hir_node(hir_id)
1012+
&& let hir::ExprKind::Call(_, args) = call_expr.kind
1013+
&& let Some(first_arg) = args.first()
1014+
{
1015+
let mut arg = first_arg;
1016+
while let hir::ExprKind::AddrOf(_, _, inner) = arg.kind {
1017+
arg = inner;
1018+
}
1019+
Some(arg.span)
1020+
} else {
1021+
None
1022+
};
1023+
10101024
if let Err(e) = callee::check_legal_trait_for_method_call(
10111025
tcx,
10121026
path_span,
1013-
None,
1027+
arg_span,
10141028
span,
10151029
container_id,
10161030
self.body_id.to_def_id(),

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

0 commit comments

Comments
 (0)