Skip to content

Commit 43a2e9d

Browse files
committed
Auto merge of rust-lang#138611 - matthiaskrgr:rollup-hmjbqva, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#133870 (Stabilize `asm_goto` feature gate) - rust-lang#137449 (Denote `ControlFlow` as `#[must_use]`) - rust-lang#137465 (mir_build: Avoid some useless work when visiting "primary" bindings) - rust-lang#138349 (Emit function declarations for functions with `#[linkage="extern_weak"]`) - rust-lang#138412 (Install licenses into `share/doc/rust/licenses`) - rust-lang#138577 (rustdoc-json: Don't also include `#[deprecated]` in `Item::attrs`) - rust-lang#138588 (Avoid double lowering of idents) Failed merges: - rust-lang#138321 ([bootstrap] Distribute split debuginfo if present) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8279176 + 1e58d51 commit 43a2e9d

File tree

60 files changed

+911
-335
lines changed

Some content is hidden

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

60 files changed

+911
-335
lines changed

compiler/rustc_ast_lowering/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ ast_lowering_underscore_expr_lhs_assign =
185185
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
186186
ast_lowering_unstable_inline_assembly_label_operand_with_outputs =
187187
using both label and output operands for inline assembly is unstable
188-
ast_lowering_unstable_inline_assembly_label_operands =
189-
label operands for inline assembly are unstable
190188
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
191189
192190
ast_lowering_use_angle_brackets = use angle brackets instead

compiler/rustc_ast_lowering/src/asm.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -470,22 +470,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
470470
}
471471
}
472472

473-
// Feature gate checking for asm goto.
473+
// Feature gate checking for `asm_goto_with_outputs`.
474474
if let Some((_, op_sp)) =
475475
operands.iter().find(|(op, _)| matches!(op, hir::InlineAsmOperand::Label { .. }))
476476
{
477-
if !self.tcx.features().asm_goto() {
478-
feature_err(
479-
sess,
480-
sym::asm_goto,
481-
*op_sp,
482-
fluent::ast_lowering_unstable_inline_assembly_label_operands,
483-
)
484-
.emit();
485-
}
486-
487-
// In addition, check if an output operand is used.
488-
// This is gated behind an additional feature.
477+
// Check if an output operand is used.
489478
let output_operand_used = operands.iter().any(|(op, _)| {
490479
matches!(
491480
op,

compiler/rustc_ast_lowering/src/item.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
17201720

17211721
let bounds = self.lower_param_bounds(bounds, itctx);
17221722

1723-
let ident = self.lower_ident(ident);
17241723
let param_span = ident.span;
17251724

17261725
// Reconstruct the span of the entire predicate from the individual generic bounds.
@@ -1739,6 +1738,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17391738
let def_id = self.local_def_id(id).to_def_id();
17401739
let hir_id = self.next_id();
17411740
let res = Res::Def(DefKind::TyParam, def_id);
1741+
let ident = self.lower_ident(ident);
17421742
let ty_path = self.arena.alloc(hir::Path {
17431743
span: param_span,
17441744
res,
@@ -1757,7 +1757,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
17571757
})
17581758
}
17591759
GenericParamKind::Lifetime => {
1760-
let ident = self.lower_ident(ident);
17611760
let lt_id = self.next_node_id();
17621761
let lifetime = self.new_named_lifetime(id, lt_id, ident);
17631762
hir::WherePredicateKind::RegionPredicate(hir::WhereRegionPredicate {

compiler/rustc_ast_lowering/src/lib.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -1769,17 +1769,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17691769
}
17701770

17711771
fn lower_lifetime(&mut self, l: &Lifetime) -> &'hir hir::Lifetime {
1772-
let ident = self.lower_ident(l.ident);
1773-
self.new_named_lifetime(l.id, l.id, ident)
1772+
self.new_named_lifetime(l.id, l.id, l.ident)
17741773
}
17751774

17761775
#[instrument(level = "debug", skip(self))]
1777-
fn new_named_lifetime_with_res(
1776+
fn new_named_lifetime(
17781777
&mut self,
17791778
id: NodeId,
1779+
new_id: NodeId,
17801780
ident: Ident,
1781-
res: LifetimeRes,
17821781
) -> &'hir hir::Lifetime {
1782+
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
17831783
let res = match res {
17841784
LifetimeRes::Param { param, .. } => hir::LifetimeName::Param(param),
17851785
LifetimeRes::Fresh { param, .. } => {
@@ -1789,31 +1789,19 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17891789
LifetimeRes::Infer => hir::LifetimeName::Infer,
17901790
LifetimeRes::Static { .. } => hir::LifetimeName::Static,
17911791
LifetimeRes::Error => hir::LifetimeName::Error,
1792-
res => panic!(
1793-
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
1794-
res, ident, ident.span
1795-
),
1792+
LifetimeRes::ElidedAnchor { .. } => {
1793+
panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
1794+
}
17961795
};
17971796

17981797
debug!(?res);
17991798
self.arena.alloc(hir::Lifetime {
1800-
hir_id: self.lower_node_id(id),
1799+
hir_id: self.lower_node_id(new_id),
18011800
ident: self.lower_ident(ident),
18021801
res,
18031802
})
18041803
}
18051804

1806-
#[instrument(level = "debug", skip(self))]
1807-
fn new_named_lifetime(
1808-
&mut self,
1809-
id: NodeId,
1810-
new_id: NodeId,
1811-
ident: Ident,
1812-
) -> &'hir hir::Lifetime {
1813-
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
1814-
self.new_named_lifetime_with_res(new_id, ident, res)
1815-
}
1816-
18171805
fn lower_generic_params_mut(
18181806
&mut self,
18191807
params: &[GenericParam],

compiler/rustc_codegen_llvm/src/consts.rs

+24-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ use rustc_abi::{
55
};
66
use rustc_codegen_ssa::common;
77
use rustc_codegen_ssa::traits::*;
8+
use rustc_hir::LangItem;
89
use rustc_hir::def::DefKind;
910
use rustc_hir::def_id::DefId;
1011
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1112
use rustc_middle::mir::interpret::{
1213
Allocation, ConstAllocation, ErrorHandled, InitChunk, Pointer, Scalar as InterpScalar,
1314
read_target_uint,
1415
};
15-
use rustc_middle::mir::mono::MonoItem;
16-
use rustc_middle::ty::Instance;
16+
use rustc_middle::mir::mono::{Linkage, MonoItem};
1717
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
18+
use rustc_middle::ty::{self, Instance};
1819
use rustc_middle::{bug, span_bug};
1920
use tracing::{debug, instrument, trace};
2021

@@ -171,8 +172,27 @@ fn check_and_apply_linkage<'ll, 'tcx>(
171172
if let Some(linkage) = attrs.import_linkage {
172173
debug!("get_static: sym={} linkage={:?}", sym, linkage);
173174

174-
// Declare a symbol `foo` with the desired linkage.
175-
let g1 = cx.declare_global(sym, cx.type_i8());
175+
// Declare a symbol `foo`. If `foo` is an extern_weak symbol, we declare
176+
// an extern_weak function, otherwise a global with the desired linkage.
177+
let g1 = if matches!(attrs.import_linkage, Some(Linkage::ExternalWeak)) {
178+
// An `extern_weak` function is represented as an `Option<unsafe extern ...>`,
179+
// we extract the function signature and declare it as an extern_weak function
180+
// instead of an extern_weak i8.
181+
let instance = Instance::mono(cx.tcx, def_id);
182+
if let ty::Adt(struct_def, args) = instance.ty(cx.tcx, cx.typing_env()).kind()
183+
&& cx.tcx.is_lang_item(struct_def.did(), LangItem::Option)
184+
&& let ty::FnPtr(sig, header) = args.type_at(0).kind()
185+
{
186+
let fn_sig = sig.with(*header);
187+
188+
let fn_abi = cx.fn_abi_of_fn_ptr(fn_sig, ty::List::empty());
189+
cx.declare_fn(sym, &fn_abi, None)
190+
} else {
191+
cx.declare_global(sym, cx.type_i8())
192+
}
193+
} else {
194+
cx.declare_global(sym, cx.type_i8())
195+
};
176196
llvm::set_linkage(g1, base::linkage_to_llvm(linkage));
177197

178198
// Declare an internal global `extern_with_linkage_foo` which

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ fn add_library_search_dirs(
21362136
}
21372137

21382138
let fallback = Some(NativeLibSearchFallback { self_contained_components, apple_sdk_root });
2139-
walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
2139+
let _ = walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
21402140
if is_framework {
21412141
cmd.framework_path(dir);
21422142
} else {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ declare_features! (
6262
(accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)),
6363
/// Allows using `const` operands in inline assembly.
6464
(accepted, asm_const, "1.82.0", Some(93332)),
65+
/// Allows using `label` operands in inline assembly.
66+
(accepted, asm_goto, "CURRENT_RUSTC_VERSION", Some(119364)),
6567
/// Allows using `sym` operands in inline assembly.
6668
(accepted, asm_sym, "1.66.0", Some(93333)),
6769
/// Allows the definition of associated constants in `trait` or `impl` blocks.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ declare_features! (
372372
(unstable, asm_experimental_arch, "1.58.0", Some(93335)),
373373
/// Enables experimental register support in inline assembly.
374374
(unstable, asm_experimental_reg, "1.85.0", Some(133416)),
375-
/// Allows using `label` operands in inline assembly.
376-
(unstable, asm_goto, "1.78.0", Some(119364)),
377375
/// Allows using `label` operands in inline assembly together with output operands.
378376
(unstable, asm_goto_with_outputs, "1.85.0", Some(119364)),
379377
/// Allows the `may_unwind` option in inline assembly.

compiler/rustc_hir_typeck/src/method/suggest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
533533
}
534534
}
535535
_ => {
536-
intravisit::walk_pat(self, p);
536+
let _ = intravisit::walk_pat(self, p);
537537
}
538538
}
539539
ControlFlow::Continue(())
@@ -556,7 +556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
556556
method_name,
557557
sugg_let: None,
558558
};
559-
let_visitor.visit_body(&body);
559+
let _ = let_visitor.visit_body(&body);
560560
if let Some(sugg_let) = let_visitor.sugg_let
561561
&& let Some(self_ty) = self.node_ty_opt(sugg_let.init_hir_id)
562562
{

compiler/rustc_middle/src/mir/mod.rs

+3-82
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::mir::interpret::{AllocRange, Scalar};
3333
use crate::ty::codec::{TyDecoder, TyEncoder};
3434
use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths};
3535
use crate::ty::{
36-
self, AdtDef, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt,
37-
TypeVisitableExt, TypingEnv, UserTypeAnnotationIndex,
36+
self, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt, TypeVisitableExt,
37+
TypingEnv, UserTypeAnnotationIndex,
3838
};
3939

4040
mod basic_blocks;
@@ -1482,53 +1482,10 @@ pub struct UserTypeProjections {
14821482
pub contents: Vec<UserTypeProjection>,
14831483
}
14841484

1485-
impl<'tcx> UserTypeProjections {
1486-
pub fn none() -> Self {
1487-
UserTypeProjections { contents: vec![] }
1488-
}
1489-
1490-
pub fn is_empty(&self) -> bool {
1491-
self.contents.is_empty()
1492-
}
1493-
1485+
impl UserTypeProjections {
14941486
pub fn projections(&self) -> impl Iterator<Item = &UserTypeProjection> + ExactSizeIterator {
14951487
self.contents.iter()
14961488
}
1497-
1498-
pub fn push_user_type(mut self, base_user_type: UserTypeAnnotationIndex) -> Self {
1499-
self.contents.push(UserTypeProjection { base: base_user_type, projs: vec![] });
1500-
self
1501-
}
1502-
1503-
fn map_projections(mut self, f: impl FnMut(UserTypeProjection) -> UserTypeProjection) -> Self {
1504-
self.contents = self.contents.into_iter().map(f).collect();
1505-
self
1506-
}
1507-
1508-
pub fn index(self) -> Self {
1509-
self.map_projections(|pat_ty_proj| pat_ty_proj.index())
1510-
}
1511-
1512-
pub fn subslice(self, from: u64, to: u64) -> Self {
1513-
self.map_projections(|pat_ty_proj| pat_ty_proj.subslice(from, to))
1514-
}
1515-
1516-
pub fn deref(self) -> Self {
1517-
self.map_projections(|pat_ty_proj| pat_ty_proj.deref())
1518-
}
1519-
1520-
pub fn leaf(self, field: FieldIdx) -> Self {
1521-
self.map_projections(|pat_ty_proj| pat_ty_proj.leaf(field))
1522-
}
1523-
1524-
pub fn variant(
1525-
self,
1526-
adt_def: AdtDef<'tcx>,
1527-
variant_index: VariantIdx,
1528-
field_index: FieldIdx,
1529-
) -> Self {
1530-
self.map_projections(|pat_ty_proj| pat_ty_proj.variant(adt_def, variant_index, field_index))
1531-
}
15321489
}
15331490

15341491
/// Encodes the effect of a user-supplied type annotation on the
@@ -1553,42 +1510,6 @@ pub struct UserTypeProjection {
15531510
pub projs: Vec<ProjectionKind>,
15541511
}
15551512

1556-
impl UserTypeProjection {
1557-
pub(crate) fn index(mut self) -> Self {
1558-
self.projs.push(ProjectionElem::Index(()));
1559-
self
1560-
}
1561-
1562-
pub(crate) fn subslice(mut self, from: u64, to: u64) -> Self {
1563-
self.projs.push(ProjectionElem::Subslice { from, to, from_end: true });
1564-
self
1565-
}
1566-
1567-
pub(crate) fn deref(mut self) -> Self {
1568-
self.projs.push(ProjectionElem::Deref);
1569-
self
1570-
}
1571-
1572-
pub(crate) fn leaf(mut self, field: FieldIdx) -> Self {
1573-
self.projs.push(ProjectionElem::Field(field, ()));
1574-
self
1575-
}
1576-
1577-
pub(crate) fn variant(
1578-
mut self,
1579-
adt_def: AdtDef<'_>,
1580-
variant_index: VariantIdx,
1581-
field_index: FieldIdx,
1582-
) -> Self {
1583-
self.projs.push(ProjectionElem::Downcast(
1584-
Some(adt_def.variant(variant_index).name),
1585-
variant_index,
1586-
));
1587-
self.projs.push(ProjectionElem::Field(field_index, ()));
1588-
self
1589-
}
1590-
}
1591-
15921513
rustc_index::newtype_index! {
15931514
#[derive(HashStable)]
15941515
#[encodable]

compiler/rustc_middle/src/thir.rs

+4
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,12 @@ pub enum PatKind<'tcx> {
783783
var: LocalVarId,
784784
ty: Ty<'tcx>,
785785
subpattern: Option<Box<Pat<'tcx>>>,
786+
786787
/// Is this the leftmost occurrence of the binding, i.e., is `var` the
787788
/// `HirId` of this pattern?
789+
///
790+
/// (The same binding can occur multiple times in different branches of
791+
/// an or-pattern, but only one of them will be primary.)
788792
is_primary: bool,
789793
},
790794

compiler/rustc_mir_build/src/builder/block.rs

+19-27
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
199199
None,
200200
Some((Some(&destination), initializer_span)),
201201
);
202-
this.visit_primary_bindings(
203-
pattern,
204-
UserTypeProjections::none(),
205-
&mut |this, _, _, node, span, _, _| {
206-
this.storage_live_binding(
207-
block,
208-
node,
209-
span,
210-
OutsideGuard,
211-
ScheduleDrops::Yes,
212-
);
213-
},
214-
);
202+
this.visit_primary_bindings(pattern, &mut |this, node, span| {
203+
this.storage_live_binding(
204+
block,
205+
node,
206+
span,
207+
OutsideGuard,
208+
ScheduleDrops::Yes,
209+
);
210+
});
215211
let else_block_span = this.thir[*else_block].span;
216212
let (matching, failure) =
217213
this.in_if_then_scope(last_remainder_scope, else_block_span, |this| {
@@ -295,20 +291,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
295291
});
296292

297293
debug!("ast_block_stmts: pattern={:?}", pattern);
298-
this.visit_primary_bindings(
299-
pattern,
300-
UserTypeProjections::none(),
301-
&mut |this, _, _, node, span, _, _| {
302-
this.storage_live_binding(
303-
block,
304-
node,
305-
span,
306-
OutsideGuard,
307-
ScheduleDrops::Yes,
308-
);
309-
this.schedule_drop_for_binding(node, span, OutsideGuard);
310-
},
311-
)
294+
this.visit_primary_bindings(pattern, &mut |this, node, span| {
295+
this.storage_live_binding(
296+
block,
297+
node,
298+
span,
299+
OutsideGuard,
300+
ScheduleDrops::Yes,
301+
);
302+
this.schedule_drop_for_binding(node, span, OutsideGuard);
303+
})
312304
}
313305

314306
// Enter the visibility scope, after evaluating the initializer.

0 commit comments

Comments
 (0)