Skip to content

Commit

Permalink
#3390: hide_parse_errors to show_parse_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
llesha committed Nov 10, 2023
1 parent 37489e4 commit 693365c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ create_config! {
"Enables unstable features. Only available on nightly channel";
disable_all_formatting: bool, false, true, "Don't reformat anything";
skip_children: bool, false, false, "Don't reformat out of line modules";
hide_parse_errors: bool, false, false, "Hide errors from the parser";
show_parse_errors: bool, true, true, "Show errors from the parser";
hide_parse_errors: bool, false, false, "(deprecated: use show_parse_errors instead)";
error_on_line_overflow: bool, false, false, "Error if unable to get all lines within max_width";
error_on_unformatted: bool, false, false,
"Error if unable to get comments or string literals within max_width, \
Expand Down
16 changes: 13 additions & 3 deletions src/parse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn default_handler(
source_map: Lrc<SourceMap>,
ignore_path_set: Lrc<IgnorePathSet>,
can_reset: Lrc<AtomicBool>,
hide_parse_errors: bool,
show_parse_errors: bool,
color: Color,
) -> Handler {
let supports_color = term::stderr().map_or(false, |term| term.supports_color());
Expand All @@ -132,7 +132,7 @@ fn default_handler(
ColorConfig::Never
};

let emitter = if hide_parse_errors {
let emitter = if !show_parse_errors {
silent_emitter()
} else {
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
Expand All @@ -159,11 +159,21 @@ impl ParseSess {
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let can_reset_errors = Lrc::new(AtomicBool::new(false));

let show_parse_errors = if config.was_set().hide_parse_errors() {
eprintln!(
"Warning: the `hide_parse_errors` option is deprecated. \
Use `show_parse_errors` instead"
);
config.hide_parse_errors()
} else {
config.show_parse_errors()
};

let handler = default_handler(
Lrc::clone(&source_map),
Lrc::clone(&ignore_path_set),
Lrc::clone(&can_reset_errors),
config.hide_parse_errors(),
show_parse_errors,
config.color(),
);
let parse_sess = RawParseSess::with_span_handler(handler, source_map);
Expand Down

0 comments on commit 693365c

Please sign in to comment.