diff options
| author | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2022-01-26 03:46:56 +0000 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2022-02-23 05:38:24 +0000 |
| commit | d4fc5ae25cea1068fc2a3d96763d3ede3a6a14d4 (patch) | |
| tree | c5eb1d2eb4b4bfdb915f8dbd114fc5cf98ee6578 /compiler/rustc_errors/src/lib.rs | |
| parent | 02ff9e0aef03d48fdecc2d114311217010ec1d81 (diff) | |
| download | rust-d4fc5ae25cea1068fc2a3d96763d3ede3a6a14d4.tar.gz rust-d4fc5ae25cea1068fc2a3d96763d3ede3a6a14d4.zip | |
rustc_errors: handle `force_warn` only through `DiagnosticId::Lint`.
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 0fae230813b..aec67b5e1fd 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -632,27 +632,15 @@ impl Handler { /// Construct a builder at the `Warning` level at the given `span` and with the `msg`. /// - /// The builder will be canceled if warnings cannot be emitted. + /// Attempting to `.emit()` the builder will only emit if either: + /// * `can_emit_warnings` is `true` + /// * `is_force_warn` was set in `DiagnosticId::Lint` pub fn struct_span_warn(&self, span: impl Into<MultiSpan>, msg: &str) -> DiagnosticBuilder<'_> { let mut result = self.struct_warn(msg); result.set_span(span); result } - /// Construct a builder at the `Warning` level at the given `span` and with the `msg`. - /// - /// This will "force" the warning meaning it will not be canceled even - /// if warnings cannot be emitted. - pub fn struct_span_force_warn( - &self, - span: impl Into<MultiSpan>, - msg: &str, - ) -> DiagnosticBuilder<'_> { - let mut result = self.struct_force_warn(msg); - result.set_span(span); - result - } - /// Construct a builder at the `Allow` level at the given `span` and with the `msg`. pub fn struct_span_allow( &self, @@ -679,20 +667,10 @@ impl Handler { /// Construct a builder at the `Warning` level with the `msg`. /// - /// The builder will be canceled if warnings cannot be emitted. + /// Attempting to `.emit()` the builder will only emit if either: + /// * `can_emit_warnings` is `true` + /// * `is_force_warn` was set in `DiagnosticId::Lint` pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { - let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); - if !self.flags.can_emit_warnings { - result.cancel(); - } - result - } - - /// Construct a builder at the `Warning` level with the `msg`. - /// - /// This will "force" a warning meaning it will not be canceled even - /// if warnings cannot be emitted. - pub fn struct_force_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { DiagnosticBuilder::new(self, Level::Warning, msg) } |
