Skip to content

Rollup of 8 pull requests #140298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
13303a5
Update the index of Result to make the summary more comprehensive
Natural-selection1 Mar 26, 2025
f8f2330
Solved suggestions
Natural-selection1 Apr 21, 2025
a4630f7
fix ICE in attribute name printing
folkertdev Apr 23, 2025
f86cd70
keep original text for is_ok and is_err
Natural-selection1 Apr 24, 2025
56d5efc
add examples using .as_ref() for is_err_and and is_ok_and
Natural-selection1 Apr 24, 2025
3a14991
fix example
Natural-selection1 Apr 24, 2025
1fd928e
fix doc error
Natural-selection1 Apr 24, 2025
d054690
Unify the format of rustc cli flags
xizheyin Apr 22, 2025
cdc7298
Solved suggestions
Natural-selection1 Apr 25, 2025
49cb451
docs(std): mention const blocks in const keyword doc page
ismailarilik Apr 25, 2025
0e4ffa1
Add a tidy check for GCC submodule version
Kobzol Mar 5, 2025
796a9ee
Update gcc submodule to 0ea98a1365b81f7488073512c850e8ee951a4afd
Kobzol Apr 25, 2025
8604d0f
rustdoc: fix typo change from equivelent to equivalent
styvane Apr 25, 2025
999b906
Add option style comment for `rustc_optgroups`
xizheyin Apr 25, 2025
db2a73e
Cleaned up 5 tests in `tests/ui`
reddevilmidzy Apr 19, 2025
d3a4ebc
remove expect() in unnecessary_transmutes
bend-n Apr 25, 2025
4bbd21b
Rollup merge of #137683 - Kobzol:tidy-gcc-submodule, r=GuillaumeGomez
matthiaskrgr Apr 25, 2025
a353796
Rollup merge of #138968 - Natural-selection1:update-Result-doc, r=Ama…
matthiaskrgr Apr 25, 2025
394cdca
Rollup merge of #139572 - ismailarilik:docs/std/mention-const-blocks-…
matthiaskrgr Apr 25, 2025
eb225e3
Rollup merge of #140152 - xizheyin:issue-140102, r=jieyouxu
matthiaskrgr Apr 25, 2025
7f27d16
Rollup merge of #140193 - folkertdev:fix-issue-140082, r=jdonszelmann
matthiaskrgr Apr 25, 2025
8888488
Rollup merge of #140205 - reddevilmidzy:clean-up-test, r=jieyouxu
matthiaskrgr Apr 25, 2025
4323939
Rollup merge of #140284 - bend-n:fix-expectation-unmet, r=jieyouxu
matthiaskrgr Apr 25, 2025
99dc43b
Rollup merge of #140290 - styvane:patch0001-fix-typo-in-rusdoc-search…
matthiaskrgr Apr 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ impl<'tcx> Visitor<'tcx> for UnnecessaryTransmuteChecker<'_, 'tcx> {
&& let Some((func_def_id, _)) = func.const_fn_def()
&& self.tcx.is_intrinsic(func_def_id, sym::transmute)
&& let span = self.body.source_info(location).span
&& let Some(lint) = self.is_unnecessary_transmute(
func,
self.tcx.sess.source_map().span_to_snippet(arg).expect("ok"),
span,
)
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(arg)
&& let Some(lint) = self.is_unnecessary_transmute(func, snippet, span)
&& let Some(hir_id) = terminator.source_info.scope.lint_root(&self.body.source_scopes)
{
self.tcx.emit_node_span_lint(UNNECESSARY_TRANSMUTES, hir_id, span, lint);
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}

if !other_attr.has_any_name(ALLOW_LIST) {
let path = other_attr.path();
let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
let other_attr_name = path.join("::");

self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
span: other_attr.span(),
naked_span: attr.span(),
attr: other_attr.name().unwrap(),
attr: other_attr_name,
});

return;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ pub(crate) struct NakedFunctionIncompatibleAttribute {
pub span: Span,
#[label(passes_naked_attribute)]
pub naked_span: Span,
pub attr: Symbol,
pub attr: String,
}

#[derive(Diagnostic)]
Expand Down
79 changes: 43 additions & 36 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE
static PRINT_HELP: LazyLock<String> = LazyLock::new(|| {
format!(
"Compiler information to print on stdout (or to a file)\n\
INFO may be one of ({}).",
INFO may be one of <{}>.",
PRINT_KINDS.iter().map(|(name, _)| format!("{name}")).collect::<Vec<_>>().join("|")
)
});
Expand All @@ -1669,6 +1669,13 @@ static EMIT_HELP: LazyLock<String> = LazyLock::new(|| {

/// Returns all rustc command line options, including metadata for
/// each option, such as whether the option is stable.
///
/// # Option style guidelines
///
/// - `<param>`: Indicates a required parameter
/// - `[param]`: Indicates an optional parameter
/// - `|`: Indicates a mutually exclusive option
/// - `*`: a list element with description
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
use OptionKind::{Flag, FlagMulti, Multi, Opt};
use OptionStability::{Stable, Unstable};
Expand All @@ -1683,18 +1690,18 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"cfg",
"Configure the compilation environment.\n\
SPEC supports the syntax `NAME[=\"VALUE\"]`.",
"SPEC",
SPEC supports the syntax `<NAME>[=\"<VALUE>\"]`.",
"<SPEC>",
),
opt(Stable, Multi, "", "check-cfg", "Provide list of expected cfgs for checking", "SPEC"),
opt(Stable, Multi, "", "check-cfg", "Provide list of expected cfgs for checking", "<SPEC>"),
opt(
Stable,
Multi,
"L",
"",
"Add a directory to the library search path. \
The optional KIND can be one of dependency, crate, native, framework, or all (the default).",
"[KIND=]PATH",
The optional KIND can be one of <dependency|crate|native|framework|all> (default: all).",
"[<KIND>=]<PATH>",
),
opt(
Stable,
Expand All @@ -1703,46 +1710,46 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"Link the generated crate(s) to the specified native\n\
library NAME. The optional KIND can be one of\n\
static, framework, or dylib (the default).\n\
<static|framework|dylib> (default: dylib).\n\
Optional comma separated MODIFIERS\n\
(bundle|verbatim|whole-archive|as-needed)\n\
<bundle|verbatim|whole-archive|as-needed>\n\
may be specified each with a prefix of either '+' to\n\
enable or '-' to disable.",
"[KIND[:MODIFIERS]=]NAME[:RENAME]",
"[<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]",
),
make_crate_type_option(),
opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "NAME"),
opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "<NAME>"),
opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST),
opt(Stable, Multi, "", "emit", &EMIT_HELP, "TYPE[=FILE]"),
opt(Stable, Multi, "", "print", &PRINT_HELP, "INFO[=FILE]"),
opt(Stable, Multi, "", "emit", &EMIT_HELP, "<TYPE>[=<FILE>]"),
opt(Stable, Multi, "", "print", &PRINT_HELP, "<INFO>[=<FILE>]"),
opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""),
opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""),
opt(Stable, Opt, "o", "", "Write output to <filename>", "FILENAME"),
opt(Stable, Opt, "", "out-dir", "Write output to compiler-chosen filename in <dir>", "DIR"),
opt(Stable, Opt, "o", "", "Write output to FILENAME", "<FILENAME>"),
opt(Stable, Opt, "", "out-dir", "Write output to compiler-chosen filename in DIR", "<DIR>"),
opt(
Stable,
Opt,
"",
"explain",
"Provide a detailed explanation of an error message",
"OPT",
"<OPT>",
),
opt(Stable, Flag, "", "test", "Build a test harness", ""),
opt(Stable, Opt, "", "target", "Target triple for which the code is compiled", "TARGET"),
opt(Stable, Multi, "A", "allow", "Set lint allowed", "LINT"),
opt(Stable, Multi, "W", "warn", "Set lint warnings", "LINT"),
opt(Stable, Multi, "", "force-warn", "Set lint force-warn", "LINT"),
opt(Stable, Multi, "D", "deny", "Set lint denied", "LINT"),
opt(Stable, Multi, "F", "forbid", "Set lint forbidden", "LINT"),
opt(Stable, Opt, "", "target", "Target triple for which the code is compiled", "<TARGET>"),
opt(Stable, Multi, "A", "allow", "Set lint allowed", "<LINT>"),
opt(Stable, Multi, "W", "warn", "Set lint warnings", "<LINT>"),
opt(Stable, Multi, "", "force-warn", "Set lint force-warn", "<LINT>"),
opt(Stable, Multi, "D", "deny", "Set lint denied", "<LINT>"),
opt(Stable, Multi, "F", "forbid", "Set lint forbidden", "<LINT>"),
opt(
Stable,
Multi,
"",
"cap-lints",
"Set the most restrictive lint level. More restrictive lints are capped at this level",
"LEVEL",
"<LEVEL>",
),
opt(Stable, Multi, "C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
opt(Stable, Multi, "C", "codegen", "Set a codegen option", "<OPT>[=<VALUE>]"),
opt(Stable, Flag, "V", "version", "Print version info and exit", ""),
opt(Stable, Flag, "v", "verbose", "Use verbose output", ""),
];
Expand All @@ -1756,47 +1763,47 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"extern",
"Specify where an external rust library is located",
"NAME[=PATH]",
"<NAME>[=<PATH>]",
),
opt(Stable, Opt, "", "sysroot", "Override the system root", "PATH"),
opt(Unstable, Multi, "Z", "", "Set unstable / perma-unstable options", "FLAG"),
opt(Stable, Opt, "", "sysroot", "Override the system root", "<PATH>"),
opt(Unstable, Multi, "Z", "", "Set unstable / perma-unstable options", "<FLAG>"),
opt(
Stable,
Opt,
"",
"error-format",
"How errors and other messages are produced",
"human|json|short",
"<human|json|short>",
),
opt(Stable, Multi, "", "json", "Configure the JSON output of the compiler", "CONFIG"),
opt(Stable, Multi, "", "json", "Configure the JSON output of the compiler", "<CONFIG>"),
opt(
Stable,
Opt,
"",
"color",
"Configure coloring of output:
auto = colorize, if output goes to a tty (default);
always = always colorize output;
never = never colorize output",
"auto|always|never",
* auto = colorize, if output goes to a tty (default);
* always = always colorize output;
* never = never colorize output",
"<auto|always|never>",
),
opt(
Stable,
Opt,
"",
"diagnostic-width",
"Inform rustc of the width of the output so that diagnostics can be truncated to fit",
"WIDTH",
"<WIDTH>",
),
opt(
Stable,
Multi,
"",
"remap-path-prefix",
"Remap source names in all output (compiler messages and output files)",
"FROM=TO",
"<FROM>=<TO>",
),
opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "VAR=VALUE"),
opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"),
];
options.extend(verbose_only.into_iter().map(|mut opt| {
opt.is_verbose_help_only = true;
Expand Down Expand Up @@ -2796,7 +2803,7 @@ pub fn make_crate_type_option() -> RustcOptGroup {
"crate-type",
"Comma separated list of types of crates
for the compiler to emit",
"[bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]",
"<bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>",
)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub const ALL_EDITIONS: &[Edition] = &[
Edition::EditionFuture,
];

pub const EDITION_NAME_LIST: &str = "2015|2018|2021|2024";
pub const EDITION_NAME_LIST: &str = "<2015|2018|2021|2024|future>";

pub const DEFAULT_EDITION: Edition = Edition::Edition2015;

Expand Down
32 changes: 30 additions & 2 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,14 @@
//! The [`is_ok`] and [`is_err`] methods return [`true`] if the [`Result`]
//! is [`Ok`] or [`Err`], respectively.
//!
//! The [`is_ok_and`] and [`is_err_and`] methods apply the provided function
//! to the contents of the [`Result`] to produce a boolean value. If the [`Result`] does not have the expected variant
//! then [`false`] is returned instead without executing the function.
//!
//! [`is_err`]: Result::is_err
//! [`is_ok`]: Result::is_ok
//! [`is_ok_and`]: Result::is_ok_and
//! [`is_err_and`]: Result::is_err_and
//!
//! ## Adapters for working with references
//!
Expand All @@ -287,6 +293,7 @@
//! (which must implement the [`Default`] trait)
//! * [`unwrap_or_else`] returns the result of evaluating the provided
//! function
//! * [`unwrap_unchecked`] produces *[undefined behavior]*
//!
//! The panicking methods [`expect`] and [`unwrap`] require `E` to
//! implement the [`Debug`] trait.
Expand All @@ -297,17 +304,22 @@
//! [`unwrap_or`]: Result::unwrap_or
//! [`unwrap_or_default`]: Result::unwrap_or_default
//! [`unwrap_or_else`]: Result::unwrap_or_else
//! [`unwrap_unchecked`]: Result::unwrap_unchecked
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
//!
//! These methods extract the contained value in a [`Result<T, E>`] when it
//! is the [`Err`] variant. They require `T` to implement the [`Debug`]
//! trait. If the [`Result`] is [`Ok`]:
//!
//! * [`expect_err`] panics with a provided custom message
//! * [`unwrap_err`] panics with a generic message
//! * [`unwrap_err_unchecked`] produces *[undefined behavior]*
//!
//! [`Debug`]: crate::fmt::Debug
//! [`expect_err`]: Result::expect_err
//! [`unwrap_err`]: Result::unwrap_err
//! [`unwrap_err_unchecked`]: Result::unwrap_err_unchecked
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
//!
//! ## Transforming contained values
//!
Expand All @@ -330,21 +342,29 @@
//! [`Some(v)`]: Option::Some
//! [`transpose`]: Result::transpose
//!
//! This method transforms the contained value of the [`Ok`] variant:
//! These methods transform the contained value of the [`Ok`] variant:
//!
//! * [`map`] transforms [`Result<T, E>`] into [`Result<U, E>`] by applying
//! the provided function to the contained value of [`Ok`] and leaving
//! [`Err`] values unchanged
//! * [`inspect`] takes ownership of the [`Result`], applies the
//! provided function to the contained value by reference,
//! and then returns the [`Result`]
//!
//! [`map`]: Result::map
//! [`inspect`]: Result::inspect
//!
//! This method transforms the contained value of the [`Err`] variant:
//! These methods transform the contained value of the [`Err`] variant:
//!
//! * [`map_err`] transforms [`Result<T, E>`] into [`Result<T, F>`] by
//! applying the provided function to the contained value of [`Err`] and
//! leaving [`Ok`] values unchanged
//! * [`inspect_err`] takes ownership of the [`Result`], applies the
//! provided function to the contained value of [`Err`] by reference,
//! and then returns the [`Result`]
//!
//! [`map_err`]: Result::map_err
//! [`inspect_err`]: Result::inspect_err
//!
//! These methods transform a [`Result<T, E>`] into a value of a possibly
//! different type `U`:
Expand Down Expand Up @@ -578,6 +598,10 @@ impl<T, E> Result<T, E> {
///
/// let x: Result<u32, &str> = Err("hey");
/// assert_eq!(x.is_ok_and(|x| x > 1), false);
///
/// let x: Result<String, &str> = Ok("ownership".to_string());
/// assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]
Expand Down Expand Up @@ -623,6 +647,10 @@ impl<T, E> Result<T, E> {
///
/// let x: Result<u32, Error> = Ok(123);
/// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);
///
/// let x: Result<u32, String> = Err("ownership".to_string());
/// assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]
Expand Down
9 changes: 8 additions & 1 deletion library/std/src/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod break_keyword {}

#[doc(keyword = "const")]
//
/// Compile-time constants, compile-time evaluable functions, and raw pointers.
/// Compile-time constants, compile-time blocks, compile-time evaluable functions, and raw pointers.
///
/// ## Compile-time constants
///
Expand Down Expand Up @@ -166,6 +166,12 @@ mod break_keyword {}
///
/// For more detail on `const`, see the [Rust Book] or the [Reference].
///
/// ## Compile-time blocks
///
/// The `const` keyword can also be used to define a block of code that is evaluated at compile time.
/// This is useful for ensuring certain computations are completed before optimizations happen, as well as
/// before runtime. For more details, see the [Reference][const-blocks].
///
/// ## Compile-time evaluable functions
///
/// The other main use of the `const` keyword is in `const fn`. This marks a function as being
Expand All @@ -184,6 +190,7 @@ mod break_keyword {}
/// [pointer primitive]: pointer
/// [Rust Book]: ../book/ch03-01-variables-and-mutability.html#constants
/// [Reference]: ../reference/items/constant-items.html
/// [const-blocks]: ../reference/expressions/block-expr.html#const-blocks
/// [const-eval]: ../reference/const_eval.html
mod const_keyword {}

Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/read-documentation/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ the standard library and functions that are included in the results list:

### Non-functions in type-based search
Certain items that are not functions are treated as though they
were a semantically equivelent function.
were a semantically equivalent function.

For example, struct fields are treated as though they were getter methods.
This means that a search for `CpuidResult -> u32` will show
Expand Down
2 changes: 1 addition & 1 deletion src/gcc
Submodule gcc updated 29018 files
Loading
Loading