Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a09204a
fix: missing suggestion for string match.
Kokoro2336 May 21, 2026
8495129
Adding sign flag formatting error message
madsravn May 25, 2026
900e061
Removing Suggestion from ParseError and fixed tests accordingly
madsravn May 25, 2026
bc12569
rustdoc: avoid ICE when rendering body-less type consts
reddevilmidzy May 23, 2026
9e96efa
Remove unneeded `#[skip_arg]` attributes
GuillaumeGomez May 25, 2026
9219446
fix issue-144595
bb1yd May 26, 2026
f7c3568
add field_projections fixme
lcnr May 26, 2026
a2b2190
Move check_cfg out of diagnostic attr module
mejrs May 26, 2026
fd0c5f3
Add missing --set rust.codegen-backends=["gcc"] in the gcc codegen Do…
antoyo May 26, 2026
52bedb4
Suppress macOS deployment target linker warnings from ld_prime
cezarbbb May 25, 2026
495657c
Rollup merge of #156796 - Kokoro2336:fix/match-str-sugg, r=estebank
JonathanBrouwer May 27, 2026
b0760d1
Rollup merge of #156933 - madsravn:wrong-order-more, r=estebank
JonathanBrouwer May 27, 2026
806a518
Rollup merge of #156545 - bb1yd:issue-144595, r=mejrs
JonathanBrouwer May 27, 2026
aa9d133
Rollup merge of #156814 - cezarbbb:fix-issue-156714, r=jieyouxu
JonathanBrouwer May 27, 2026
03e935f
Rollup merge of #156851 - reddevilmidzy:mgca-doc, r=GuillaumeGomez
JonathanBrouwer May 27, 2026
241bbc1
Rollup merge of #156942 - GuillaumeGomez:rm-skip_arg-attrs, r=Jonatha…
JonathanBrouwer May 27, 2026
1bc8461
Rollup merge of #156972 - lcnr:field_projections-fixme, r=Nadrieril
JonathanBrouwer May 27, 2026
694ce93
Rollup merge of #156975 - mejrs:move_check_cfg, r=GuillaumeGomez,Jona…
JonathanBrouwer May 27, 2026
a64a3f2
Rollup merge of #156989 - antoyo:fix/cg_gcc-coretests-ci, r=Guillaume…
JonathanBrouwer May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
use thin_vec::ThinVec;

use crate::attributes::AttributeSafety;
use crate::attributes::diagnostic::check_cfg;
use crate::context::{AcceptContext, ShouldEmit};
use crate::parser::{
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
Expand All @@ -29,7 +28,7 @@ use crate::session_diagnostics::{
AttributeParseError, AttributeParseErrorReason, CfgAttrBadDelim, MetaBadDelimSugg,
ParsedDescription,
};
use crate::{AttributeParser, parse_version, session_diagnostics};
use crate::{AttributeParser, check_cfg, parse_version, session_diagnostics};

pub const CFG_TEMPLATE: AttributeTemplate = template!(
List: &["predicate"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::errors::{
};
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};

pub(crate) mod check_cfg;
pub(crate) mod do_not_recommend;
pub(crate) mod on_const;
pub(crate) mod on_move;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ mod interface;
/// like lists or name-value pairs.
pub mod parser;

mod check_cfg;
mod early_parsed;
mod errors;
mod safety;
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,7 @@ pub(crate) enum IncorrectReprFormatGenericCause {
Int {
#[primary_span]
span: Span,

#[skip_arg]
name: Symbol,

#[skip_arg]
value: u128,
},

Expand All @@ -290,11 +286,7 @@ pub(crate) enum IncorrectReprFormatGenericCause {
Symbol {
#[primary_span]
span: Span,

#[skip_arg]
name: Symbol,

#[skip_arg]
value: Symbol,
},
}
Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,15 @@ fn report_linker_output(

// FIXME: Tracked by https://github.com/rust-lang/rust/issues/136113
let deployment_mismatch = |line: &str| {
line.starts_with("ld: warning: object file (")
&& line.contains("was built for newer 'macOS' version")
&& line.contains("than being linked")
// ld64 (object files + dylibs) and ld_prime (object files only):
(line.starts_with("ld: ")
&& line.contains("was built for newer")
&& line.contains("than being linked"))
// ld_prime (Xcode 15+, dylibs only):
|| (line.starts_with("ld: ")
&& line.contains("building for")
&& line.contains("but linking with")
&& line.contains("which was built for newer version"))
};
// FIXME: This is a real warning we would like to show, but it hits too many crates
// to want to turn it on immediately.
Expand Down
17 changes: 16 additions & 1 deletion compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
//
// then that's equivalent to there existing a LUB.
let cause = self.pattern_cause(ti, span);
if let Err(err) = self.demand_suptype_with_origin(&cause, expected, pat_ty) {
if let Err(mut err) = self.demand_suptype_with_origin(&cause, expected, pat_ty) {
// If scrutinee is String and pattern is &str, suggest .as_str()
let expected = self.resolve_vars_with_obligations(expected);
if let ty::Adt(adt, _) = expected.kind()
&& self.tcx.is_lang_item(adt.did(), LangItem::String)
&& pat_ty.is_ref()
&& pat_ty.peel_refs().is_str()
&& let Some(origin_expr) = ti.origin_expr
{
err.span_suggestion_verbose(
origin_expr.span.shrink_to_hi(),
"consider converting the `String` to a `&str` using `.as_str()`",
".as_str()",
Applicability::MachineApplicable,
);
}
err.emit();
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,8 @@ where
predicate: TraitRef::new(ecx.cx(), sized_trait, [ty]).upcast(ecx.cx()),
},
);
// FIXME(field_projections): This function does some questionable incomplete stuff by
// returning `Err(NoSolution)` on ambiguity.
ecx.try_evaluate_added_goals()? == Certainty::Yes
}
&& match base.kind() {
Expand Down
25 changes: 25 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4639,3 +4639,28 @@ pub(crate) struct ReservedMultihashLint {
)]
pub suggestion: Span,
}

#[derive(Subdiagnostic)]
#[suggestion(
"if you meant to write a path, use a double colon:",
code = "::",
applicability = "maybe-incorrect"
)]
pub(crate) struct UseDoubleColonSuggestion {
#[primary_span]
pub colon: Span,
}

#[derive(Subdiagnostic)]
#[multipart_suggestion(
"if you meant to create a regular struct, use curly braces:",
applicability = "maybe-incorrect"
)]
pub(crate) struct UseRegularStructSuggestion {
#[suggestion_part(code = "{{")]
pub open: Span,
#[suggestion_part(code = "}}")]
pub close: Span,
#[suggestion_part(code = "")]
pub semicolon: Option<Span>,
}
27 changes: 23 additions & 4 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use super::{
AllowConstBlockItems, AttrWrapper, ExpKeywordPair, ExpTokenPair, FollowedByType, ForceCollect,
Parser, PathStyle, Recovered, Trailing, UsePreAttrPos,
};
use crate::errors::{self, FnPointerCannotBeAsync, FnPointerCannotBeConst, MacroExpandsToAdtField};
use crate::errors::{
self, FnPointerCannotBeAsync, FnPointerCannotBeConst, MacroExpandsToAdtField,
UseDoubleColonSuggestion, UseRegularStructSuggestion,
};
use crate::exp;

impl<'a> Parser<'a> {
Expand Down Expand Up @@ -2084,10 +2087,11 @@ impl<'a> Parser<'a> {
Safety::Default
}
}

/// This is the case where we find `struct Foo<T>(T) where T: Copy;`
/// Unit like structs are handled in parse_item_struct function
pub(super) fn parse_tuple_struct_body(&mut self) -> PResult<'a, ThinVec<FieldDef>> {
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
// Unit like structs are handled in parse_item_struct function
let openparen_span = self.token.span;
let mut encountered_colon = false;
self.parse_paren_comma_seq(|p| {
let attrs = p.parse_outer_attributes()?;
p.collect_tokens(None, attrs, ForceCollect::No, |p, attrs| {
Expand All @@ -2109,6 +2113,8 @@ impl<'a> Parser<'a> {
}
};
let mut_restriction = p.parse_mut_restriction()?;
encountered_colon |=
p.token.is_ident() && p.look_ahead(1, |tok| tok == &token::Colon);
// Unsafe fields are not supported in tuple structs, as doing so would result in a
// parsing ambiguity for `struct X(unsafe fn())`.
let ty = match p.parse_ty() {
Expand Down Expand Up @@ -2156,6 +2162,19 @@ impl<'a> Parser<'a> {
})
})
.map(|(r, _)| r)
.map_err(|mut error| {
if encountered_colon {
error.subdiagnostic(UseDoubleColonSuggestion { colon: self.token.span });
self.eat_to_tokens(&[exp!(CloseParen)]);
self.bump();
error.subdiagnostic(UseRegularStructSuggestion {
open: openparen_span,
close: self.prev_token.span,
semicolon: if self.token == token::Semi { Some(self.token.span) } else { None },
});
}
error
})
}

/// Parses an element of a struct declaration.
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_parse_format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ impl<'input> Parser<'input> {
('<' | '^' | '>', _) => self.suggest_format_align(c),
(',', _) => self.suggest_unsupported_python_numeric_grouping(),
('=', '}') => self.suggest_rust_debug_printing_macro(),
('+', _) => self.suggest_format_missing_colon_for_sign(),
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
}
}
Expand Down Expand Up @@ -939,6 +940,23 @@ impl<'input> Parser<'input> {
}
}

fn suggest_format_missing_colon_for_sign(&mut self) {
if let Some((range, _)) = self.consume_pos('+') {
self.errors.insert(
0,
ParseError {
description: "the `+` sign flag must appear after `:` in a format string"
.to_owned(),
note: Some("`+` comes after `:`, try `{:+}` instead of `{+}`".to_owned()),
label: "expected `:` before `+` sign flag".to_owned(),
span: range,
secondary_label: None,
suggestion: Suggestion::None,
},
);
}
}

fn suggest_positional_arg_instead_of_captured_arg(&mut self, arg: &Argument<'_>) {
// If the argument is not an identifier, it is not a field access.
if !arg.is_identifier() {
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_parse_format/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,13 @@ fn diagnostic_format_mod() {
assert_eq!(parser.line_spans, &[]);
assert!(parser.errors.is_empty());
}
#[test]
fn format_plus_sign_missing_colon_error() {
// `{+}` should produce an error suggesting `:` before `+`
let mut p = Parser::new("{+}", None, None, false, ParseMode::Format);
let _ = p.by_ref().collect::<Vec<Piece<'static>>>();
assert!(!p.errors.is_empty());
assert!(p.errors[0].description.contains("`+` sign flag must appear after `:`"));
assert!(p.errors[0].label.contains("expected `:` before `+` sign flag"));
assert_eq!(p.errors[0].span, 2..3);
}
9 changes: 0 additions & 9 deletions compiler/rustc_trait_selection/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,6 @@ pub(crate) enum ExplicitLifetimeRequired<'a> {
style = "verbose"
)]
new_ty_span: Span,
#[skip_arg]
new_ty: Ty<'a>,
},
#[diag("explicit lifetime required in parameter type", code = E0621)]
Expand All @@ -885,7 +884,6 @@ pub(crate) enum ExplicitLifetimeRequired<'a> {
style = "verbose"
)]
new_ty_span: Span,
#[skip_arg]
new_ty: Ty<'a>,
},
}
Expand Down Expand Up @@ -1519,7 +1517,6 @@ pub(crate) enum FunctionPointerSuggestion<'a> {
RemoveRef {
#[primary_span]
span: Span,
#[skip_arg]
fn_name: String,
},
#[suggestion(
Expand All @@ -1531,9 +1528,7 @@ pub(crate) enum FunctionPointerSuggestion<'a> {
CastRef {
#[primary_span]
span: Span,
#[skip_arg]
fn_name: String,
#[skip_arg]
sig: Binder<'a, FnSig<'a>>,
},
#[suggestion(
Expand All @@ -1545,7 +1540,6 @@ pub(crate) enum FunctionPointerSuggestion<'a> {
Cast {
#[primary_span]
span: Span,
#[skip_arg]
sig: Binder<'a, FnSig<'a>>,
},
#[suggestion(
Expand All @@ -1557,7 +1551,6 @@ pub(crate) enum FunctionPointerSuggestion<'a> {
CastBoth {
#[primary_span]
span: Span,
#[skip_arg]
found_sig: Binder<'a, FnSig<'a>>,
expected_sig: Binder<'a, FnSig<'a>>,
},
Expand All @@ -1570,9 +1563,7 @@ pub(crate) enum FunctionPointerSuggestion<'a> {
CastBothRef {
#[primary_span]
span: Span,
#[skip_arg]
fn_name: String,
#[skip_arg]
found_sig: Binder<'a, FnSig<'a>>,
expected_sig: Binder<'a, FnSig<'a>>,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ ENV RUST_CONFIGURE_ARGS="--build=x86_64-unknown-linux-gnu \
--set rust.codegen-backends=[\\\"gcc\\\"]"
ENV SCRIPT="python3 ../x.py \
--stage 1 \
test library/coretests"
test library/coretests \
--set rust.codegen-backends=[\\\"gcc\\\"]"
6 changes: 4 additions & 2 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
pub(crate) fn print_const(tcx: TyCtxt<'_>, n: ty::Const<'_>) -> String {
match n.kind() {
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args: _ }) => {
if let Some(def) = def.as_local() {
rendered_const(tcx, tcx.hir_body_owned_by(def), def)
if let Some(def) = def.as_local()
&& let Some(body_id) = tcx.hir_maybe_body_owned_by(def)
{
rendered_const(tcx, body_id, def)
} else {
inline::print_inlined_const(tcx, def)
}
Expand Down
11 changes: 11 additions & 0 deletions tests/run-make/macos-deployment-target-warning/dylib_warnings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
warning: NORMALIZED_DYLIB_DEPLOYMENT_MISMATCH_LINKER_WARNING

|
note: the lint level is defined here
--> main_dylib.rs:1:9
|
1 | #![warn(linker_info, linker_messages)]
| ^^^^^^^^^^^

warning: 1 warning emitted

8 changes: 8 additions & 0 deletions tests/run-make/macos-deployment-target-warning/main_dylib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![warn(linker_info, linker_messages)]
unsafe extern "C" {
safe fn foo();
}

fn main() {
foo();
}
33 changes: 32 additions & 1 deletion tests/run-make/macos-deployment-target-warning/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore-tidy-linelength
//! Tests that deployment target linker warnings are shown as `linker-info`, not `linker-messages`
//! See <https://github.com/rust-lang/rust/issues/156714>

//@ only-macos

Expand All @@ -7,6 +9,12 @@ use run_make_support::external_deps::llvm::llvm_ar;
use run_make_support::{diff, rustc};

fn main() {
let ld64_obj = r"ld: warning: object file \(.*\) was built for newer .+ version \(\d+\.\d+\) than being linked \(\d+\.\d+\)";
let ld_prime_obj = r"ld: warning: object file \(.*\) was built for newer '.+' version \(\d+\.\d+\) than being linked \(\d+\.\d+\)";
let ld64_dylib = r"ld: warning: dylib \(.*\) was built for newer .+ version \(\d+\.\d+\) than being linked \(\d+\.\d+\)";
let ld_prime_dylib = r"ld: warning: building for [^ ,]+, but linking with dylib '[^']*' which was built for newer version [0-9.]+";

// Test 1: static archive (object file mismatch)
cc().arg("-c").arg("-mmacosx-version-min=15.5").output("foo.o").input("foo.c").run();
llvm_ar().obj_to_ar().output_input("libfoo.a", "foo.o").run();

Expand All @@ -21,6 +29,29 @@ fn main() {
diff()
.expected_file("warnings.txt")
.actual_text("(rustc -W linker-info)", &warnings)
.normalize(r"\(.*/rmake_out/", "(TEST_DIR/")
.normalize(ld64_obj, "NORMALIZED_OBJECT_DEPLOYMENT_MISMATCH_LINKER_WARNING")
.normalize(ld_prime_obj, "NORMALIZED_OBJECT_DEPLOYMENT_MISMATCH_LINKER_WARNING")
.run();

// Test 2: shared library (dylib mismatch)
cc().arg("-shared")
.arg("-mmacosx-version-min=15.5")
.output("libbar.dylib")
.input("foo.c")
.run();

let dylib_warnings = rustc()
.arg("-lbar")
.link_arg("-mmacosx-version-min=11.2")
.input("main_dylib.rs")
.crate_type("bin")
.run()
.stderr_utf8();

diff()
.expected_file("dylib_warnings.txt")
.actual_text("(rustc -W linker-info dylib)", &dylib_warnings)
.normalize(ld64_dylib, "NORMALIZED_DYLIB_DEPLOYMENT_MISMATCH_LINKER_WARNING")
.normalize(ld_prime_dylib, "NORMALIZED_DYLIB_DEPLOYMENT_MISMATCH_LINKER_WARNING")
.run();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: ld: warning: object file (TEST_DIR/libfoo.a[2](foo.o)) was built for newer 'macOS' version (15.5) than being linked (11.2)
warning: NORMALIZED_OBJECT_DEPLOYMENT_MISMATCH_LINKER_WARNING

|
note: the lint level is defined here
Expand Down
Loading
Loading