Skip to content

Commit 38081f2

Browse files
committed
Auto merge of rust-lang#141716 - jhpratt:rollup-9bjrzfi, r=jhpratt
Rollup of 16 pull requests Successful merges: - rust-lang#136429 (GCI: At their def site, actually wfcheck the where-clause & always eval free lifetime-generic constants) - rust-lang#138139 (Emit warning while outputs is not exe and prints linkage info) - rust-lang#141104 (Test(fs): Fix `test_eq_windows_file_type` for Windows 7) - rust-lang#141477 (Path::with_extension: show that it adds an extension where one did no…) - rust-lang#141533 (clean up old rintf leftovers) - rust-lang#141612 (Call out possibility of invariant result in variance markers) - rust-lang#141638 (Use `builtin_index` instead of hand-rolling it) - rust-lang#141643 (ci: verify that codebuild jobs use ghcr.io) - rust-lang#141675 (Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.) - rust-lang#141680 (replace TraitRef link memory.md) - rust-lang#141682 (interpret/allocation: Fixup type for `alloc_bytes`) - rust-lang#141683 (Handle ed2021 precise capturing of unsafe binder) - rust-lang#141684 (rustbook: Bump versions of `onig` and `onig_sys`) - rust-lang#141687 (core: unstably expose atomic_compare_exchange so stdarch can use it) - rust-lang#141690 (Add `rustc_diagnostic_item` to `sys::Mutex` methods) - rust-lang#141702 (Add eholk to compiler reviewer rotation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5f025f3 + 4327a7c commit 38081f2

File tree

56 files changed

+322
-145
lines changed

Some content is hidden

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

56 files changed

+322
-145
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,9 +3417,9 @@ impl Item {
34173417
ItemKind::Fn(i) => Some(&i.generics),
34183418
ItemKind::TyAlias(i) => Some(&i.generics),
34193419
ItemKind::TraitAlias(_, generics, _)
3420-
| ItemKind::Enum(_, _, generics)
3421-
| ItemKind::Struct(_, _, generics)
3422-
| ItemKind::Union(_, _, generics) => Some(&generics),
3420+
| ItemKind::Enum(_, generics, _)
3421+
| ItemKind::Struct(_, generics, _)
3422+
| ItemKind::Union(_, generics, _) => Some(&generics),
34233423
ItemKind::Trait(i) => Some(&i.generics),
34243424
ItemKind::Impl(i) => Some(&i.generics),
34253425
}
@@ -3663,15 +3663,15 @@ pub enum ItemKind {
36633663
/// An enum definition (`enum`).
36643664
///
36653665
/// E.g., `enum Foo<A, B> { C<A>, D<B> }`.
3666-
Enum(Ident, EnumDef, Generics),
3666+
Enum(Ident, Generics, EnumDef),
36673667
/// A struct definition (`struct`).
36683668
///
36693669
/// E.g., `struct Foo<A> { x: A }`.
3670-
Struct(Ident, VariantData, Generics),
3670+
Struct(Ident, Generics, VariantData),
36713671
/// A union definition (`union`).
36723672
///
36733673
/// E.g., `union Foo<A, B> { x: A, y: B }`.
3674-
Union(Ident, VariantData, Generics),
3674+
Union(Ident, Generics, VariantData),
36753675
/// A trait declaration (`trait`).
36763676
///
36773677
/// E.g., `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`.
@@ -3688,10 +3688,8 @@ pub enum ItemKind {
36883688
///
36893689
/// E.g., `foo!(..)`.
36903690
MacCall(P<MacCall>),
3691-
36923691
/// A macro definition.
36933692
MacroDef(Ident, MacroDef),
3694-
36953693
/// A single delegation item (`reuse`).
36963694
///
36973695
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
@@ -3767,9 +3765,9 @@ impl ItemKind {
37673765
Self::Fn(box Fn { generics, .. })
37683766
| Self::TyAlias(box TyAlias { generics, .. })
37693767
| Self::Const(box ConstItem { generics, .. })
3770-
| Self::Enum(_, _, generics)
3771-
| Self::Struct(_, _, generics)
3772-
| Self::Union(_, _, generics)
3768+
| Self::Enum(_, generics, _)
3769+
| Self::Struct(_, generics, _)
3770+
| Self::Union(_, generics, _)
37733771
| Self::Trait(box Trait { generics, .. })
37743772
| Self::TraitAlias(_, generics, _)
37753773
| Self::Impl(box Impl { generics, .. }) => Some(generics),

compiler/rustc_ast/src/visit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,16 @@ macro_rules! common_visitor_and_walkers {
508508
)?
509509
$(<V as Visitor<$lt>>::Result::output())?
510510
}
511-
ItemKind::Enum(ident, enum_definition, generics) => {
511+
ItemKind::Enum(ident, generics, enum_definition) => {
512512
try_visit!(vis.visit_ident(ident));
513513
try_visit!(vis.visit_generics(generics));
514514
$(${ignore($mut)}
515515
enum_definition.variants.flat_map_in_place(|variant| vis.flat_map_variant(variant));
516516
)?
517517
$(${ignore($lt)}vis.visit_enum_def(enum_definition))?
518518
}
519-
ItemKind::Struct(ident, variant_data, generics)
520-
| ItemKind::Union(ident, variant_data, generics) => {
519+
ItemKind::Struct(ident, generics, variant_data)
520+
| ItemKind::Union(ident, generics, variant_data) => {
521521
try_visit!(vis.visit_ident(ident));
522522
try_visit!(vis.visit_generics(generics));
523523
vis.visit_variant_data(variant_data)

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
306306
);
307307
hir::ItemKind::TyAlias(ident, ty, generics)
308308
}
309-
ItemKind::Enum(ident, enum_definition, generics) => {
309+
ItemKind::Enum(ident, generics, enum_definition) => {
310310
let ident = self.lower_ident(*ident);
311311
let (generics, variants) = self.lower_generics(
312312
generics,
@@ -320,7 +320,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
320320
);
321321
hir::ItemKind::Enum(ident, hir::EnumDef { variants }, generics)
322322
}
323-
ItemKind::Struct(ident, struct_def, generics) => {
323+
ItemKind::Struct(ident, generics, struct_def) => {
324324
let ident = self.lower_ident(*ident);
325325
let (generics, struct_def) = self.lower_generics(
326326
generics,
@@ -330,7 +330,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
330330
);
331331
hir::ItemKind::Struct(ident, struct_def, generics)
332332
}
333-
ItemKind::Union(ident, vdata, generics) => {
333+
ItemKind::Union(ident, generics, vdata) => {
334334
let ident = self.lower_ident(*ident);
335335
let (generics, vdata) = self.lower_generics(
336336
generics,

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10101010
});
10111011
self.extern_mod_span = old_item;
10121012
}
1013-
ItemKind::Enum(_, def, _) => {
1013+
ItemKind::Enum(_, _, def) => {
10141014
for variant in &def.variants {
10151015
self.visibility_not_permitted(
10161016
&variant.vis,
@@ -1061,7 +1061,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10611061
}
10621062
visit::walk_item(self, item)
10631063
}
1064-
ItemKind::Struct(ident, vdata, generics) => match vdata {
1064+
ItemKind::Struct(ident, generics, vdata) => match vdata {
10651065
VariantData::Struct { fields, .. } => {
10661066
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
10671067
self.visit_generics(generics);
@@ -1070,7 +1070,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10701070
}
10711071
_ => visit::walk_item(self, item),
10721072
},
1073-
ItemKind::Union(ident, vdata, generics) => {
1073+
ItemKind::Union(ident, generics, vdata) => {
10741074
if vdata.fields().is_empty() {
10751075
self.dcx().emit_err(errors::FieldlessUnion { span: item.span });
10761076
}

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ impl<'a> State<'a> {
298298
*defaultness,
299299
);
300300
}
301-
ast::ItemKind::Enum(ident, enum_definition, params) => {
302-
self.print_enum_def(enum_definition, params, *ident, item.span, &item.vis);
301+
ast::ItemKind::Enum(ident, generics, enum_definition) => {
302+
self.print_enum_def(enum_definition, generics, *ident, item.span, &item.vis);
303303
}
304-
ast::ItemKind::Struct(ident, struct_def, generics) => {
304+
ast::ItemKind::Struct(ident, generics, struct_def) => {
305305
let (cb, ib) = self.head(visibility_qualified(&item.vis, "struct"));
306306
self.print_struct(struct_def, generics, *ident, item.span, true, cb, ib);
307307
}
308-
ast::ItemKind::Union(ident, struct_def, generics) => {
308+
ast::ItemKind::Union(ident, generics, struct_def) => {
309309
let (cb, ib) = self.head(visibility_qualified(&item.vis, "union"));
310310
self.print_struct(struct_def, generics, *ident, item.span, true, cb, ib);
311311
}

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub(crate) fn expand_deriving_clone(
3434
let is_simple;
3535
match item {
3636
Annotatable::Item(annitem) => match &annitem.kind {
37-
ItemKind::Struct(_, _, Generics { params, .. })
38-
| ItemKind::Enum(_, _, Generics { params, .. }) => {
37+
ItemKind::Struct(_, Generics { params, .. }, _)
38+
| ItemKind::Enum(_, Generics { params, .. }, _) => {
3939
let container_id = cx.current_expansion.id.expn_data().parent.expect_local();
4040
let has_derive_copy = cx.resolver.has_derive_copy(container_id);
4141
if has_derive_copy

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) fn expand_deriving_partial_ord(
2121

2222
// Order in which to perform matching
2323
let discr_then_data = if let Annotatable::Item(item) = item
24-
&& let ItemKind::Enum(_, def, _) = &item.kind
24+
&& let ItemKind::Enum(_, _, def) = &item.kind
2525
{
2626
let dataful: Vec<bool> = def.variants.iter().map(|v| !v.data.fields().is_empty()).collect();
2727
match dataful.iter().filter(|&&b| b).count() {

compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
3030
item.visit_with(&mut DetectNonGenericPointeeAttr { cx });
3131

3232
let (name_ident, generics) = if let Annotatable::Item(aitem) = item
33-
&& let ItemKind::Struct(ident, struct_data, g) = &aitem.kind
33+
&& let ItemKind::Struct(ident, g, struct_data) = &aitem.kind
3434
{
3535
if !matches!(
3636
struct_data,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,23 +488,23 @@ impl<'a> TraitDef<'a> {
488488
);
489489

490490
let newitem = match &item.kind {
491-
ast::ItemKind::Struct(ident, struct_def, generics) => self.expand_struct_def(
491+
ast::ItemKind::Struct(ident, generics, struct_def) => self.expand_struct_def(
492492
cx,
493493
struct_def,
494494
*ident,
495495
generics,
496496
from_scratch,
497497
is_packed,
498498
),
499-
ast::ItemKind::Enum(ident, enum_def, generics) => {
499+
ast::ItemKind::Enum(ident, generics, enum_def) => {
500500
// We ignore `is_packed` here, because `repr(packed)`
501501
// enums cause an error later on.
502502
//
503503
// This can only cause further compilation errors
504504
// downstream in blatantly illegal code, so it is fine.
505505
self.expand_enum_def(cx, enum_def, *ident, generics, from_scratch)
506506
}
507-
ast::ItemKind::Union(ident, struct_def, generics) => {
507+
ast::ItemKind::Union(ident, generics, struct_def) => {
508508
if self.supports_unions {
509509
self.expand_struct_def(
510510
cx,

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
6868
}
6969
}
7070

71+
fn check_link_info_print_request(sess: &Session, crate_types: &[CrateType]) {
72+
let print_native_static_libs =
73+
sess.opts.prints.iter().any(|p| p.kind == PrintKind::NativeStaticLibs);
74+
let has_staticlib = crate_types.iter().any(|ct| *ct == CrateType::Staticlib);
75+
if print_native_static_libs {
76+
if !has_staticlib {
77+
sess.dcx()
78+
.warn(format!("cannot output linkage information without staticlib crate-type"));
79+
sess.dcx()
80+
.note(format!("consider `--crate-type staticlib` to print linkage information"));
81+
} else if !sess.opts.output_types.should_link() {
82+
sess.dcx()
83+
.warn(format!("cannot output linkage information when --emit link is not passed"));
84+
}
85+
}
86+
}
87+
7188
/// Performs the linkage portion of the compilation phase. This will generate all
7289
/// of the requested outputs for this compilation session.
7390
pub fn link_binary(
@@ -180,6 +197,8 @@ pub fn link_binary(
180197
}
181198
}
182199

200+
check_link_info_print_request(sess, &codegen_results.crate_info.crate_types);
201+
183202
// Remove the temporary object file and metadata if we aren't saving temps.
184203
sess.time("link_binary_remove_temps", || {
185204
// If the user requests that temporaries are saved, don't delete any.

0 commit comments

Comments
 (0)