Skip to content

Commit e3c631b

Browse files
committed
Auto merge of rust-lang#116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#115863 (Add check_unused_messages in tidy) - rust-lang#116210 (Ensure that `~const` trait bounds on associated functions are in const traits or impls) - rust-lang#116358 (Rename both of the `Match` relations) - rust-lang#116371 (Remove unused features from `rustc_llvm`.) - rust-lang#116374 (Print normalized ty) r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb0f3ed + 7ba6498 commit e3c631b

File tree

20 files changed

+193
-127
lines changed

20 files changed

+193
-127
lines changed

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+34-22
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ struct AstValidator<'a> {
5252
/// Are we inside a trait impl?
5353
in_trait_impl: bool,
5454

55-
in_const_trait_impl: bool,
55+
/// Are we inside a const trait defn or impl?
56+
in_const_trait_or_impl: bool,
5657

5758
has_proc_macro_decls: bool,
5859

@@ -78,11 +79,19 @@ impl<'a> AstValidator<'a> {
7879
f: impl FnOnce(&mut Self),
7980
) {
8081
let old = mem::replace(&mut self.in_trait_impl, is_in);
81-
let old_const =
82-
mem::replace(&mut self.in_const_trait_impl, matches!(constness, Some(Const::Yes(_))));
82+
let old_const = mem::replace(
83+
&mut self.in_const_trait_or_impl,
84+
matches!(constness, Some(Const::Yes(_))),
85+
);
8386
f(self);
8487
self.in_trait_impl = old;
85-
self.in_const_trait_impl = old_const;
88+
self.in_const_trait_or_impl = old_const;
89+
}
90+
91+
fn with_in_trait(&mut self, is_const: bool, f: impl FnOnce(&mut Self)) {
92+
let old = mem::replace(&mut self.in_const_trait_or_impl, is_const);
93+
f(self);
94+
self.in_const_trait_or_impl = old;
8695
}
8796

8897
fn with_banned_impl_trait(&mut self, f: impl FnOnce(&mut Self)) {
@@ -933,23 +942,26 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
933942
}
934943
}
935944
ItemKind::Trait(box Trait { is_auto, generics, bounds, items, .. }) => {
936-
if *is_auto == IsAuto::Yes {
937-
// Auto traits cannot have generics, super traits nor contain items.
938-
self.deny_generic_params(generics, item.ident.span);
939-
self.deny_super_traits(bounds, item.ident.span);
940-
self.deny_where_clause(&generics.where_clause, item.ident.span);
941-
self.deny_items(items, item.ident.span);
942-
}
945+
let is_const_trait = attr::contains_name(&item.attrs, sym::const_trait);
946+
self.with_in_trait(is_const_trait, |this| {
947+
if *is_auto == IsAuto::Yes {
948+
// Auto traits cannot have generics, super traits nor contain items.
949+
this.deny_generic_params(generics, item.ident.span);
950+
this.deny_super_traits(bounds, item.ident.span);
951+
this.deny_where_clause(&generics.where_clause, item.ident.span);
952+
this.deny_items(items, item.ident.span);
953+
}
943954

944-
// Equivalent of `visit::walk_item` for `ItemKind::Trait` that inserts a bound
945-
// context for the supertraits.
946-
self.visit_vis(&item.vis);
947-
self.visit_ident(item.ident);
948-
self.visit_generics(generics);
949-
self.with_tilde_const_allowed(|this| {
950-
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
955+
// Equivalent of `visit::walk_item` for `ItemKind::Trait` that inserts a bound
956+
// context for the supertraits.
957+
this.visit_vis(&item.vis);
958+
this.visit_ident(item.ident);
959+
this.visit_generics(generics);
960+
this.with_tilde_const_allowed(|this| {
961+
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
962+
});
963+
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
951964
});
952-
walk_list!(self, visit_assoc_item, items, AssocCtxt::Trait);
953965
walk_list!(self, visit_attribute, &item.attrs);
954966
return; // Avoid visiting again
955967
}
@@ -1278,7 +1290,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12781290

12791291
let tilde_const_allowed =
12801292
matches!(fk.header(), Some(FnHeader { constness: ast::Const::Yes(_), .. }))
1281-
|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)));
1293+
|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)) if self.in_const_trait_or_impl);
12821294

12831295
let disallowed = (!tilde_const_allowed).then(|| DisallowTildeConstContext::Fn(fk));
12841296

@@ -1363,7 +1375,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13631375
walk_list!(self, visit_ty, ty);
13641376
}
13651377
AssocItemKind::Fn(box Fn { sig, generics, body, .. })
1366-
if self.in_const_trait_impl
1378+
if self.in_const_trait_or_impl
13671379
|| ctxt == AssocCtxt::Trait
13681380
|| matches!(sig.header.constness, Const::Yes(_)) =>
13691381
{
@@ -1510,7 +1522,7 @@ pub fn check_crate(
15101522
features,
15111523
extern_mod: None,
15121524
in_trait_impl: false,
1513-
in_const_trait_impl: false,
1525+
in_const_trait_or_impl: false,
15141526
has_proc_macro_decls: false,
15151527
outer_impl_trait: None,
15161528
disallow_tilde_const: None,

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -670,19 +670,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
670670

671671
trace!("eval_place_to_op: got {:?}", op);
672672
// Sanity-check the type we ended up with.
673-
debug_assert!(
674-
mir_assign_valid_types(
673+
if cfg!(debug_assertions) {
674+
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
675+
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
676+
)?;
677+
if !mir_assign_valid_types(
675678
*self.tcx,
676679
self.param_env,
677-
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
678-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
679-
)?)?,
680+
self.layout_of(normalized_place_ty)?,
680681
op.layout,
681-
),
682-
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {}",
683-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
684-
op.layout.ty,
685-
);
682+
) {
683+
span_bug!(
684+
self.cur_span(),
685+
"eval_place of a MIR place with type {} produced an interpreter operand with type {}",
686+
normalized_place_ty,
687+
op.layout.ty,
688+
)
689+
}
690+
}
686691
Ok(op)
687692
}
688693

Diff for: compiler/rustc_const_eval/src/interpret/place.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -573,19 +573,24 @@ where
573573

574574
trace!("{:?}", self.dump_place(&place));
575575
// Sanity-check the type we ended up with.
576-
debug_assert!(
577-
mir_assign_valid_types(
576+
if cfg!(debug_assertions) {
577+
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
578+
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
579+
)?;
580+
if !mir_assign_valid_types(
578581
*self.tcx,
579582
self.param_env,
580-
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
581-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
582-
)?)?,
583+
self.layout_of(normalized_place_ty)?,
583584
place.layout,
584-
),
585-
"eval_place of a MIR place with type {:?} produced an interpreter place with type {}",
586-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
587-
place.layout.ty,
588-
);
585+
) {
586+
span_bug!(
587+
self.cur_span(),
588+
"eval_place of a MIR place with type {} produced an interpreter place with type {}",
589+
normalized_place_ty,
590+
place.layout.ty,
591+
)
592+
}
593+
}
589594
Ok(place)
590595
}
591596

Diff for: compiler/rustc_hir_analysis/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ hir_analysis_enum_discriminant_overflowed = enum discriminant overflowed
9696
.label = overflowed on value after {$discr}
9797
.note = explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome
9898
99-
hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
100-
10199
hir_analysis_field_already_declared =
102100
field `{$field_name}` is already declared
103101
.label = field already declared

Diff for: compiler/rustc_infer/messages.ftl

-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ infer_await_both_futures = consider `await`ing on both `Future`s
6666
infer_await_future = consider `await`ing on the `Future`
6767
infer_await_note = calling an async function returns a future
6868
69-
infer_borrowed_too_long = a value of type `{$ty}` is borrowed for too long
7069
infer_but_calling_introduces = {$has_param_name ->
7170
[true] `{$param_name}`
7271
*[false] `fn` parameter
@@ -181,8 +180,6 @@ infer_more_targeted = {$has_param_name ->
181180
} but calling `{$ident}` introduces an implicit `'static` lifetime requirement
182181
183182
infer_msl_introduces_static = introduces a `'static` lifetime requirement
184-
infer_msl_trait_note = this has an implicit `'static` lifetime requirement
185-
infer_msl_trait_sugg = consider relaxing the implicit `'static` requirement
186183
infer_msl_unmet_req = because this has an unmet lifetime requirement
187184
infer_need_type_info_in_generator =
188185
type inside {$generator_kind ->
@@ -233,7 +230,6 @@ infer_prlf_known_limitation = this is a known limitation that will be removed in
233230
infer_prlf_must_outlive_with_sup = ...must outlive the lifetime `{$sup_symbol}` defined here
234231
infer_prlf_must_outlive_without_sup = ...must outlive the lifetime defined here
235232
infer_reborrow = ...so that reference does not outlive borrowed content
236-
infer_reborrow_upvar = ...so that closure can access `{$name}`
237233
infer_ref_longer_than_data = in type `{$ty}`, reference has a longer lifetime than the data it references
238234
239235
infer_reference_outlives_referent = ...so that the reference type `{$name}` does not outlive the data it points at

Diff for: compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn extract_verify_if_eq<'tcx>(
4444
test_ty: Ty<'tcx>,
4545
) -> Option<ty::Region<'tcx>> {
4646
assert!(!verify_if_eq_b.has_escaping_bound_vars());
47-
let mut m = Match::new(tcx, param_env);
47+
let mut m = MatchAgainstHigherRankedOutlives::new(tcx, param_env);
4848
let verify_if_eq = verify_if_eq_b.skip_binder();
4949
m.relate(verify_if_eq.ty, test_ty).ok()?;
5050

@@ -87,24 +87,32 @@ pub(super) fn can_match_erased_ty<'tcx>(
8787
// pointless micro-optimization
8888
true
8989
} else {
90-
Match::new(tcx, param_env).relate(outlives_ty, erased_ty).is_ok()
90+
MatchAgainstHigherRankedOutlives::new(tcx, param_env).relate(outlives_ty, erased_ty).is_ok()
9191
}
9292
}
9393

94-
struct Match<'tcx> {
94+
struct MatchAgainstHigherRankedOutlives<'tcx> {
9595
tcx: TyCtxt<'tcx>,
9696
param_env: ty::ParamEnv<'tcx>,
9797
pattern_depth: ty::DebruijnIndex,
9898
map: FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
9999
}
100100

101-
impl<'tcx> Match<'tcx> {
102-
fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Match<'tcx> {
103-
Match { tcx, param_env, pattern_depth: ty::INNERMOST, map: FxHashMap::default() }
101+
impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
102+
fn new(
103+
tcx: TyCtxt<'tcx>,
104+
param_env: ty::ParamEnv<'tcx>,
105+
) -> MatchAgainstHigherRankedOutlives<'tcx> {
106+
MatchAgainstHigherRankedOutlives {
107+
tcx,
108+
param_env,
109+
pattern_depth: ty::INNERMOST,
110+
map: FxHashMap::default(),
111+
}
104112
}
105113
}
106114

107-
impl<'tcx> Match<'tcx> {
115+
impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
108116
/// Creates the "Error" variant that signals "no match".
109117
fn no_match<T>(&self) -> RelateResult<'tcx, T> {
110118
Err(TypeError::Mismatch)
@@ -134,7 +142,7 @@ impl<'tcx> Match<'tcx> {
134142
}
135143
}
136144

137-
impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
145+
impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
138146
fn tag(&self) -> &'static str {
139147
"Match"
140148
}

Diff for: compiler/rustc_llvm/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name = "rustc_llvm"
33
version = "0.0.0"
44
edition = "2021"
55

6-
[features]
7-
static-libstdcpp = []
8-
emscripten = []
9-
106
[dependencies]
117
libc = "0.2.73"
128

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ use crate::ty::{self, InferConst, Ty, TyCtxt};
1818
/// Like subtyping, matching is really a binary relation, so the only
1919
/// important thing about the result is Ok/Err. Also, matching never
2020
/// affects any type variables or unification state.
21-
pub struct Match<'tcx> {
21+
pub struct MatchAgainstFreshVars<'tcx> {
2222
tcx: TyCtxt<'tcx>,
2323
param_env: ty::ParamEnv<'tcx>,
2424
}
2525

26-
impl<'tcx> Match<'tcx> {
27-
pub fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Match<'tcx> {
28-
Match { tcx, param_env }
26+
impl<'tcx> MatchAgainstFreshVars<'tcx> {
27+
pub fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> MatchAgainstFreshVars<'tcx> {
28+
MatchAgainstFreshVars { tcx, param_env }
2929
}
3030
}
3131

32-
impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
32+
impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
3333
fn tag(&self) -> &'static str {
34-
"Match"
34+
"MatchAgainstFreshVars"
3535
}
3636
fn tcx(&self) -> TyCtxt<'tcx> {
3737
self.tcx

Diff for: compiler/rustc_monomorphize/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ monomorphize_couldnt_dump_mono_stats =
77
monomorphize_encountered_error_while_instantiating =
88
the above error was encountered while instantiating `{$formatted_item}`
99
10-
monomorphize_fatal_error = {$error_message}
11-
1210
monomorphize_large_assignments =
1311
moving {$size} bytes
1412
.label = value moved from here

Diff for: compiler/rustc_parse/messages.ftl

-30
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ parse_bare_cr = {$double_quotes ->
5959
6060
parse_bare_cr_in_raw_string = bare CR not allowed in raw string
6161
62-
parse_binary_float_literal_not_supported = binary float literal is not supported
6362
parse_bounds_not_allowed_on_trait_aliases = bounds are not allowed on trait aliases
6463
6564
parse_box_not_pat = expected pattern, found {$descr}
@@ -284,7 +283,6 @@ parse_generics_in_path = unexpected generic arguments in path
284283
285284
parse_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
286285
parse_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
287-
parse_hexadecimal_float_literal_not_supported = hexadecimal float literal is not supported
288286
parse_if_expression_missing_condition = missing condition for `if` expression
289287
.condition_label = expected condition here
290288
.block_label = if this block is the condition of the `if` expression, then it must be followed by another block
@@ -356,8 +354,6 @@ parse_inner_doc_comment_not_permitted = expected outer doc comment
356354
.label_does_not_annotate_this = the inner doc comment doesn't annotate this {$item}
357355
.sugg_change_inner_to_outer = to annotate the {$item}, change the doc comment from inner to outer style
358356
359-
parse_int_literal_too_large = integer literal is too large
360-
361357
parse_invalid_block_macro_segment = cannot use a `block` macro fragment here
362358
.label = the `block` fragment is within this context
363359
.suggestion = wrap this in another block
@@ -382,18 +378,8 @@ parse_invalid_dyn_keyword = invalid `dyn` keyword
382378
.suggestion = remove this keyword
383379
384380
parse_invalid_expression_in_let_else = a `{$operator}` expression cannot be directly assigned in `let...else`
385-
parse_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal
386-
.label = invalid suffix `{$suffix}`
387-
.help = valid suffixes are `f32` and `f64`
388-
389-
parse_invalid_float_literal_width = invalid width `{$width}` for float literal
390-
.help = valid widths are 32 and 64
391-
392381
parse_invalid_identifier_with_leading_number = identifiers cannot start with a number
393382
394-
parse_invalid_int_literal_width = invalid width `{$width}` for integer literal
395-
.help = valid widths are 8, 16, 32, 64 and 128
396-
397383
parse_invalid_interpolated_expression = invalid interpolated expression
398384
399385
parse_invalid_literal_suffix = suffixes on {$kind} literals are invalid
@@ -412,14 +398,6 @@ parse_invalid_logical_operator = `{$incorrect}` is not a logical operator
412398
413399
parse_invalid_meta_item = expected unsuffixed literal or identifier, found `{$token}`
414400
415-
parse_invalid_num_literal_base_prefix = invalid base prefix for number literal
416-
.note = base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
417-
.suggestion = try making the prefix lowercase
418-
419-
parse_invalid_num_literal_suffix = invalid suffix `{$suffix}` for number literal
420-
.label = invalid suffix `{$suffix}`
421-
.help = the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
422-
423401
parse_invalid_unicode_escape = invalid unicode character escape
424402
.label = invalid escape
425403
.help = unicode escape must {$surrogate ->
@@ -603,13 +581,6 @@ parse_no_brace_unicode_escape = incorrect unicode escape sequence
603581
604582
parse_no_digits_literal = no valid digits found for number
605583
606-
parse_non_item_in_item_list = non-item in item list
607-
.suggestion_use_const_not_let = consider using `const` instead of `let` for associated const
608-
.label_list_start = item list starts here
609-
.label_non_item = non-item starts here
610-
.label_list_end = item list ends here
611-
.suggestion_remove_semicolon = consider removing this semicolon
612-
613584
parse_non_string_abi_literal = non-string ABI literal
614585
.suggestion = specify the ABI with a string literal
615586
@@ -626,7 +597,6 @@ parse_note_mut_pattern_usage = `mut` may be followed by `variable` and `variable
626597
627598
parse_note_pattern_alternatives_use_single_vert = alternatives in or-patterns are separated with `|`, not `||`
628599
629-
parse_octal_float_literal_not_supported = octal float literal is not supported
630600
parse_or_pattern_not_allowed_in_fn_parameters = top-level or-patterns are not allowed in function parameters
631601
parse_or_pattern_not_allowed_in_let_binding = top-level or-patterns are not allowed in `let` bindings
632602
parse_out_of_range_hex_escape = out of range hex escape

Diff for: compiler/rustc_query_system/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ query_system_cycle_stack_single = ...which immediately requires {$stack_bottom}
1515
1616
query_system_cycle_usage = cycle used when {$usage}
1717
18-
query_system_cycle_which_requires = ...which requires {$desc}...
19-
2018
query_system_increment_compilation = internal compiler error: encountered incremental compilation error with {$dep_node}
2119
.help = This is a known issue with the compiler. Run {$run_cmd} to allow your project to compile
2220

0 commit comments

Comments
 (0)