Skip to content

Commit f1bc669

Browse files
committed
Auto merge of #138974 - Zalathar:rollup-568cpmy, r=Zalathar
Rollup of 7 pull requests Successful merges: - #138483 (Target modifiers fix for bool flags without value) - #138818 (Don't produce debug information for compiler-introduced-vars when desugaring assignments.) - #138898 (Mostly parser: Eliminate code that's been dead / semi-dead since the removal of type ascription syntax) - #138930 (Add bootstrap step diff to CI job analysis) - #138954 (Ensure `define_opaque` attrs are accounted for in HIR hash) - #138959 (Revert "Make MatchPairTree::place non-optional") - #138967 (Fix typo in error message) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 65899c0 + 46a40be commit f1bc669

File tree

63 files changed

+896
-745
lines changed

Some content is hidden

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

63 files changed

+896
-745
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

-8
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,6 @@ pub struct Block {
545545
pub rules: BlockCheckMode,
546546
pub span: Span,
547547
pub tokens: Option<LazyAttrTokenStream>,
548-
/// The following *isn't* a parse error, but will cause multiple errors in following stages.
549-
/// ```compile_fail
550-
/// let x = {
551-
/// foo: var
552-
/// };
553-
/// ```
554-
/// #34255
555-
pub could_be_bare_literal: bool,
556548
}
557549

558550
/// A match pattern.

Diff for: compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
12221222
}
12231223

12241224
pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
1225-
let Block { id, stmts, rules: _, span, tokens, could_be_bare_literal: _ } = block.deref_mut();
1225+
let Block { id, stmts, rules: _, span, tokens } = block.deref_mut();
12261226
vis.visit_id(id);
12271227
stmts.flat_map_in_place(|stmt| vis.flat_map_stmt(stmt));
12281228
visit_lazy_tts(vis, tokens);

Diff for: compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ pub fn walk_field_def<'a, V: Visitor<'a>>(visitor: &mut V, field: &'a FieldDef)
10671067
}
10681068

10691069
pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::Result {
1070-
let Block { stmts, id: _, rules: _, span: _, tokens: _, could_be_bare_literal: _ } = block;
1070+
let Block { stmts, id: _, rules: _, span: _, tokens: _ } = block;
10711071
walk_list!(visitor, visit_stmt, stmts);
10721072
V::Result::output()
10731073
}

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
623623

624624
// Don't hash unless necessary, because it's expensive.
625625
let (opt_hash_including_bodies, attrs_hash) =
626-
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
626+
self.tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
627627
let num_nodes = self.item_local_id_counter.as_usize();
628628
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
629629
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };

Diff for: compiler/rustc_builtin_macros/src/autodiff.rs

-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ mod llvm_enzyme {
395395
tokens: None,
396396
rules: unsf,
397397
span,
398-
could_be_bare_literal: false,
399398
};
400399
let unsf_expr = ecx.expr_block(P(unsf_block));
401400
let blackbox_call_expr = ecx.expr_path(ecx.path(span, blackbox_path));

Diff for: compiler/rustc_builtin_macros/src/deriving/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P<ast::Expr> {
110110
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
111111
span,
112112
tokens: None,
113-
could_be_bare_literal: false,
114113
}))
115114
}
116115

Diff for: compiler/rustc_expand/src/build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ impl<'a> ExtCtxt<'a> {
286286
rules: BlockCheckMode::Default,
287287
span,
288288
tokens: None,
289-
could_be_bare_literal: false,
290289
})
291290
}
292291

Diff for: compiler/rustc_metadata/messages.ftl

+14-3
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,23 @@ metadata_incompatible_rustc =
118118
119119
metadata_incompatible_target_modifiers =
120120
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
121-
.note = `{$flag_name_prefixed}={$flag_local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$flag_extern_value}` in dependency `{$extern_crate}`
121+
.note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`
122122
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
123-
124123
metadata_incompatible_target_modifiers_help_allow = if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error
125-
metadata_incompatible_target_modifiers_help_fix = set `{$flag_name_prefixed}={$flag_extern_value}` in this crate or `{$flag_name_prefixed}={$flag_local_value}` in `{$extern_crate}`
124+
metadata_incompatible_target_modifiers_help_fix = set `{$flag_name_prefixed}={$extern_value}` in this crate or `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`
125+
126+
metadata_incompatible_target_modifiers_help_fix_l_missed = set `{$flag_name_prefixed}={$extern_value}` in this crate or unset `{$flag_name_prefixed}` in `{$extern_crate}`
126127
128+
metadata_incompatible_target_modifiers_help_fix_r_missed = unset `{$flag_name_prefixed}` in this crate or set `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`
129+
130+
metadata_incompatible_target_modifiers_l_missed =
131+
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
132+
.note = unset `{$flag_name_prefixed}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`
133+
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
134+
metadata_incompatible_target_modifiers_r_missed =
135+
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
136+
.note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}`
137+
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
127138
metadata_incompatible_wasm_link =
128139
`wasm_import_module` is incompatible with other arguments in `#[link]` attributes
129140

Diff for: compiler/rustc_metadata/src/creader.rs

+51-18
Original file line numberDiff line numberDiff line change
@@ -358,57 +358,90 @@ impl CStore {
358358
) {
359359
let span = krate.spans.inner_span.shrink_to_lo();
360360
let allowed_flag_mismatches = &tcx.sess.opts.cg.unsafe_allow_abi_mismatch;
361-
let name = tcx.crate_name(LOCAL_CRATE);
361+
let local_crate = tcx.crate_name(LOCAL_CRATE);
362362
let tmod_extender = |tmod: &TargetModifier| (tmod.extend(), tmod.clone());
363363
let report_diff = |prefix: &String,
364364
opt_name: &String,
365-
flag_local_value: &String,
366-
flag_extern_value: &String| {
365+
flag_local_value: Option<&String>,
366+
flag_extern_value: Option<&String>| {
367367
if allowed_flag_mismatches.contains(&opt_name) {
368368
return;
369369
}
370-
tcx.dcx().emit_err(errors::IncompatibleTargetModifiers {
371-
span,
372-
extern_crate: data.name(),
373-
local_crate: name,
374-
flag_name: opt_name.clone(),
375-
flag_name_prefixed: format!("-{}{}", prefix, opt_name),
376-
flag_local_value: flag_local_value.to_string(),
377-
flag_extern_value: flag_extern_value.to_string(),
378-
});
370+
let extern_crate = data.name();
371+
let flag_name = opt_name.clone();
372+
let flag_name_prefixed = format!("-{}{}", prefix, opt_name);
373+
374+
match (flag_local_value, flag_extern_value) {
375+
(Some(local_value), Some(extern_value)) => {
376+
tcx.dcx().emit_err(errors::IncompatibleTargetModifiers {
377+
span,
378+
extern_crate,
379+
local_crate,
380+
flag_name,
381+
flag_name_prefixed,
382+
local_value: local_value.to_string(),
383+
extern_value: extern_value.to_string(),
384+
})
385+
}
386+
(None, Some(extern_value)) => {
387+
tcx.dcx().emit_err(errors::IncompatibleTargetModifiersLMissed {
388+
span,
389+
extern_crate,
390+
local_crate,
391+
flag_name,
392+
flag_name_prefixed,
393+
extern_value: extern_value.to_string(),
394+
})
395+
}
396+
(Some(local_value), None) => {
397+
tcx.dcx().emit_err(errors::IncompatibleTargetModifiersRMissed {
398+
span,
399+
extern_crate,
400+
local_crate,
401+
flag_name,
402+
flag_name_prefixed,
403+
local_value: local_value.to_string(),
404+
})
405+
}
406+
(None, None) => panic!("Incorrect target modifiers report_diff(None, None)"),
407+
};
379408
};
380409
let mut it1 = mods.iter().map(tmod_extender);
381410
let mut it2 = dep_mods.iter().map(tmod_extender);
382411
let mut left_name_val: Option<(ExtendedTargetModifierInfo, TargetModifier)> = None;
383412
let mut right_name_val: Option<(ExtendedTargetModifierInfo, TargetModifier)> = None;
384-
let no_val = "*".to_string();
385413
loop {
386414
left_name_val = left_name_val.or_else(|| it1.next());
387415
right_name_val = right_name_val.or_else(|| it2.next());
388416
match (&left_name_val, &right_name_val) {
389417
(Some(l), Some(r)) => match l.1.opt.cmp(&r.1.opt) {
390418
cmp::Ordering::Equal => {
391419
if l.0.tech_value != r.0.tech_value {
392-
report_diff(&l.0.prefix, &l.0.name, &l.1.value_name, &r.1.value_name);
420+
report_diff(
421+
&l.0.prefix,
422+
&l.0.name,
423+
Some(&l.1.value_name),
424+
Some(&r.1.value_name),
425+
);
393426
}
394427
left_name_val = None;
395428
right_name_val = None;
396429
}
397430
cmp::Ordering::Greater => {
398-
report_diff(&r.0.prefix, &r.0.name, &no_val, &r.1.value_name);
431+
report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
399432
right_name_val = None;
400433
}
401434
cmp::Ordering::Less => {
402-
report_diff(&l.0.prefix, &l.0.name, &l.1.value_name, &no_val);
435+
report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
403436
left_name_val = None;
404437
}
405438
},
406439
(Some(l), None) => {
407-
report_diff(&l.0.prefix, &l.0.name, &l.1.value_name, &no_val);
440+
report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
408441
left_name_val = None;
409442
}
410443
(None, Some(r)) => {
411-
report_diff(&r.0.prefix, &r.0.name, &no_val, &r.1.value_name);
444+
report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
412445
right_name_val = None;
413446
}
414447
(None, None) => break,

Diff for: compiler/rustc_metadata/src/errors.rs

+34-2
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,40 @@ pub struct IncompatibleTargetModifiers {
759759
pub local_crate: Symbol,
760760
pub flag_name: String,
761761
pub flag_name_prefixed: String,
762-
pub flag_local_value: String,
763-
pub flag_extern_value: String,
762+
pub local_value: String,
763+
pub extern_value: String,
764+
}
765+
766+
#[derive(Diagnostic)]
767+
#[diag(metadata_incompatible_target_modifiers_l_missed)]
768+
#[help]
769+
#[note]
770+
#[help(metadata_incompatible_target_modifiers_help_fix_l_missed)]
771+
#[help(metadata_incompatible_target_modifiers_help_allow)]
772+
pub struct IncompatibleTargetModifiersLMissed {
773+
#[primary_span]
774+
pub span: Span,
775+
pub extern_crate: Symbol,
776+
pub local_crate: Symbol,
777+
pub flag_name: String,
778+
pub flag_name_prefixed: String,
779+
pub extern_value: String,
780+
}
781+
782+
#[derive(Diagnostic)]
783+
#[diag(metadata_incompatible_target_modifiers_r_missed)]
784+
#[help]
785+
#[note]
786+
#[help(metadata_incompatible_target_modifiers_help_fix_r_missed)]
787+
#[help(metadata_incompatible_target_modifiers_help_allow)]
788+
pub struct IncompatibleTargetModifiersRMissed {
789+
#[primary_span]
790+
pub span: Span,
791+
pub extern_crate: Symbol,
792+
pub local_crate: Symbol,
793+
pub flag_name: String,
794+
pub flag_name_prefixed: String,
795+
pub local_value: String,
764796
}
765797

766798
#[derive(Diagnostic)]

Diff for: compiler/rustc_middle/src/hir/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_hir::def::DefKind;
1414
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
1515
use rustc_hir::*;
1616
use rustc_macros::{Decodable, Encodable, HashStable};
17-
use rustc_span::{ErrorGuaranteed, ExpnId};
17+
use rustc_span::{ErrorGuaranteed, ExpnId, Span};
1818

1919
use crate::query::Providers;
2020
use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
@@ -157,6 +157,7 @@ impl<'tcx> TyCtxt<'tcx> {
157157
node: OwnerNode<'_>,
158158
bodies: &SortedMap<ItemLocalId, &Body<'_>>,
159159
attrs: &SortedMap<ItemLocalId, &[Attribute]>,
160+
define_opaque: Option<&[(Span, LocalDefId)]>,
160161
) -> (Option<Fingerprint>, Option<Fingerprint>) {
161162
if self.needs_crate_hash() {
162163
self.with_stable_hashing_context(|mut hcx| {
@@ -168,6 +169,10 @@ impl<'tcx> TyCtxt<'tcx> {
168169

169170
let mut stable_hasher = StableHasher::new();
170171
attrs.hash_stable(&mut hcx, &mut stable_hasher);
172+
173+
// Hash the defined opaque types, which are not present in the attrs.
174+
define_opaque.hash_stable(&mut hcx, &mut stable_hasher);
175+
171176
let h2 = stable_hasher.finish();
172177
(Some(h1), Some(h2))
173178
})

Diff for: compiler/rustc_middle/src/ty/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,8 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
12881288
let bodies = Default::default();
12891289
let attrs = hir::AttributeMap::EMPTY;
12901290

1291-
let (opt_hash_including_bodies, _) = self.tcx.hash_owner_nodes(node, &bodies, &attrs.map);
1291+
let (opt_hash_including_bodies, _) =
1292+
self.tcx.hash_owner_nodes(node, &bodies, &attrs.map, attrs.define_opaque);
12921293
let node = node.into();
12931294
self.opt_hir_owner_nodes(Some(self.tcx.arena.alloc(hir::OwnerNodes {
12941295
opt_hash_including_bodies,

Diff for: compiler/rustc_mir_build/src/builder/matches/match_pair.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ impl<'tcx> MatchPairTree<'tcx> {
115115
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
116116
}
117117

118-
// Place can be none if the pattern refers to a non-captured place in a closure.
119118
let place = place_builder.try_to_place(cx);
120119
let mut subpairs = Vec::new();
121120
let test_case = match pattern.kind {
@@ -321,7 +320,7 @@ impl<'tcx> MatchPairTree<'tcx> {
321320
if let Some(test_case) = test_case {
322321
// This pattern is refutable, so push a new match-pair node.
323322
match_pairs.push(MatchPairTree {
324-
place: place.expect("refutable patterns should always have a place to inspect"),
323+
place,
325324
test_case,
326325
subpairs,
327326
pattern_ty: pattern.ty,

0 commit comments

Comments
 (0)