diff options
| author | bors <bors@rust-lang.org> | 2025-04-25 18:51:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-25 18:51:15 +0000 |
| commit | b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3 (patch) | |
| tree | eef1aa90a79b32d1ea165af6b54170a3ca6c0468 /compiler | |
| parent | e3e432d4d65a55e6db167598e96db2bcb163e316 (diff) | |
| parent | 99dc43b7178445e3e7eacd10630dfbfadefab560 (diff) | |
| download | rust-b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3.tar.gz rust-b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3.zip | |
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
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 79 | ||||
| -rw-r--r-- | compiler/rustc_span/src/edition.rs | 2 |
5 files changed, 52 insertions, 44 deletions
diff --git a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs index 8be782dcbf0..4aff127908e 100644 --- a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs +++ b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs @@ -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); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index cfc71a412be..7a27bc5c387 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -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; diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 4052264b051..b1b4b9ee927 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -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)] diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 02c164a706c..43955cc23a9 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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("|") ) }); @@ -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}; @@ -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>", ) } diff --git a/compiler/rustc_span/src/edition.rs b/compiler/rustc_span/src/edition.rs index da298080ed2..28335734f4d 100644 --- a/compiler/rustc_span/src/edition.rs +++ b/compiler/rustc_span/src/edition.rs @@ -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; |
