Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ccb841f

Browse files
committed
Auto merge of rust-lang#122816 - workingjubilee:rollup-2jipmky, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#122222 (deref patterns: bare-bones feature gate and typechecking) - rust-lang#122456 (CFI: Skip non-passed arguments) - rust-lang#122696 (Add bare metal riscv32 target.) - rust-lang#122771 (add some comments to hir::ModuleItems) - rust-lang#122773 (make "expected paren or brace" error translatable) - rust-lang#122795 (Inherit `RUSTC_BOOTSTRAP` when testing wasm) - rust-lang#122799 (Replace closures with `_` when suggesting fully qualified path for method call) - rust-lang#122801 (Fix misc printing issues in emit=stable_mir) - rust-lang#122806 (Make `type_ascribe!` not a built-in) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 47dd709 + b3869b6 commit ccb841f

File tree

71 files changed

+796
-739
lines changed

Some content is hidden

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

71 files changed

+796
-739
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
413413
}
414414
}
415415
PatKind::Box(..) => {
416-
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
416+
if !self.features.deref_patterns {
417+
// Allow box patterns under `deref_patterns`.
418+
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
419+
}
417420
}
418421
PatKind::Range(_, Some(_), Spanned { node: RangeEnd::Excluded, .. }) => {
419422
gate!(
@@ -607,13 +610,16 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
607610
};
608611
}
609612

613+
if !visitor.features.deref_patterns {
614+
// Allow box patterns under `deref_patterns`.
615+
gate_all_legacy_dont_use!(box_patterns, "box pattern syntax is experimental");
616+
}
610617
gate_all_legacy_dont_use!(trait_alias, "trait aliases are experimental");
611618
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
612619
// used to be gated under associated_type_bounds, which are right above, so RTN needs to
613620
// be too.
614621
gate_all_legacy_dont_use!(return_type_notation, "return type notation is experimental");
615622
gate_all_legacy_dont_use!(decl_macro, "`macro` is experimental");
616-
gate_all_legacy_dont_use!(box_patterns, "box pattern syntax is experimental");
617623
gate_all_legacy_dont_use!(
618624
exclusive_range_pattern,
619625
"exclusive range pattern syntax is experimental"

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ mod log_syntax;
4949
mod source_util;
5050
mod test;
5151
mod trace_macros;
52-
mod type_ascribe;
5352
mod util;
5453

5554
pub mod asm;
@@ -99,7 +98,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
9998
std_panic: edition_panic::expand_panic,
10099
stringify: source_util::expand_stringify,
101100
trace_macros: trace_macros::expand_trace_macros,
102-
type_ascribe: type_ascribe::expand_type_ascribe,
103101
unreachable: edition_panic::expand_unreachable,
104102
// tidy-alphabetical-end
105103
}

compiler/rustc_builtin_macros/src/type_ascribe.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

compiler/rustc_expand/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ expand_duplicate_matcher_binding = duplicate matcher binding
3333
expand_expected_comma_in_list =
3434
expected token: `,`
3535
36+
expand_expected_paren_or_brace =
37+
expected `(` or `{"{"}`, found `{$token}`
38+
3639
expand_explain_doc_comment_inner =
3740
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
3841

compiler/rustc_expand/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,11 @@ pub struct InvalidFragmentSpecifier {
448448
pub fragment: Ident,
449449
pub help: String,
450450
}
451+
452+
#[derive(Diagnostic)]
453+
#[diag(expand_expected_paren_or_brace)]
454+
pub struct ExpectedParenOrBrace<'a> {
455+
#[primary_span]
456+
pub span: Span,
457+
pub token: Cow<'a, str>,
458+
}

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@ fn parse_tree<'a>(
194194
}
195195
Delimiter::Parenthesis => {}
196196
_ => {
197-
let tok = pprust::token_kind_to_string(&token::OpenDelim(delim));
198-
let msg = format!("expected `(` or `{{`, found `{tok}`");
199-
sess.dcx().span_err(delim_span.entire(), msg);
197+
let token = pprust::token_kind_to_string(&token::OpenDelim(delim));
198+
sess.dcx().emit_err(errors::ExpectedParenOrBrace {
199+
span: delim_span.entire(),
200+
token,
201+
});
200202
}
201203
}
202204
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ declare_features! (
436436
(unstable, deprecated_safe, "1.61.0", Some(94978)),
437437
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
438438
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
439+
/// Allows deref patterns.
440+
(incomplete, deref_patterns, "CURRENT_RUSTC_VERSION", Some(87121)),
439441
/// Controls errors in trait implementations.
440442
(unstable, do_not_recommend, "1.67.0", Some(51992)),
441443
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.

compiler/rustc_hir_analysis/src/astconv/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fn check_assoc_const_binding_type<'tcx>(
565565
let mut guar = ty.visit_with(&mut collector).break_value();
566566

567567
let ty_note = ty
568-
.make_suggestable(tcx, false)
568+
.make_suggestable(tcx, false, None)
569569
.map(|ty| crate::errors::TyOfAssocConstBindingNote { assoc_const, ty });
570570

571571
let enclosing_item_owner_id = tcx

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
13711371
// recursive function definition to leak out into the fn sig.
13721372
let mut should_recover = false;
13731373

1374-
if let Some(ret_ty) = ret_ty.make_suggestable(tcx, false) {
1374+
if let Some(ret_ty) = ret_ty.make_suggestable(tcx, false, None) {
13751375
diag.span_suggestion(
13761376
ty.span,
13771377
"replace with the correct return type",
@@ -1449,7 +1449,7 @@ fn suggest_impl_trait<'tcx>(
14491449
let ty::Tuple(types) = *args_tuple.kind() else {
14501450
return None;
14511451
};
1452-
let types = types.make_suggestable(tcx, false)?;
1452+
let types = types.make_suggestable(tcx, false, None)?;
14531453
let maybe_ret =
14541454
if item_ty.is_unit() { String::new() } else { format!(" -> {item_ty}") };
14551455
Some(format!(
@@ -1507,7 +1507,7 @@ fn suggest_impl_trait<'tcx>(
15071507
// FIXME(compiler-errors): We may benefit from resolving regions here.
15081508
if ocx.select_where_possible().is_empty()
15091509
&& let item_ty = infcx.resolve_vars_if_possible(item_ty)
1510-
&& let Some(item_ty) = item_ty.make_suggestable(tcx, false)
1510+
&& let Some(item_ty) = item_ty.make_suggestable(tcx, false, None)
15111511
&& let Some(sugg) = formatter(
15121512
tcx,
15131513
infcx.resolve_vars_if_possible(args),

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
4747
let ty = tcx.fold_regions(ty, |r, _| {
4848
if r.is_erased() { ty::Region::new_error_misc(tcx) } else { r }
4949
});
50-
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) {
50+
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false, None) {
5151
(ty, Some((span, Applicability::MachineApplicable)))
5252
} else {
5353
(ty, None)
@@ -587,7 +587,7 @@ fn infer_placeholder_type<'a>(
587587
suggestions.clear();
588588
}
589589

590-
if let Some(ty) = ty.make_suggestable(tcx, false) {
590+
if let Some(ty) = ty.make_suggestable(tcx, false, None) {
591591
err.span_suggestion(
592592
span,
593593
format!("provide a type for the {kind}"),
@@ -606,7 +606,7 @@ fn infer_placeholder_type<'a>(
606606
let mut diag = bad_placeholder(tcx, vec![span], kind);
607607

608608
if !ty.references_error() {
609-
if let Some(ty) = ty.make_suggestable(tcx, false) {
609+
if let Some(ty) = ty.make_suggestable(tcx, false, None) {
610610
diag.span_suggestion(
611611
span,
612612
"replace with the correct type",

0 commit comments

Comments
 (0)