Skip to content

Commit 15c4cce

Browse files
committed
Auto merge of rust-lang#139940 - matthiaskrgr:rollup-rd4d3fn, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#135340 (Add `explicit_extern_abis` Feature and Enforce Explicit ABIs) - rust-lang#139440 (rustc_target: RISC-V: feature addition batch 2) - rust-lang#139667 (cfi: Remove #[no_sanitize(cfi)] for extern weak functions) - rust-lang#139828 (Don't require rigid alias's trait to hold) - rust-lang#139854 (Improve parse errors for stray lifetimes in type position) - rust-lang#139889 (Clean UI tests 3 of n) - rust-lang#139894 (Fix `opt-dist` CLI flag and make it work without LLD) - rust-lang#139900 (stepping into impls for normalization is unproductive) - rust-lang#139915 (replace some #[rustc_intrinsic] usage with use of the libcore declarations) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 79a272c + f8f22ad commit 15c4cce

File tree

79 files changed

+939
-231
lines changed

Some content is hidden

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

79 files changed

+939
-231
lines changed

compiler/rustc_ast_passes/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ ast_passes_extern_types_cannot = `type`s inside `extern` blocks cannot have {$de
7979
.suggestion = remove the {$remove_descr}
8080
.label = `extern` block begins here
8181
82+
ast_passes_extern_without_abi = `extern` declarations without an explicit ABI are disallowed
83+
.suggestion = specify an ABI
84+
.help = prior to Rust 2024, a default ABI was inferred
85+
8286
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
8387
.suggestion = remove the attribute
8488
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ impl<'a> AstValidator<'a> {
684684
self.dcx().emit_err(errors::PatternFnPointer { span });
685685
});
686686
if let Extern::Implicit(extern_span) = bfty.ext {
687-
self.maybe_lint_missing_abi(extern_span, ty.id);
687+
self.handle_missing_abi(extern_span, ty.id);
688688
}
689689
}
690690
TyKind::TraitObject(bounds, ..) => {
@@ -717,10 +717,12 @@ impl<'a> AstValidator<'a> {
717717
}
718718
}
719719

720-
fn maybe_lint_missing_abi(&mut self, span: Span, id: NodeId) {
720+
fn handle_missing_abi(&mut self, span: Span, id: NodeId) {
721721
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
722722
// call site which do not have a macro backtrace. See #61963.
723-
if self
723+
if span.edition().at_least_edition_future() && self.features.explicit_extern_abis() {
724+
self.dcx().emit_err(errors::MissingAbi { span });
725+
} else if self
724726
.sess
725727
.source_map()
726728
.span_to_snippet(span)
@@ -996,7 +998,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
996998
}
997999

9981000
if abi.is_none() {
999-
self.maybe_lint_missing_abi(*extern_span, item.id);
1001+
self.handle_missing_abi(*extern_span, item.id);
10001002
}
10011003
self.with_in_extern_mod(*safety, |this| {
10021004
visit::walk_item(this, item);
@@ -1370,7 +1372,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13701372
},
13711373
) = fk
13721374
{
1373-
self.maybe_lint_missing_abi(*extern_span, id);
1375+
self.handle_missing_abi(*extern_span, id);
13741376
}
13751377

13761378
// Functions without bodies cannot have patterns.

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,12 @@ pub(crate) struct DuplicatePreciseCapturing {
823823
#[label]
824824
pub bound2: Span,
825825
}
826+
827+
#[derive(Diagnostic)]
828+
#[diag(ast_passes_extern_without_abi)]
829+
#[help]
830+
pub(crate) struct MissingAbi {
831+
#[primary_span]
832+
#[suggestion(code = "extern \"<abi>\"", applicability = "has-placeholders")]
833+
pub span: Span,
834+
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ declare_features! (
477477
(incomplete, ergonomic_clones, "1.87.0", Some(132290)),
478478
/// Allows exhaustive pattern matching on types that contain uninhabited types.
479479
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
480+
/// Disallows `extern` without an explicit ABI.
481+
(unstable, explicit_extern_abis, "CURRENT_RUSTC_VERSION", Some(134986)),
480482
/// Allows explicit tail calls via `become` expression.
481483
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
482484
/// Allows using `aapcs`, `efiapi`, `sysv64` and `win64` as calling conventions

compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ lint_expectation = this lint expectation is unfulfilled
271271
lint_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition
272272
.suggestion = convert it to a `use`
273273
274-
lint_extern_without_abi = extern declarations without an explicit ABI are deprecated
274+
lint_extern_without_abi = `extern` declarations without an explicit ABI are deprecated
275275
.label = ABI should be specified here
276276
.suggestion = explicitly specify the {$default_abi} ABI
277277

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,18 +286,23 @@ where
286286
// fixing it may cause inference breakage or introduce ambiguity.
287287
GoalSource::Misc => PathKind::Unknown,
288288
GoalSource::NormalizeGoal(path_kind) => path_kind,
289-
GoalSource::ImplWhereBound => {
289+
GoalSource::ImplWhereBound => match self.current_goal_kind {
290290
// We currently only consider a cycle coinductive if it steps
291291
// into a where-clause of a coinductive trait.
292+
CurrentGoalKind::CoinductiveTrait => PathKind::Coinductive,
293+
// While normalizing via an impl does step into a where-clause of
294+
// an impl, accessing the associated item immediately steps out of
295+
// it again. This means cycles/recursive calls are not guarded
296+
// by impls used for normalization.
292297
//
298+
// See tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs
299+
// for how this can go wrong.
300+
CurrentGoalKind::NormalizesTo => PathKind::Inductive,
293301
// We probably want to make all traits coinductive in the future,
294-
// so we treat cycles involving their where-clauses as ambiguous.
295-
if let CurrentGoalKind::CoinductiveTrait = self.current_goal_kind {
296-
PathKind::Coinductive
297-
} else {
298-
PathKind::Unknown
299-
}
300-
}
302+
// so we treat cycles involving where-clauses of not-yet coinductive
303+
// traits as ambiguous for now.
304+
CurrentGoalKind::Misc => PathKind::Unknown,
305+
},
301306
// Relating types is always unproductive. If we were to map proof trees to
302307
// corecursive functions as explained in #136824, relating types never
303308
// introduces a constructor which could cause the recursion to be guarded.

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ where
4545
goal,
4646
goal.predicate.alias,
4747
);
48-
this.add_goal(GoalSource::AliasWellFormed, goal.with(cx, trait_ref));
4948
this.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
5049
})
5150
})

compiler/rustc_parse/messages.ftl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ parse_maybe_recover_from_bad_qpath_stage_2 =
543543
.suggestion = types that don't start with an identifier need to be surrounded with angle brackets in qualified paths
544544
545545
parse_maybe_recover_from_bad_type_plus =
546-
expected a path on the left-hand side of `+`, not `{$ty}`
546+
expected a path on the left-hand side of `+`
547547
548548
parse_maybe_report_ambiguous_plus =
549549
ambiguous `+` in a type
@@ -642,7 +642,9 @@ parse_mut_on_nested_ident_pattern = `mut` must be attached to each individual bi
642642
.suggestion = add `mut` to each binding
643643
parse_mut_on_non_ident_pattern = `mut` must be followed by a named binding
644644
.suggestion = remove the `mut` prefix
645-
parse_need_plus_after_trait_object_lifetime = lifetime in trait object type must be followed by `+`
645+
646+
parse_need_plus_after_trait_object_lifetime = lifetimes must be followed by `+` to form a trait object type
647+
.suggestion = consider adding a trait bound after the potential lifetime bound
646648
647649
parse_nested_adt = `{$kw_str}` definition cannot be nested inside `{$keyword}`
648650
.suggestion = consider creating a new `{$kw_str}` definition instead of nesting

compiler/rustc_parse/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub(crate) struct AmbiguousPlus {
3030
#[derive(Diagnostic)]
3131
#[diag(parse_maybe_recover_from_bad_type_plus, code = E0178)]
3232
pub(crate) struct BadTypePlus {
33-
pub ty: String,
3433
#[primary_span]
3534
pub span: Span,
3635
#[subdiagnostic]
@@ -2800,6 +2799,8 @@ pub(crate) struct ReturnTypesUseThinArrow {
28002799
pub(crate) struct NeedPlusAfterTraitObjectLifetime {
28012800
#[primary_span]
28022801
pub span: Span,
2802+
#[suggestion(code = " + /* Trait */", applicability = "has-placeholders")]
2803+
pub suggestion: Span,
28032804
}
28042805

28052806
#[derive(Diagnostic)]

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,19 +1657,19 @@ impl<'a> Parser<'a> {
16571657

16581658
self.bump(); // `+`
16591659
let _bounds = self.parse_generic_bounds()?;
1660-
let sum_span = ty.span.to(self.prev_token.span);
1661-
16621660
let sub = match &ty.kind {
16631661
TyKind::Ref(_lifetime, mut_ty) => {
16641662
let lo = mut_ty.ty.span.shrink_to_lo();
16651663
let hi = self.prev_token.span.shrink_to_hi();
16661664
BadTypePlusSub::AddParen { suggestion: AddParen { lo, hi } }
16671665
}
1668-
TyKind::Ptr(..) | TyKind::BareFn(..) => BadTypePlusSub::ForgotParen { span: sum_span },
1669-
_ => BadTypePlusSub::ExpectPath { span: sum_span },
1666+
TyKind::Ptr(..) | TyKind::BareFn(..) => {
1667+
BadTypePlusSub::ForgotParen { span: ty.span.to(self.prev_token.span) }
1668+
}
1669+
_ => BadTypePlusSub::ExpectPath { span: ty.span },
16701670
};
16711671

1672-
self.dcx().emit_err(BadTypePlus { ty: pprust::ty_to_string(ty), span: sum_span, sub });
1672+
self.dcx().emit_err(BadTypePlus { span: ty.span, sub });
16731673

16741674
Ok(())
16751675
}

0 commit comments

Comments
 (0)