Skip to content

Commit 08d9006

Browse files
committed
Auto merge of #157726 - jhpratt:rollup-UIfbKIF, r=jhpratt
Rollup of 23 pull requests Successful merges: - #157280 (traits: Allow escaping self types in ExistentialTraitRef::with_self_ty) - #157282 (Fix post-monomorphization error note race in the parallel frontend) - #157352 (Make the retained dep graph deterministic under the parallel frontend) - #157601 (Emit error for unused target expression in glob and list delegations) - #157611 (Update `browser-ui-test` version to `0.24.0`) - #157620 (Add a strategy FnMut to inject behavior into the flush cycle) - #157645 (Windows TLS - Only register the `atexit` hook when `cleanup` can be unloaded) - #157647 (Start using comptime for reflection intrinsics and their wrapper functions) - #157719 (resolve: Partially revert "Remove a special case for dummy imports") - #156497 (fix-155516: Don't suggest wrong unwrap expect) - #156583 (Support defaults for static EIIs) - #157013 (Ensure inferred let pattern types are well-formed) - #157230 (borrowck: avoid ICE describing fields on generic params) - #157288 (platform support: add SNaN erratum to MIPS targets) - #157350 (compiletest: ignore SVG `y` offset in by-lines comparison) - #157355 (Add `or_try_*` variants for `HashMap` and `BTreeMap` Entry APIs) - #157384 (Add `#[rustc_dump_generics]` attribute) - #157577 (Fix parser error recovery treating 'dyn' as a strict keyword in Rust 2015 when used in `dyn + dyn`) - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N)) - #157691 (Move symbol hiding code to a new file) - #157697 (Add more tests that exercise the well-formedness checking of lazy type aliases) - #157700 (Rename `errors.rs` file to `diagnostics.rs` (5/N)) - #157703 (Fix doc link to Instant sub in saturating caveat) Failed merges: - #157699 (Arg splat experiment - hir FnDecl impl)
2 parents 485ec3f + 8367944 commit 08d9006

197 files changed

Lines changed: 3741 additions & 1563 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.

compiler/rustc_ast/src/ast.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ use rustc_data_structures::tagged_ptr::Tag;
3131
use rustc_macros::{Decodable, Encodable, StableHash, Walkable};
3232
pub use rustc_span::AttrId;
3333
use rustc_span::{
34-
ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym,
34+
ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, LocalExpnId, Span, Spanned, Symbol, kw, respan,
35+
sym,
3536
};
3637
use thin_vec::{ThinVec, thin_vec};
3738

@@ -3906,10 +3907,10 @@ pub struct EiiImpl {
39063907
pub is_default: bool,
39073908
}
39083909

3909-
#[derive(Clone, Encodable, Decodable, Debug, Walkable, PartialEq, Eq)]
3910+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq)]
39103911
pub enum DelegationSource {
39113912
Single,
3912-
List,
3913+
List(LocalExpnId),
39133914
Glob,
39143915
}
39153916

@@ -3923,6 +3924,7 @@ pub struct Delegation {
39233924
pub rename: Option<Ident>,
39243925
pub body: Option<Box<Block>>,
39253926
/// The item was expanded from a glob delegation item.
3927+
#[visitable(ignore)]
39263928
pub source: DelegationSource,
39273929
}
39283930

compiler/rustc_ast/src/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ macro_rules! common_visitor_and_walkers {
431431
Delegation,
432432
DelegationMac,
433433
DelegationSuffixes,
434-
DelegationSource,
435434
DelimArgs,
436435
DelimSpan,
437436
EnumDef,

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use crate::diagnostics::{
6262
};
6363
use crate::{
6464
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
65-
ResolverAstLoweringExt, index_crate,
65+
index_crate,
6666
};
6767

6868
mod generics;
@@ -126,7 +126,7 @@ pub(crate) fn delegations_resolutions(
126126
let delegation = ast_index[def_id].delegation().expect("processing delegations");
127127
let span = delegation.last_segment_span();
128128

129-
if let Some(info) = resolver.delegation_info(def_id) {
129+
if let Some(info) = tcx.resolutions(()).delegation_infos.get(&def_id) {
130130
let res = info.resolution_id.map(|id| check_for_cycles(tcx, id, span).map(|_| id));
131131
result.insert(def_id, res.flatten());
132132
} else {
@@ -143,16 +143,14 @@ pub(crate) fn delegations_resolutions(
143143
fn check_for_cycles(tcx: TyCtxt<'_>, mut def_id: DefId, span: Span) -> Result<(), ErrorGuaranteed> {
144144
let mut visited: FxHashSet<DefId> = Default::default();
145145

146-
let (resolver, _) = &*tcx.hir_crate(()).delayed_resolver.borrow();
147-
148146
loop {
149147
visited.insert(def_id);
150148

151149
// If def_id is in local crate and it corresponds to another delegation
152150
// it means that we refer to another delegation as a callee, so in order to obtain
153151
// a signature DefId we obtain NodeId of the callee delegation and try to get signature from it.
154152
if let Some(local_id) = def_id.as_local()
155-
&& let Some(info) = resolver.delegation_info(local_id)
153+
&& let Some(info) = tcx.resolutions(()).delegation_infos.get(&local_id)
156154
&& let Ok(id) = info.resolution_id
157155
{
158156
def_id = id;
@@ -209,17 +207,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
209207

210208
let mut generics = self.uplift_delegation_generics(delegation, sig_id, is_method);
211209

212-
let (body_id, call_expr_id) =
210+
let (body_id, call_expr_id, unused_target_expr) =
213211
self.lower_delegation_body(delegation, sig_id, param_count, &mut generics, span);
214212

215213
let decl = self.lower_delegation_decl(
214+
delegation.source,
216215
sig_id,
217216
param_count,
218217
c_variadic,
219218
span,
220219
&generics,
221220
delegation.id,
222221
call_expr_id,
222+
unused_target_expr,
223223
);
224224

225225
let sig = self.lower_delegation_sig(sig_id, decl, span);
@@ -375,13 +375,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
375375

376376
fn lower_delegation_decl(
377377
&mut self,
378+
source: DelegationSource,
378379
sig_id: DefId,
379380
param_count: usize,
380381
c_variadic: bool,
381382
span: Span,
382383
generics: &GenericsGenerationResults<'hir>,
383384
call_path_node_id: NodeId,
384385
call_expr_id: HirId,
386+
unused_target_expr: bool,
385387
) -> &'hir hir::FnDecl<'hir> {
386388
// The last parameter in C variadic functions is skipped in the signature,
387389
// like during regular lowering.
@@ -406,6 +408,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
406408
parent_args_segment_id: generics.parent.args_segment_id,
407409
self_ty_id: generics.self_ty_id,
408410
propagate_self_ty: generics.propagate_self_ty,
411+
group_id: {
412+
let id = match source {
413+
DelegationSource::Single => None,
414+
DelegationSource::List(expn_id) => Some(expn_id),
415+
DelegationSource::Glob => {
416+
Some(self.tcx.expn_that_defined(self.owner.def_id).expect_local())
417+
}
418+
};
419+
420+
id.map(|id| (id, unused_target_expr))
421+
},
409422
})),
410423
)),
411424
span,
@@ -504,16 +517,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
504517
param_count: usize,
505518
generics: &mut GenericsGenerationResults<'hir>,
506519
span: Span,
507-
) -> (BodyId, HirId) {
520+
) -> (BodyId, HirId, bool) {
508521
let block = delegation.body.as_deref();
509522
let mut call_expr_id = HirId::INVALID;
523+
let mut unused_target_expr = false;
510524

511525
let block_id = self.lower_body(|this| {
512526
let mut parameters: Vec<hir::Param<'_>> = Vec::with_capacity(param_count);
513527
let mut args: Vec<hir::Expr<'_>> = Vec::with_capacity(param_count);
514528
let mut stmts: &[hir::Stmt<'hir>] = &[];
515529

516530
let is_method = this.is_method(sig_id, span);
531+
let should_generate_block = this.should_generate_block(delegation, sig_id, is_method);
532+
533+
// Consider non-specified target expression as generated,
534+
// as we do not want to emit error when target expression is
535+
// not specified.
536+
unused_target_expr = block.is_some() && (param_count == 0 || !should_generate_block);
517537

518538
for idx in 0..param_count {
519539
let (param, pat_node_id) = this.generate_param(is_method, idx, span);
@@ -524,7 +544,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
524544

525545
let arg = if let Some(block) = block
526546
&& idx == 0
527-
&& this.should_generate_block(delegation, sig_id, is_method)
547+
&& should_generate_block
528548
{
529549
let mut self_resolver = SelfResolver {
530550
ctxt: this,
@@ -565,7 +585,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
565585

566586
debug_assert_ne!(call_expr_id, HirId::INVALID);
567587

568-
(block_id, call_expr_id)
588+
(block_id, call_expr_id, unused_target_expr)
569589
}
570590

571591
fn finalize_body_lowering(

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use rustc_macros::extension;
6363
use rustc_middle::hir::{self as mid_hir};
6464
use rustc_middle::queries::Providers;
6565
use rustc_middle::span_bug;
66-
use rustc_middle::ty::{DelegationInfo, PerOwnerResolverData, ResolverAstLowering, TyCtxt};
66+
use rustc_middle::ty::{PerOwnerResolverData, ResolverAstLowering, TyCtxt};
6767
use rustc_session::errors::add_feature_diagnostics;
6868
use rustc_span::symbol::{Ident, Symbol, kw, sym};
6969
use rustc_span::{DUMMY_SP, DesugaringKind, Span};
@@ -307,10 +307,6 @@ impl<'tcx> ResolverAstLowering<'tcx> {
307307
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
308308
}
309309

310-
fn delegation_info(&self, id: LocalDefId) -> Option<&DelegationInfo> {
311-
self.delegation_infos.get(&id)
312-
}
313-
314310
fn owner_def_id(&self, id: NodeId) -> LocalDefId {
315311
self.owners[&id].def_id
316312
}

compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,35 @@ impl SingleAttributeParser for RustcDumpDefPathParser {
4545
}
4646
}
4747

48+
pub(crate) struct RustcDumpGenericsParser;
49+
50+
impl NoArgsAttributeParser for RustcDumpGenericsParser {
51+
const PATH: &[Symbol] = &[sym::rustc_dump_generics];
52+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
53+
Allow(Target::Struct),
54+
Allow(Target::Enum),
55+
Allow(Target::Union),
56+
Allow(Target::Trait),
57+
Allow(Target::TraitAlias),
58+
Allow(Target::Fn),
59+
Allow(Target::Closure),
60+
Allow(Target::TyAlias),
61+
Allow(Target::Const),
62+
Allow(Target::AssocConst),
63+
Allow(Target::AssocTy),
64+
Allow(Target::Impl { of_trait: false }),
65+
Allow(Target::Impl { of_trait: true }),
66+
Allow(Target::Method(MethodKind::Inherent)),
67+
Allow(Target::Method(MethodKind::Trait { body: false })),
68+
Allow(Target::Method(MethodKind::Trait { body: true })),
69+
Allow(Target::Method(MethodKind::TraitImpl)),
70+
Allow(Target::Delegation { mac: false }),
71+
Allow(Target::Delegation { mac: true }),
72+
]);
73+
const STABILITY: AttributeStability = unstable!(rustc_attrs);
74+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpGenerics;
75+
}
76+
4877
pub(crate) struct RustcDumpHiddenTypeOfOpaquesParser;
4978

5079
impl NoArgsAttributeParser for RustcDumpHiddenTypeOfOpaquesParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ attribute_parsers!(
278278
Single<WithoutArgs<RustcDenyExplicitImplParser>>,
279279
Single<WithoutArgs<RustcDoNotConstCheckParser>>,
280280
Single<WithoutArgs<RustcDumpDefParentsParser>>,
281+
Single<WithoutArgs<RustcDumpGenericsParser>>,
281282
Single<WithoutArgs<RustcDumpHiddenTypeOfOpaquesParser>>,
282283
Single<WithoutArgs<RustcDumpInferredOutlivesParser>>,
283284
Single<WithoutArgs<RustcDumpItemBoundsParser>>,

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
537537
Some(self.infcx.tcx.hir_name(var_id).to_string())
538538
}
539539
_ => {
540-
// Might need a revision when the fields in trait RFC is implemented
541-
// (https://github.com/rust-lang/rfcs/pull/1546)
542-
bug!("End-user description not implemented for field access on `{:?}`", ty);
540+
// This can happen for field accesses on `Box<T>`: the field is
541+
// described from the boxed type, which may have no named fields
542+
Some(field.index().to_string())
543543
}
544544
}
545545
}

compiler/rustc_builtin_macros/src/diagnostics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,9 @@ pub(crate) struct EiiStaticMultipleImplementations {
11351135
}
11361136

11371137
#[derive(Diagnostic)]
1138-
#[diag("`#[{$name}]` cannot be used on statics with a value")]
1139-
pub(crate) struct EiiStaticDefault {
1138+
#[diag("`#[{$name}]` cannot be used on statics with a value on Apple targets")]
1139+
#[note("see issue #157649 <https://github.com/rust-lang/rust/issues/157649> for more information")]
1140+
pub(crate) struct EiiStaticDefaultApple {
11401141
#[primary_span]
11411142
pub span: Span,
11421143
pub name: String,

0 commit comments

Comments
 (0)