Skip to content

Commit 0298975

Browse files
committed
attempt to stabilize annotate snippet
1 parent 8188f6c commit 0298975

File tree

11 files changed

+13
-76
lines changed

11 files changed

+13
-76
lines changed

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,6 @@ impl AnnotateSnippetEmitter {
303303
}
304304
}
305305

306-
let suggestions_expected = suggestions
307-
.iter()
308-
.filter(|s| {
309-
matches!(
310-
s.style,
311-
SuggestionStyle::HideCodeInline
312-
| SuggestionStyle::ShowCode
313-
| SuggestionStyle::ShowAlways
314-
)
315-
})
316-
.count();
317306
for suggestion in suggestions {
318307
match suggestion.style {
319308
SuggestionStyle::CompletelyHidden => {
@@ -526,12 +515,6 @@ impl AnnotateSnippetEmitter {
526515
}
527516
}
528517

529-
// FIXME: This hack should be removed once annotate_snippets is the
530-
// default emitter.
531-
if suggestions_expected > 0 && report.is_empty() {
532-
group = group.element(Padding);
533-
}
534-
535518
if !group.is_empty() {
536519
report.push(group);
537520
}

compiler/rustc_session/src/config.rs

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ pub enum ErrorOutputType {
806806
/// Output meant for the consumption of humans.
807807
#[default]
808808
HumanReadable {
809-
kind: HumanReadableErrorType = HumanReadableErrorType::Default { short: false },
809+
kind: HumanReadableErrorType = HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false },
810810
color_config: ColorConfig = ColorConfig::Auto,
811811
},
812812
/// Output that's consumed by other tools such as `rustfix` or the `RLS`.
@@ -1965,16 +1965,9 @@ impl JsonUnusedExterns {
19651965
///
19661966
/// The first value returned is how to render JSON diagnostics, and the second
19671967
/// is whether or not artifact notifications are enabled.
1968-
pub fn parse_json(
1969-
early_dcx: &EarlyDiagCtxt,
1970-
matches: &getopts::Matches,
1971-
is_nightly_build: bool,
1972-
) -> JsonConfig {
1973-
let mut json_rendered = if is_nightly_build {
1974-
HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false }
1975-
} else {
1976-
HumanReadableErrorType::Default { short: false }
1977-
};
1968+
pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
1969+
let mut json_rendered =
1970+
HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false };
19781971
let mut json_color = ColorConfig::Never;
19791972
let mut json_artifact_notifications = false;
19801973
let mut json_unused_externs = JsonUnusedExterns::No;
@@ -1991,11 +1984,8 @@ pub fn parse_json(
19911984
for sub_option in option.split(',') {
19921985
match sub_option {
19931986
"diagnostic-short" => {
1994-
json_rendered = if is_nightly_build {
1995-
HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false }
1996-
} else {
1997-
HumanReadableErrorType::Default { short: true }
1998-
};
1987+
json_rendered =
1988+
HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false };
19991989
}
20001990
"diagnostic-unicode" => {
20011991
json_rendered =
@@ -2029,13 +2019,8 @@ pub fn parse_error_format(
20292019
color_config: ColorConfig,
20302020
json_color: ColorConfig,
20312021
json_rendered: HumanReadableErrorType,
2032-
is_nightly_build: bool,
20332022
) -> ErrorOutputType {
2034-
let default_kind = if is_nightly_build {
2035-
HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false }
2036-
} else {
2037-
HumanReadableErrorType::Default { short: false }
2038-
};
2023+
let default_kind = HumanReadableErrorType::AnnotateSnippet { short: false, unicode: false };
20392024
// We need the `opts_present` check because the driver will send us Matches
20402025
// with only stable options if no unstable options are used. Since error-format
20412026
// is unstable, it will not be present. We have to use `opts_present` not
@@ -2056,11 +2041,7 @@ pub fn parse_error_format(
20562041
ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
20572042
}
20582043
Some("short") => ErrorOutputType::HumanReadable {
2059-
kind: if is_nightly_build {
2060-
HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false }
2061-
} else {
2062-
HumanReadableErrorType::Default { short: true }
2063-
},
2044+
kind: HumanReadableErrorType::AnnotateSnippet { short: true, unicode: false },
20642045
color_config,
20652046
},
20662047
Some("human-unicode") => ErrorOutputType::HumanReadable {
@@ -2135,11 +2116,6 @@ fn check_error_format_stability(
21352116
}
21362117
let format = match format {
21372118
ErrorOutputType::Json { pretty: true, .. } => "pretty-json",
2138-
ErrorOutputType::HumanReadable { kind, .. } => match kind {
2139-
HumanReadableErrorType::AnnotateSnippet { unicode: false, .. } => "human-annotate-rs",
2140-
HumanReadableErrorType::AnnotateSnippet { unicode: true, .. } => "human-unicode",
2141-
_ => return,
2142-
},
21432119
_ => return,
21442120
};
21452121
early_dcx.early_fatal(format!("`--error-format={format}` is unstable"))
@@ -2465,16 +2441,9 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
24652441
json_timings,
24662442
json_unused_externs,
24672443
json_future_incompat,
2468-
} = parse_json(early_dcx, matches, unstable_features.is_nightly_build());
2444+
} = parse_json(early_dcx, matches);
24692445

2470-
let error_format = parse_error_format(
2471-
early_dcx,
2472-
matches,
2473-
color,
2474-
json_color,
2475-
json_rendered,
2476-
unstable_features.is_nightly_build(),
2477-
);
2446+
let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered);
24782447

24792448
early_dcx.set_error_format(error_format);
24802449

src/librustdoc/config.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,9 @@ impl Options {
404404
let unstable_features =
405405
rustc_feature::UnstableFeatures::from_environment(crate_name.as_deref());
406406
let config::JsonConfig { json_rendered, json_unused_externs, json_color, .. } =
407-
config::parse_json(early_dcx, matches, unstable_features.is_nightly_build());
408-
let error_format = config::parse_error_format(
409-
early_dcx,
410-
matches,
411-
color,
412-
json_color,
413-
json_rendered,
414-
unstable_features.is_nightly_build(),
415-
);
407+
config::parse_json(early_dcx, matches);
408+
let error_format =
409+
config::parse_error_format(early_dcx, matches, color, json_color, json_rendered);
416410
let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_default();
417411

418412
let mut target_modifiers = BTreeMap::<OptionsTargetModifiers, String>::new();

tests/ui/attributes/crate-type-delimited.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | #![crate_type(lib)]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8-
|
98

109
error: aborting due to 1 previous error
1110

tests/ui/attributes/crate-type-empty.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | #![crate_type]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8-
|
98

109
error: aborting due to 1 previous error
1110

tests/ui/attributes/crate-type-macro-call.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | #![crate_type = foo!()]
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html>
8-
|
98

109
error: aborting due to 1 previous error
1110

tests/ui/const-generics/generic_const_exprs/issue-105608.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ error[E0282]: type annotations needed
33
|
44
LL | Combination::<0>.and::<_>().and::<_>();
55
| ^^^ cannot infer type of the type parameter `M` declared on the method `and`
6-
|
76

87
error: aborting due to 1 previous error
98

tests/ui/delegation/ice-line-bounds-issue-148732.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | dbg!(b);
55
| ^^^^^^^ expected named lifetime parameter
66
|
77
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
8-
|
98

109
error[E0425]: cannot find function `a` in this scope
1110
--> $DIR/ice-line-bounds-issue-148732.rs:1:7

tests/ui/macros/cfg_select.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ error[E0539]: malformed `cfg_select` macro input
3838
|
3939
LL | "str" => {}
4040
| ^^^^^ expected a valid identifier here
41-
|
4241

4342
error[E0539]: malformed `cfg_select` macro input
4443
--> $DIR/cfg_select.rs:80:5
4544
|
4645
LL | a::b => {}
4746
| ^^^^ expected a valid identifier here
48-
|
4947

5048
error[E0537]: invalid predicate `a`
5149
--> $DIR/cfg_select.rs:85:5

tests/ui/span/issue-42234-unknown-receiver-type.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ error[E0282]: type annotations needed
1616
|
1717
LL | .sum::<_>()
1818
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
19-
|
2019

2120
error: aborting due to 2 previous errors
2221

0 commit comments

Comments
 (0)