Skip to content

Commit 35f6640

Browse files
committed
Auto merge of #145588 - jhpratt:rollup-gfojsgp, r=jhpratt
Rollup of 33 pull requests Successful merges: - #139345 (Extend `QueryStability` to handle `IntoIterator` implementations) - #140740 (Add `-Zindirect-branch-cs-prefix`) - #142079 (nll-relate: improve hr opaque types support) - #142938 (implement std::fs::set_permissions_nofollow on unix) - #144767 (Correct some grammar in integer documentation) - #144906 (Require approval from t-infra instead of t-release on tier bumps) - #144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #145025 (run spellcheck as a tidy extra check in ci) - #145166 (suggest using `pub(crate)` for E0364) - #145255 (dec2flt: Provide more valid inputs examples) - #145306 (Add tracing to various miscellaneous functions) - #145336 (Hide docs for `core::unicode`) - #145429 (Couple of codegen_fn_attrs improvements) - #145452 (Do not strip binaries in bootstrap everytime if they are unchanged) - #145464 (Stabilize `const_pathbuf_osstring_new` feature) - #145474 (Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups) - #145486 (Fix `unicode_data.rs` mention message) - #145493 (remove `should_render` in `PrintAttribute` derive) - #145505 (Simplify span caches) - #145510 (Visit and print async_fut local for async drop.) - #145511 (Rust build fails on OpenBSD after using file_lock feature) - #145532 (resolve: debug for block module) - #145533 (Reorder `lto` options from most to least optimizing) - #145537 (Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.) - #145538 (bufreader::Buffer::backshift: don't move the uninit bytes) - #145542 (triagebot: Don't warn no-mentions on subtree updates) - #145549 (Update rust maintainers in openharmony.md) - #145550 (Avoid using `()` in `derive(From)` output.) - #145556 (Allow stability attributes on extern crates) - #145560 (Remove unused `PartialOrd`/`Ord` from bootstrap) - #145568 (ignore frontmatters in `TokenStream::new`) - #145571 (remove myself from some adhoc-groups and pings) - #145576 (Add change tracker entry for `--timings`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b96868f + 271430e commit 35f6640

File tree

194 files changed

+1099
-670
lines changed

Some content is hidden

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

194 files changed

+1099
-670
lines changed

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
5454
Allow(Target::Static),
5555
Allow(Target::ForeignFn),
5656
Allow(Target::ForeignStatic),
57+
Allow(Target::ExternCrate),
5758
]);
5859

5960
#[derive(Default)]

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
124124
// by using `ty_vid rel B` and then finally and end by equating `ty_vid` to
125125
// the opaque.
126126
let mut enable_subtyping = |ty, opaque_is_expected| {
127-
let ty_vid = infcx.next_ty_var_id_in_universe(self.span(), ty::UniverseIndex::ROOT);
128-
127+
// We create the fresh inference variable in the highest universe.
128+
// In theory we could limit it to the highest universe in the args of
129+
// the opaque but that isn't really worth the effort.
130+
//
131+
// We'll make sure that the opaque type can actually name everything
132+
// in its hidden type later on.
133+
let ty_vid = infcx.next_ty_vid(self.span());
129134
let variance = if opaque_is_expected {
130135
self.ambient_variance
131136
} else {

compiler/rustc_builtin_macros/src/deriving/from.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,39 @@ pub(crate) fn expand_deriving_from(
2727
cx.dcx().bug("derive(From) used on something else than an item");
2828
};
2929

30-
// #[derive(From)] is currently usable only on structs with exactly one field.
31-
let field = if let ItemKind::Struct(_, _, data) = &item.kind
32-
&& let [field] = data.fields()
33-
{
34-
Some(field.clone())
35-
} else {
36-
None
30+
let err_span = || {
31+
let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span);
32+
MultiSpan::from_spans(vec![span, item_span])
3733
};
3834

39-
let from_type = match &field {
40-
Some(field) => Ty::AstTy(field.ty.clone()),
41-
// We don't have a type to put into From<...> if we don't have a single field, so just put
42-
// unit there.
43-
None => Ty::Unit,
35+
// `#[derive(From)]` is currently usable only on structs with exactly one field.
36+
let field = match &item.kind {
37+
ItemKind::Struct(_, _, data) => {
38+
if let [field] = data.fields() {
39+
Ok(field.clone())
40+
} else {
41+
let guar = cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
42+
span: err_span(),
43+
multiple_fields: data.fields().len() > 1,
44+
});
45+
Err(guar)
46+
}
47+
}
48+
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
49+
let guar = cx.dcx().emit_err(errors::DeriveFromWrongTarget {
50+
span: err_span(),
51+
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
52+
});
53+
Err(guar)
54+
}
55+
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
4456
};
57+
58+
let from_type = Ty::AstTy(match field {
59+
Ok(ref field) => field.ty.clone(),
60+
Err(guar) => cx.ty(span, ast::TyKind::Err(guar)),
61+
});
62+
4563
let path =
4664
Path::new_(pathvec_std!(convert::From), vec![Box::new(from_type.clone())], PathKind::Std);
4765

@@ -71,34 +89,17 @@ pub(crate) fn expand_deriving_from(
7189
attributes: thin_vec![cx.attr_word(sym::inline, span)],
7290
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
7391
combine_substructure: combine_substructure(Box::new(|cx, span, substructure| {
74-
let Some(field) = &field else {
75-
let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span);
76-
let err_span = MultiSpan::from_spans(vec![span, item_span]);
77-
let error = match &item.kind {
78-
ItemKind::Struct(_, _, data) => {
79-
cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
80-
span: err_span,
81-
multiple_fields: data.fields().len() > 1,
82-
})
83-
}
84-
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
85-
cx.dcx().emit_err(errors::DeriveFromWrongTarget {
86-
span: err_span,
87-
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
88-
})
89-
}
90-
_ => cx.dcx().bug("Invalid derive(From) ADT input"),
91-
};
92-
93-
return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(error)));
92+
let field = match field {
93+
Ok(ref field) => field,
94+
Err(guar) => {
95+
return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(guar)));
96+
}
9497
};
9598

9699
let self_kw = Ident::new(kw::SelfUpper, span);
97100
let expr: Box<ast::Expr> = match substructure.fields {
98101
SubstructureFields::StaticStruct(variant, _) => match variant {
99-
// Self {
100-
// field: value
101-
// }
102+
// Self { field: value }
102103
VariantData::Struct { .. } => cx.expr_struct_ident(
103104
span,
104105
self_kw,

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
99
#![doc(rust_logo)]
1010
#![feature(assert_matches)]
11-
#![feature(autodiff)]
1211
#![feature(box_patterns)]
1312
#![feature(decl_macro)]
1413
#![feature(if_let_guard)]

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
497497
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-module", module));
498498

499499
let name =
500-
codegen_fn_attrs.link_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id()));
500+
codegen_fn_attrs.symbol_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id()));
501501
let name = name.as_str();
502502
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name));
503503
}

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,15 @@ pub(crate) unsafe fn create_module<'ll>(
471471
}
472472
}
473473

474+
if sess.opts.unstable_opts.indirect_branch_cs_prefix {
475+
llvm::add_module_flag_u32(
476+
llmod,
477+
llvm::ModuleFlagMergeBehavior::Override,
478+
"indirect_branch_cs_prefix",
479+
1,
480+
);
481+
}
482+
474483
match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
475484
{
476485
// Set up the small-data optimization limit for architectures that use

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ pub fn is_call_from_compiler_builtins_to_upstream_monomorphization<'tcx>(
858858
instance: Instance<'tcx>,
859859
) -> bool {
860860
fn is_llvm_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
861-
if let Some(name) = tcx.codegen_fn_attrs(def_id).link_name {
861+
if let Some(name) = tcx.codegen_fn_attrs(def_id).symbol_name {
862862
name.as_str().starts_with("llvm.")
863863
} else {
864864
false

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr};
66
use rustc_hir::attrs::{AttributeKind, InlineAttr, InstructionSetAttr, UsedBy};
77
use rustc_hir::def::DefKind;
88
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
9-
use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
109
use rustc_hir::{self as hir, Attribute, LangItem, find_attr, lang_items};
1110
use rustc_middle::middle::codegen_fn_attrs::{
1211
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry,
@@ -182,15 +181,21 @@ fn process_builtin_attrs(
182181
match p {
183182
AttributeKind::Cold(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD,
184183
AttributeKind::ExportName { name, .. } => {
185-
codegen_fn_attrs.export_name = Some(*name)
184+
codegen_fn_attrs.symbol_name = Some(*name)
186185
}
187186
AttributeKind::Inline(inline, span) => {
188187
codegen_fn_attrs.inline = *inline;
189188
interesting_spans.inline = Some(*span);
190189
}
191190
AttributeKind::Naked(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
192191
AttributeKind::Align { align, .. } => codegen_fn_attrs.alignment = Some(*align),
193-
AttributeKind::LinkName { name, .. } => codegen_fn_attrs.link_name = Some(*name),
192+
AttributeKind::LinkName { name, .. } => {
193+
// FIXME Remove check for foreign functions once #[link_name] on non-foreign
194+
// functions is a hard error
195+
if tcx.is_foreign_item(did) {
196+
codegen_fn_attrs.symbol_name = Some(*name);
197+
}
198+
}
194199
AttributeKind::LinkOrdinal { ordinal, span } => {
195200
codegen_fn_attrs.link_ordinal = Some(*ordinal);
196201
interesting_spans.link_ordinal = Some(*span);
@@ -410,7 +415,7 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code
410415
// * `#[rustc_std_internal_symbol]` mangles the symbol name in a special way
411416
// both for exports and imports through foreign items. This is handled further,
412417
// during symbol mangling logic.
413-
} else if codegen_fn_attrs.link_name.is_some() {
418+
} else if codegen_fn_attrs.symbol_name.is_some() {
414419
// * This can be overridden with the `#[link_name]` attribute
415420
} else {
416421
// NOTE: there's one more exception that we cannot apply here. On wasm,
@@ -465,7 +470,7 @@ fn check_result(
465470
}
466471

467472
// error when specifying link_name together with link_ordinal
468-
if let Some(_) = codegen_fn_attrs.link_name
473+
if let Some(_) = codegen_fn_attrs.symbol_name
469474
&& let Some(_) = codegen_fn_attrs.link_ordinal
470475
{
471476
let msg = "cannot use `#[link_name]` with `#[link_ordinal]`";
@@ -512,14 +517,11 @@ fn handle_lang_items(
512517
// strippable by the linker.
513518
//
514519
// Additionally weak lang items have predetermined symbol names.
515-
if let Some(lang_item) = lang_item {
516-
if WEAK_LANG_ITEMS.contains(&lang_item) {
517-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
518-
}
519-
if let Some(link_name) = lang_item.link_name() {
520-
codegen_fn_attrs.export_name = Some(link_name);
521-
codegen_fn_attrs.link_name = Some(link_name);
522-
}
520+
if let Some(lang_item) = lang_item
521+
&& let Some(link_name) = lang_item.link_name()
522+
{
523+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
524+
codegen_fn_attrs.symbol_name = Some(link_name);
523525
}
524526

525527
// error when using no_mangle on a lang item item

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ fn parse_rust_feature_flag<'a>(
180180
while let Some(new_feature) = new_features.pop() {
181181
if features.insert(new_feature) {
182182
if let Some(implied_features) = inverse_implied_features.get(&new_feature) {
183+
#[allow(rustc::potential_query_instability)]
183184
new_features.extend(implied_features)
184185
}
185186
}

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
325325
let _trace = enter_trace_span!(
326326
M,
327327
"instantiate_from_frame_and_normalize_erasing_regions",
328-
"{}",
329-
frame.instance
328+
%frame.instance
330329
);
331330
frame
332331
.instance
@@ -583,6 +582,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
583582
span: Span,
584583
layout: Option<TyAndLayout<'tcx>>,
585584
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
585+
let _trace = enter_trace_span!(M, const_eval::eval_mir_constant, ?val);
586586
let const_val = val.eval(*self.tcx, self.typing_env, span).map_err(|err| {
587587
if M::ALL_CONSTS_ARE_PRECHECKED {
588588
match err {

0 commit comments

Comments
 (0)