Auto merge of #140298 - matthiaskrgr:rollup-5tc1gvb, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #137683 (Add a tidy check for GCC submodule version)
 - #138968 (Update the index of Result to make the summary more comprehensive)
 - #139572 (docs(std): mention const blocks in const keyword doc page)
 - #140152 (Unify the format of rustc cli flags)
 - #140193 (fix ICE in `#[naked]` attribute validation)
 - #140205 (Tidying up UI tests [2/N])
 - #140284 (remove expect() in `unnecessary_transmutes`)
 - #140290 (rustdoc: fix typo change from equivelent to equivalent)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors
2025-04-25 18:51:15 +00:00
34 changed files with 318 additions and 169 deletions
@@ -87,11 +87,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
&& 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);
+5 -1
View File
@@ -680,10 +680,14 @@ fn check_naked(
}
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;
+1 -1
View File
@@ -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)]
+43 -36
View File
@@ -1650,7 +1650,7 @@ pub fn make_opt(
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("|")
)
});
@@ -1669,6 +1669,13 @@ pub fn make_opt(
/// 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};
@@ -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,
@@ -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", ""),
];
@@ -1756,29 +1763,29 @@ 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,
@@ -1786,7 +1793,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"diagnostic-width",
"Inform rustc of the width of the output so that diagnostics can be truncated to fit",
"WIDTH",
"<WIDTH>",
),
opt(
Stable,
@@ -1794,9 +1801,9 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"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;
@@ -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>",
)
}
+1 -1
View File
@@ -45,7 +45,7 @@ pub enum 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;
+30 -2
View File
@@ -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
//!
@@ -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.
@@ -297,6 +304,8 @@
//! [`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`]
@@ -304,10 +313,13 @@
//!
//! * [`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
//!
@@ -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`:
@@ -578,6 +598,10 @@ pub const fn is_ok(&self) -> bool {
///
/// 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]
@@ -623,6 +647,10 @@ pub const fn is_err(&self) -> bool {
///
/// 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]
+8 -1
View File
@@ -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
///
@@ -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
@@ -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 {}
@@ -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
+1 -1
Submodule src/gcc updated: 13cc824322...0ea98a1365
+47
View File
@@ -0,0 +1,47 @@
//! Tidy check to ensure that the commit SHA of the `src/gcc` submodule is the same as the
//! required GCC version of the GCC codegen backend.
use std::path::Path;
use std::process::Command;
pub fn check(root_path: &Path, compiler_path: &Path, bad: &mut bool) {
let cg_gcc_version_path = compiler_path.join("rustc_codegen_gcc/libgccjit.version");
let cg_gcc_version = std::fs::read_to_string(&cg_gcc_version_path)
.expect(&format!("Cannot read GCC version from {}", cg_gcc_version_path.display()))
.trim()
.to_string();
let git_output = Command::new("git")
.current_dir(root_path)
.arg("submodule")
.arg("status")
// --cached asks for the version that is actually committed in the repository, not the one
// that is currently checked out.
.arg("--cached")
.arg("src/gcc")
.output()
.expect("Cannot determine git SHA of the src/gcc checkout");
// This can return e.g.
// -e607be166673a8de9fc07f6f02c60426e556c5f2 src/gcc
// e607be166673a8de9fc07f6f02c60426e556c5f2 src/gcc (master-e607be166673a8de9fc07f6f02c60426e556c5f2.e607be)
// +e607be166673a8de9fc07f6f02c60426e556c5f2 src/gcc (master-e607be166673a8de9fc07f6f02c60426e556c5f2.e607be)
let git_output = String::from_utf8_lossy(&git_output.stdout)
.trim()
.split_whitespace()
.next()
.unwrap_or_default()
.to_string();
// The SHA can start with + if the submodule is modified or - if it is not checked out.
let gcc_submodule_sha = git_output.trim_start_matches(&['+', '-']);
if gcc_submodule_sha != cg_gcc_version {
*bad = true;
eprintln!(
r#"Commit SHA of the src/gcc submodule (`{gcc_submodule_sha}`) does not match the required GCC version of the GCC codegen backend (`{cg_gcc_version}`).
Make sure to set the src/gcc submodule to commit {cg_gcc_version}.
The GCC codegen backend commit is configured at {}."#,
cg_gcc_version_path.display(),
);
}
}
+1
View File
@@ -75,6 +75,7 @@ fn tidy_error(args: &str) -> std::io::Result<()> {
pub mod fluent_alphabetical;
pub mod fluent_period;
mod fluent_used;
pub mod gcc_submodule;
pub(crate) mod iter_header;
pub mod known_bug;
pub mod mir_opt_tests;
+1
View File
@@ -116,6 +116,7 @@ macro_rules! check {
check!(fluent_alphabetical, &compiler_path, bless);
check!(fluent_period, &compiler_path);
check!(target_policy, &root_path);
check!(gcc_submodule, &root_path, &compiler_path);
// Checks that only make sense for the std libs.
check!(pal, &library_path);
+12 -11
View File
@@ -1,22 +1,23 @@
@@ -63,10 +63,27 @@
@@ -65,10 +65,28 @@
Set a codegen option
-V, --version Print version info and exit
-v, --verbose Use verbose output
+ --extern NAME[=PATH]
+ --extern <NAME>[=<PATH>]
+ Specify where an external rust library is located
+ --sysroot PATH Override the system root
+ --error-format human|json|short
+ --sysroot <PATH>
+ Override the system root
+ --error-format <human|json|short>
+ How errors and other messages are produced
+ --json CONFIG Configure the JSON output of the compiler
+ --color auto|always|never
+ --json <CONFIG> Configure the JSON output of the compiler
+ --color <auto|always|never>
+ Configure coloring of output:
+ auto = colorize, if output goes to a tty (default);
+ always = always colorize output;
+ never = never colorize output
+ --diagnostic-width WIDTH
+ * auto = colorize, if output goes to a tty (default);
+ * always = always colorize output;
+ * never = never colorize output
+ --diagnostic-width <WIDTH>
+ Inform rustc of the width of the output so that
+ diagnostics can be truncated to fit
+ --remap-path-prefix FROM=TO
+ --remap-path-prefix <FROM>=<TO>
+ Remap source names in all output (compiler messages
+ and output files)
+ @path Read newline separated options from `path`
+39 -36
View File
@@ -2,31 +2,32 @@ Usage: rustc [OPTIONS] INPUT
Options:
-h, --help Display this message
--cfg SPEC Configure the compilation environment.
SPEC supports the syntax `NAME[="VALUE"]`.
--check-cfg SPEC
--cfg <SPEC> Configure the compilation environment.
SPEC supports the syntax `<NAME>[="<VALUE>"]`.
--check-cfg <SPEC>
Provide list of expected cfgs for checking
-L [KIND=]PATH Add a directory to the library search path. The
optional KIND can be one of dependency, crate, native,
framework, or all (the default).
-l [KIND[:MODIFIERS]=]NAME[:RENAME]
-L [<KIND>=]<PATH> Add a directory to the library search path. The
optional KIND can be one of
<dependency|crate|native|framework|all> (default:
all).
-l [<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]
Link the generated crate(s) to the specified native
library NAME. The optional KIND can be one of
static, framework, or dylib (the default).
<static|framework|dylib> (default: dylib).
Optional comma separated MODIFIERS
(bundle|verbatim|whole-archive|as-needed)
<bundle|verbatim|whole-archive|as-needed>
may be specified each with a prefix of either '+' to
enable or '-' to disable.
--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]
--crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>
Comma separated list of types of crates
for the compiler to emit
--crate-name NAME
--crate-name <NAME>
Specify the name of the crate being built
--edition 2015|2018|2021|2024
--edition <2015|2018|2021|2024|future>
Specify which edition of the compiler to use when
compiling code. The default is 2015 and the latest
stable edition is 2024.
--emit TYPE[=FILE]
--emit <TYPE>[=<FILE>]
Comma separated list of types of output for the
compiler to emit.
Each TYPE has the default FILE name:
@@ -39,45 +40,47 @@ Options:
* mir - CRATE_NAME.mir
* obj - CRATE_NAME.o
* thin-link-bitcode - CRATE_NAME.indexing.o
--print INFO[=FILE]
--print <INFO>[=<FILE>]
Compiler information to print on stdout (or to a file)
INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).
<all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>.
-g Equivalent to -C debuginfo=2
-O Equivalent to -C opt-level=3
-o FILENAME Write output to <filename>
--out-dir DIR Write output to compiler-chosen filename in <dir>
--explain OPT Provide a detailed explanation of an error message
-o <FILENAME> Write output to FILENAME
--out-dir <DIR> Write output to compiler-chosen filename in DIR
--explain <OPT> Provide a detailed explanation of an error message
--test Build a test harness
--target TARGET Target triple for which the code is compiled
-A, --allow LINT Set lint allowed
-W, --warn LINT Set lint warnings
--force-warn LINT
--target <TARGET>
Target triple for which the code is compiled
-A, --allow <LINT> Set lint allowed
-W, --warn <LINT> Set lint warnings
--force-warn <LINT>
Set lint force-warn
-D, --deny LINT Set lint denied
-F, --forbid LINT Set lint forbidden
--cap-lints LEVEL
-D, --deny <LINT> Set lint denied
-F, --forbid <LINT> Set lint forbidden
--cap-lints <LEVEL>
Set the most restrictive lint level. More restrictive
lints are capped at this level
-C, --codegen OPT[=VALUE]
-C, --codegen <OPT>[=<VALUE>]
Set a codegen option
-V, --version Print version info and exit
-v, --verbose Use verbose output
--extern NAME[=PATH]
--extern <NAME>[=<PATH>]
Specify where an external rust library is located
--sysroot PATH Override the system root
--error-format human|json|short
--sysroot <PATH>
Override the system root
--error-format <human|json|short>
How errors and other messages are produced
--json CONFIG Configure the JSON output of the compiler
--color auto|always|never
--json <CONFIG> Configure the JSON output of the compiler
--color <auto|always|never>
Configure coloring of output:
auto = colorize, if output goes to a tty (default);
always = always colorize output;
never = never colorize output
--diagnostic-width WIDTH
* auto = colorize, if output goes to a tty (default);
* always = always colorize output;
* never = never colorize output
--diagnostic-width <WIDTH>
Inform rustc of the width of the output so that
diagnostics can be truncated to fit
--remap-path-prefix FROM=TO
--remap-path-prefix <FROM>=<TO>
Remap source names in all output (compiler messages
and output files)
@path Read newline separated options from `path`
+28 -26
View File
@@ -2,31 +2,32 @@ Usage: rustc [OPTIONS] INPUT
Options:
-h, --help Display this message
--cfg SPEC Configure the compilation environment.
SPEC supports the syntax `NAME[="VALUE"]`.
--check-cfg SPEC
--cfg <SPEC> Configure the compilation environment.
SPEC supports the syntax `<NAME>[="<VALUE>"]`.
--check-cfg <SPEC>
Provide list of expected cfgs for checking
-L [KIND=]PATH Add a directory to the library search path. The
optional KIND can be one of dependency, crate, native,
framework, or all (the default).
-l [KIND[:MODIFIERS]=]NAME[:RENAME]
-L [<KIND>=]<PATH> Add a directory to the library search path. The
optional KIND can be one of
<dependency|crate|native|framework|all> (default:
all).
-l [<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]
Link the generated crate(s) to the specified native
library NAME. The optional KIND can be one of
static, framework, or dylib (the default).
<static|framework|dylib> (default: dylib).
Optional comma separated MODIFIERS
(bundle|verbatim|whole-archive|as-needed)
<bundle|verbatim|whole-archive|as-needed>
may be specified each with a prefix of either '+' to
enable or '-' to disable.
--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]
--crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>
Comma separated list of types of crates
for the compiler to emit
--crate-name NAME
--crate-name <NAME>
Specify the name of the crate being built
--edition 2015|2018|2021|2024
--edition <2015|2018|2021|2024|future>
Specify which edition of the compiler to use when
compiling code. The default is 2015 and the latest
stable edition is 2024.
--emit TYPE[=FILE]
--emit <TYPE>[=<FILE>]
Comma separated list of types of output for the
compiler to emit.
Each TYPE has the default FILE name:
@@ -39,27 +40,28 @@ Options:
* mir - CRATE_NAME.mir
* obj - CRATE_NAME.o
* thin-link-bitcode - CRATE_NAME.indexing.o
--print INFO[=FILE]
--print <INFO>[=<FILE>]
Compiler information to print on stdout (or to a file)
INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).
<all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>.
-g Equivalent to -C debuginfo=2
-O Equivalent to -C opt-level=3
-o FILENAME Write output to <filename>
--out-dir DIR Write output to compiler-chosen filename in <dir>
--explain OPT Provide a detailed explanation of an error message
-o <FILENAME> Write output to FILENAME
--out-dir <DIR> Write output to compiler-chosen filename in DIR
--explain <OPT> Provide a detailed explanation of an error message
--test Build a test harness
--target TARGET Target triple for which the code is compiled
-A, --allow LINT Set lint allowed
-W, --warn LINT Set lint warnings
--force-warn LINT
--target <TARGET>
Target triple for which the code is compiled
-A, --allow <LINT> Set lint allowed
-W, --warn <LINT> Set lint warnings
--force-warn <LINT>
Set lint force-warn
-D, --deny LINT Set lint denied
-F, --forbid LINT Set lint forbidden
--cap-lints LEVEL
-D, --deny <LINT> Set lint denied
-F, --forbid <LINT> Set lint forbidden
--cap-lints <LEVEL>
Set the most restrictive lint level. More restrictive
lints are capped at this level
-C, --codegen OPT[=VALUE]
-C, --codegen <OPT>[=<VALUE>]
Set a codegen option
-V, --version Print version info and exit
-v, --verbose Use verbose output
@@ -11,7 +11,7 @@ Options:
-o, --out-dir PATH which directory to place the output
--crate-name NAME
specify the name of this crate
--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]
--crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>
Comma separated list of types of crates
for the compiler to emit
-L, --library-path DIR
+9
View File
@@ -51,3 +51,12 @@ fn main() {
#[unsafe(naked)] //~ ERROR should be applied to a function definition
|| {};
}
// Check that the path of an attribute without a name is printed correctly (issue #140082)
#[::a]
//~^ ERROR attribute incompatible with `#[unsafe(naked)]`
//~| ERROR failed to resolve: use of unresolved module or unlinked crate `a`
#[unsafe(naked)]
extern "C" fn issue_140082() {
naked_asm!("")
}
+18 -1
View File
@@ -1,3 +1,9 @@
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a`
--> $DIR/naked-invalid-attr.rs:56:5
|
LL | #[::a]
| ^ use of unresolved module or unlinked crate `a`
error: attribute should be applied to a function definition
--> $DIR/naked-invalid-attr.rs:13:1
|
@@ -27,6 +33,15 @@ LL | #[unsafe(naked)]
LL | || {};
| ----- not a function definition
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
--> $DIR/naked-invalid-attr.rs:56:1
|
LL | #[::a]
| ^^^^^^ the `{{root}}::a` attribute is incompatible with `#[unsafe(naked)]`
...
LL | #[unsafe(naked)]
| ---------------- function marked with `#[unsafe(naked)]` here
error: attribute should be applied to a function definition
--> $DIR/naked-invalid-attr.rs:22:5
|
@@ -49,5 +64,7 @@ error: attribute should be applied to a function definition
LL | #![unsafe(naked)]
| ^^^^^^^^^^^^^^^^^ cannot be applied to crates
error: aborting due to 6 previous errors
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0433, E0736.
For more information about an error, try `rustc --explain E0433`.
@@ -1,5 +1,5 @@
error: Argument to option 'cap-lints' missing
Usage:
--cap-lints LEVEL Set the most restrictive lint level. More restrictive
--cap-lints <LEVEL> Set the most restrictive lint level. More restrictive
lints are capped at this level
-21
View File
@@ -1,21 +0,0 @@
#[derive(Debug)]
struct Foo {
i: isize,
}
impl Drop for Foo {
fn drop(&mut self) {}
}
fn foo(i:isize) -> Foo {
Foo {
i: i
}
}
fn main() {
let x = foo(10);
let _y = x.clone();
//~^ ERROR no method named `clone` found
println!("{:?}", x);
}
@@ -1,6 +1,7 @@
error: Argument to option 'emit' missing
Usage:
--emit TYPE[=FILE] Comma separated list of types of output for the
--emit <TYPE>[=<FILE>]
Comma separated list of types of output for the
compiler to emit.
Each TYPE has the default FILE name:
* asm - CRATE_NAME.s
@@ -1,6 +1,7 @@
error: Argument to option 'print' missing
Usage:
--print INFO[=FILE] Compiler information to print on stdout (or to a file)
--print <INFO>[=<FILE>]
Compiler information to print on stdout (or to a file)
INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).
<all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>.
@@ -1,5 +1,5 @@
error: no rules expected `@`
--> $DIR/fail-simple.rs:2:12
--> $DIR/no-matching-rule.rs:2:12
|
LL | panic!(@);
| ^ no rules expected this token in macro call
+19
View File
@@ -0,0 +1,19 @@
// This test checks that calling `.clone()` on a type that does not implement the `Clone` trait
// results in a compilation error. The `Foo` struct does not derive or implement `Clone`,
// so attempting to clone it should fail.
struct Foo {
i: isize,
}
fn foo(i:isize) -> Foo {
Foo {
i: i
}
}
fn main() {
let x = foo(10);
let _y = x.clone();
//~^ ERROR no method named `clone` found
}
@@ -1,5 +1,5 @@
error[E0599]: no method named `clone` found for struct `Foo` in the current scope
--> $DIR/copy-a-resource.rs:18:16
--> $DIR/clone-missing.rs:17:16
|
LL | struct Foo {
| ---------- method `clone` not found for this struct
+11
View File
@@ -0,0 +1,11 @@
//@ run-pass
// This is a name resolution smoke test that ensures paths with more than one
// segment (e.g., `foo::bar`) resolve correctly.
// It also serves as a basic visibility test — confirming that a `pub` item
// inside a private module can still be accessed from outside that module.
mod foo {
pub fn bar(_offset: usize) {}
}
fn main() { foo::bar(0); }
-7
View File
@@ -1,7 +0,0 @@
//@ run-pass
mod foo {
pub fn bar(_offset: usize) { }
}
pub fn main() { foo::bar(0); }
@@ -1,5 +1,5 @@
error[E0434]: can't capture dynamic environment in a fn item
--> $DIR/capture1.rs:3:32
--> $DIR/fn-item-cant-capture-dynamic-env.rs:3:32
|
LL | fn foo() -> isize { return bar; }
| ^^^
@@ -0,0 +1,10 @@
//@ compile-flags: --remap-path-prefix=/=/non-existent
// helper for ../unnecessary-transmute-path-remap-ice-140277.rs
#[macro_export]
macro_rules! transmute {
($e:expr) => {{
let e = $e;
std::mem::transmute(e)
}};
}
@@ -0,0 +1,10 @@
//@ aux-crate: zerocopy=unnecessary-transmute-path-remap-ice-140277-trans.rs
//@ check-pass
// tests for a regression in linting for unnecessary transmutes
// where a span was inacessible for snippet procuring,
// when remap-path-prefix was set, causing a panic.
fn bytes_at_home(x: [u8; 4]) -> u32 {
unsafe { zerocopy::transmute!(x) }
}
fn main() {}
+11
View File
@@ -0,0 +1,11 @@
//@ run-pass
// This is a smoke test to ensure that type aliases with type parameters
// are accepted by the compiler and that the parameters are correctly
// resolved in the aliased item type.
#![allow(dead_code)]
type Foo<T> = extern "C" fn(T) -> bool;
type Bar<T> = fn(T) -> bool;
fn main() {}
-10
View File
@@ -1,10 +0,0 @@
//@ run-pass
#![allow(non_camel_case_types)]
#![allow(dead_code)]
type lteq<T> = extern "C" fn(T) -> bool;
pub fn main() { }