diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e162bcb2b56e..3403745084c5 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2041,8 +2041,16 @@ impl JsonUnusedExterns { /// /// The first value returned is how to render JSON diagnostics, and the second /// is whether or not artifact notifications are enabled. -pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig { - let mut json_rendered = HumanReadableErrorType::Default { short: false }; +pub fn parse_json( + early_dcx: &EarlyDiagCtxt, + matches: &getopts::Matches, + is_nightly_build: bool, +) -> JsonConfig { + let mut json_rendered = if is_nightly_build { + HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false } + } else { + HumanReadableErrorType::Default { short: false } + }; let mut json_color = ColorConfig::Never; let mut json_artifact_notifications = false; let mut json_unused_externs = JsonUnusedExterns::No; @@ -2059,7 +2067,11 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json for sub_option in option.split(',') { match sub_option { "diagnostic-short" => { - json_rendered = HumanReadableErrorType::Default { short: true } + json_rendered = if is_nightly_build { + HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false } + } else { + HumanReadableErrorType::Default { short: true } + }; } "diagnostic-unicode" => { json_rendered = @@ -2093,14 +2105,22 @@ pub fn parse_error_format( color_config: ColorConfig, json_color: ColorConfig, json_rendered: HumanReadableErrorType, + is_nightly_build: bool, ) -> ErrorOutputType { + let default_kind = if is_nightly_build { + HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false } + } else { + HumanReadableErrorType::Default { short: false } + }; // We need the `opts_present` check because the driver will send us Matches // with only stable options if no unstable options are used. Since error-format // is unstable, it will not be present. We have to use `opts_present` not // `opt_present` because the latter will panic. let error_format = if matches.opts_present(&["error-format".to_owned()]) { match matches.opt_str("error-format").as_deref() { - None | Some("human") => ErrorOutputType::HumanReadable { color_config, .. }, + None | Some("human") => { + ErrorOutputType::HumanReadable { color_config, kind: default_kind } + } Some("human-annotate-rs") => ErrorOutputType::HumanReadable { kind: HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false }, color_config, @@ -2112,7 +2132,11 @@ pub fn parse_error_format( ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color } } Some("short") => ErrorOutputType::HumanReadable { - kind: HumanReadableErrorType::Default { short: true }, + kind: if is_nightly_build { + HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false } + } else { + HumanReadableErrorType::Default { short: true } + }, color_config, }, Some("human-unicode") => ErrorOutputType::HumanReadable { @@ -2120,7 +2144,10 @@ pub fn parse_error_format( color_config, }, Some(arg) => { - early_dcx.set_error_format(ErrorOutputType::HumanReadable { color_config, .. }); + early_dcx.set_error_format(ErrorOutputType::HumanReadable { + color_config, + kind: default_kind, + }); early_dcx.early_fatal(format!( "argument for `--error-format` must be `human`, `human-annotate-rs`, \ `human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)" @@ -2128,7 +2155,7 @@ pub fn parse_error_format( } } } else { - ErrorOutputType::HumanReadable { color_config, .. } + ErrorOutputType::HumanReadable { color_config, kind: default_kind } }; match error_format { @@ -2176,9 +2203,10 @@ pub fn parse_crate_edition(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches fn check_error_format_stability( early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions, + is_nightly_build: bool, format: ErrorOutputType, ) { - if unstable_opts.unstable_options { + if unstable_opts.unstable_options || is_nightly_build { return; } let format = match format { @@ -2606,6 +2634,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M let edition = parse_crate_edition(early_dcx, matches); + let crate_name = matches.opt_str("crate-name"); + let unstable_features = UnstableFeatures::from_environment(crate_name.as_deref()); let JsonConfig { json_rendered, json_color, @@ -2613,9 +2643,16 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M json_timings, json_unused_externs, json_future_incompat, - } = parse_json(early_dcx, matches); + } = parse_json(early_dcx, matches, unstable_features.is_nightly_build()); - let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered); + let error_format = parse_error_format( + early_dcx, + matches, + color, + json_color, + json_rendered, + unstable_features.is_nightly_build(), + ); early_dcx.set_error_format(error_format); @@ -2636,7 +2673,12 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M early_dcx.early_fatal("--json=timings is unstable and requires using `-Zunstable-options`"); } - check_error_format_stability(early_dcx, &unstable_opts, error_format); + check_error_format_stability( + early_dcx, + &unstable_opts, + unstable_features.is_nightly_build(), + error_format, + ); let output_types = parse_output_types(early_dcx, &unstable_opts, matches); @@ -2823,8 +2865,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M ) } - let crate_name = matches.opt_str("crate-name"); - let unstable_features = UnstableFeatures::from_environment(crate_name.as_deref()); // Parse any `-l` flags, which link to native libraries. let libs = parse_native_libs(early_dcx, &unstable_opts, unstable_features, matches); diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 55e04671b83c..da19f506a370 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -389,10 +389,19 @@ impl Options { } let color = config::parse_color(early_dcx, matches); + let crate_name = matches.opt_str("crate-name"); + let unstable_features = + rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref()); let config::JsonConfig { json_rendered, json_unused_externs, json_color, .. } = - config::parse_json(early_dcx, matches); - let error_format = - config::parse_error_format(early_dcx, matches, color, json_color, json_rendered); + config::parse_json(early_dcx, matches, unstable_features.is_nightly_build()); + let error_format = config::parse_error_format( + early_dcx, + matches, + color, + json_color, + json_rendered, + unstable_features.is_nightly_build(), + ); let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_default(); let mut target_modifiers = BTreeMap::::new(); @@ -753,7 +762,6 @@ impl Options { } }; - let crate_name = matches.opt_str("crate-name"); let bin_crate = crate_types.contains(&CrateType::Executable); let proc_macro_crate = crate_types.contains(&CrateType::ProcMacro); let playground_url = matches.opt_str("playground-url"); @@ -815,9 +823,6 @@ impl Options { crate::scrape_examples::load_call_locations(with_examples, dcx, &mut loaded_paths); let doctest_build_args = matches.opt_strs("doctest-build-arg"); - let unstable_features = - rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref()); - let disable_minification = matches.opt_present("disable-minification"); let options = Options { diff --git a/src/tools/clippy/tests/ui/bool_assert_comparison.stderr b/src/tools/clippy/tests/ui/bool_assert_comparison.stderr index f823f08f31dc..72aa6303a202 100644 --- a/src/tools/clippy/tests/ui/bool_assert_comparison.stderr +++ b/src/tools/clippy/tests/ui/bool_assert_comparison.stderr @@ -272,10 +272,8 @@ LL | assert_eq!(a!(), true); | help: replace it with `assert!(..)` | -LL | true -... -LL | -LL ~ assert!(a!()); +LL - assert_eq!(a!(), true); +LL + assert!(a!()); | error: used `assert_eq!` with a literal bool @@ -286,10 +284,8 @@ LL | assert_eq!(true, b!()); | help: replace it with `assert!(..)` | -LL | true -... -LL | -LL ~ assert!(b!()); +LL - assert_eq!(true, b!()); +LL + assert!(b!()); | error: used `debug_assert_eq!` with a literal bool diff --git a/tests/crashes/131762.rs b/tests/crashes/131762.rs index 85cb9c8f20a8..4080272226d9 100644 --- a/tests/crashes/131762.rs +++ b/tests/crashes/131762.rs @@ -1,3 +1,4 @@ +//@ needs-rustc-debug-assertions //@ known-bug: #131762 // ignore-tidy-linelength diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout index 65989a8ef47c..1048db07ae95 100644 --- a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout @@ -19,6 +19,7 @@ LL | println!(); error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL | + | ::: $DIR/main-alongside-macro-calls.rs:30:1 | LL | println!(); @@ -41,6 +42,7 @@ LL | println!(); error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL | + | ::: $DIR/main-alongside-macro-calls.rs:34:1 | LL | println!(); diff --git a/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.ascii.stderr b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.ascii.stderr index fe1ecfbe71d4..66d5a808d03c 100644 --- a/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.ascii.stderr +++ b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.ascii.stderr @@ -1,11 +1,11 @@ error[E0369]: cannot add `&str` to `&str` --> $DIR/non-1-width-unicode-multiline-label.rs:8:237 | -LL | ...๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ"; let _a = unicode_is_fun + " really fun!"; - | -------------- ^ -------------- &str - | | | - | | `+` cannot be used to concatenate two `&str` strings - | &str +LL | ... ๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ"; let _a = unicode_is_fun + " really fun!"; + | -------------- ^ -------------- &str + | | | + | | `+` cannot be used to concatenate two `&str` strings + | &str | = note: string concatenation requires an owned `String` on the left help: create an owned `String` from a string reference @@ -16,11 +16,11 @@ LL | let _ = "๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง error[E0369]: cannot add `&str` to `&str` --> $DIR/non-1-width-unicode-multiline-label.rs:10:384 | -LL | ...๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ"; let _a = unicode_is_fun + " really fun!"; - | -------------- ^ -------------- &str - | | | - | | `+` cannot be used to concatenate two `&str` strings - | &str +LL | ... ๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ"; let _a = unicode_is_fun + " really fun!"; + | -------------- ^ -------------- &str + | | | + | | `+` cannot be used to concatenate two `&str` strings + | &str | = note: string concatenation requires an owned `String` on the left help: create an owned `String` from a string reference @@ -31,11 +31,11 @@ LL | let _ = "๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘ฆ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง error[E0369]: cannot add `&str` to `&str` --> $DIR/non-1-width-unicode-multiline-label.rs:12:260 | -LL | ...เฟ‡เฟˆเฟ‰เฟŠเฟ‹เฟŒเฟเฟŽเฟเฟเฟ‘เฟ’เฟ“เฟ”เฟ•เฟ–เฟ—เฟ˜เฟ™เฟš"; let _a = unicode_is_fun + " really fun!"; - | -------------- ^ -------------- &str - | | | - | | `+` cannot be used to concatenate two `&str` strings - | &str +LL | ...เฟ†เฟ‡เฟˆเฟ‰เฟŠเฟ‹เฟŒเฟเฟŽเฟเฟเฟ‘เฟ’เฟ“เฟ”เฟ•เฟ–เฟ—เฟ˜เฟ™เฟš"; let _a = unicode_is_fun + " really fun!"; + | -------------- ^ -------------- &str + | | | + | | `+` cannot be used to concatenate two `&str` strings + | &str | = note: string concatenation requires an owned `String` on the left help: create an owned `String` from a string reference diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr index e74afbfeac47..46369c551cf3 100644 --- a/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr +++ b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr @@ -1,10 +1,10 @@ error[E0308]: mismatched types --> $DIR/non-whitespace-trimming-unicode.rs:5:415 | -LL | ...โ™ฃโ™คโ™ฅโ™ฆโ™งโ™จโ™ฉโ™ชโ™ซโ™ฌโ™ญโ™ฎโ™ฏโ™ฐโ™ฑโ™ฒโ™ณโ™ดโ™ตโ™ถโ™ทโ™ธโ™นโ™บโ™ปโ™ผโ™ฝโ™พโ™ฟโš€โšโš‚โšƒโš„โš…โš†โšˆโš‰4"; let _: () = 42; let _: &str = "๐Ÿฆ€โ˜€โ˜โ˜‚โ˜ƒโ˜„โ˜…โ˜†โ˜‡โ˜ˆโ˜‰โ˜Šโ˜‹โ˜Œโ˜โ˜Žโ˜โ˜โ˜‘โ˜’โ˜“ โ˜–โ˜—โ˜˜โ˜™โ˜šโ˜›โ˜œโ˜โ˜žโ˜Ÿโ˜ โ˜กโ˜ขโ˜ฃโ˜คโ˜ฅโ˜ฆโ˜งโ˜จโ˜ฉโ˜ชโ˜ซโ˜ฌโ˜ญโ˜ฎโ˜ฏโ˜ฐโ˜ฑโ˜ฒโ˜ณโ˜ดโ˜ตโ˜ถโ˜ทโ˜ธโ˜นโ˜บโ˜ปโ˜ผโ˜ฝ ... - | -- ^^ expected `()`, found integer - | | - | expected due to this +LL | ...โ™คโ™ฅโ™ฆโ™งโ™จโ™ฉโ™ชโ™ซโ™ฌโ™ญโ™ฎโ™ฏโ™ฐโ™ฑโ™ฒโ™ณโ™ดโ™ตโ™ถโ™ทโ™ธโ™นโ™บโ™ปโ™ผโ™ฝโ™พโ™ฟโš€โšโš‚โšƒโš„โš…โš†โšˆโš‰4"; let _: () = 42; let _: &str = "๐Ÿฆ€โ˜€โ˜โ˜‚โ˜ƒโ˜„โ˜…โ˜†โ˜‡โ˜ˆโ˜‰โ˜Šโ˜‹โ˜Œโ˜โ˜Žโ˜โ˜โ˜‘โ˜’โ˜“ โ˜–โ˜—โ˜˜โ˜™โ˜šโ˜›โ˜œโ˜โ˜žโ˜Ÿโ˜ โ˜กโ˜ขโ˜ฃโ˜คโ˜ฅโ˜ฆโ˜งโ˜จโ˜ฉโ˜ชโ˜ซโ˜ฌโ˜ญโ˜ฎโ˜ฏโ˜ฐโ˜ฑโ˜ฒโ˜ณ... + | -- ^^ expected `()`, found integer + | | + | expected due to this error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic-width/tabs-trimming.stderr b/tests/ui/diagnostic-width/tabs-trimming.stderr index e0d1c2d95a96..dfda30e6005b 100644 --- a/tests/ui/diagnostic-width/tabs-trimming.stderr +++ b/tests/ui/diagnostic-width/tabs-trimming.stderr @@ -1,20 +1,20 @@ error[E0408]: variable `v` is not bound in all patterns --> $DIR/tabs-trimming.rs:9:16 | -LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT... - | - ^ ^ pattern doesn't bind `v` - | | | - | | pattern doesn't bind `v` - | variable not in all patterns +LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT... + | - ^ ^ pattern doesn't bind `v` + | | | + | | pattern doesn't bind `v` + | variable not in all patterns error[E0381]: used binding `v` is possibly-uninitialized --> $DIR/tabs-trimming.rs:9:67 | -LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT... - | - ^ `v` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - | binding declared here but left uninitialized +LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT... + | - ^ `v` used here but it is possibly-uninitialized + | | + | binding initialized here in some conditions + | binding declared here but left uninitialized error: aborting due to 2 previous errors diff --git a/tests/ui/include-macros/mismatched-types.stderr b/tests/ui/include-macros/mismatched-types.stderr index 8d541966a6a4..4fab832c2d8e 100644 --- a/tests/ui/include-macros/mismatched-types.stderr +++ b/tests/ui/include-macros/mismatched-types.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/file.txt:0:1 | +LL | + | ^ expected `&[u8]`, found `&str` | ::: $DIR/mismatched-types.rs:2:12 | diff --git a/tests/ui/macros/same-sequence-span.stderr b/tests/ui/macros/same-sequence-span.stderr index 1ca89b6b595c..d6652453e9a9 100644 --- a/tests/ui/macros/same-sequence-span.stderr +++ b/tests/ui/macros/same-sequence-span.stderr @@ -17,14 +17,8 @@ LL | $(= $z:tt)* error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments --> $DIR/same-sequence-span.rs:20:1 | -LL | | // `proc_macro_sequence.rs`. - | |_____________________________^not allowed after `expr` fragments -... -LL | proc_macro_sequence::make_foo!(); - | ^------------------------------- - | | - | _in this macro invocation - | | +LL | proc_macro_sequence::make_foo!(); + | -------------------------------- in this macro invocation | = note: allowed there are: `=>`, `,` or `;` = note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index c54f4830533a..f6fa8df45e5e 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -38,10 +38,10 @@ LL | field2: SafeEnum::Variant4("str".to_string()), note: method `to_string` is not const because trait `ToString` is not const --> $SRC_DIR/alloc/src/string.rs:LL:COL | - = note: this trait is not const + = note: this method is not const ::: $SRC_DIR/alloc/src/string.rs:LL:COL | - = note: this method is not const + = note: this trait is not const = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 0b70ac97fd43..747d032dfd4b 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -686,11 +686,12 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | note: method `filter` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | - = note: this trait is not const ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants @@ -701,11 +702,12 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | note: method `map` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | - = note: this trait is not const ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 83 previous errors