diff options
| author | Ryan Levick <me@ryanlevick.com> | 2021-07-01 12:29:20 +0200 |
|---|---|---|
| committer | Ryan Levick <me@ryanlevick.com> | 2021-07-01 12:29:20 +0200 |
| commit | 33cc7b1fe21c82d31204e549cd2471ac8ec22aa3 (patch) | |
| tree | 6f60870bfaaaa7c5377f11f33b0dc9b84d9bda46 /compiler/rustc_errors/src | |
| parent | a3d6905053ad60e836717976e6e4d38de67888f9 (diff) | |
| download | rust-33cc7b1fe21c82d31204e549cd2471ac8ec22aa3.tar.gz rust-33cc7b1fe21c82d31204e549cd2471ac8ec22aa3.zip | |
New force_warn diagnostic builder and ensure cap-lints doesn't reduce force_warn level
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index c5399282a1e..a5e11541c8b 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -521,12 +521,24 @@ impl Handler { } /// Construct a builder at the `Warning` level at the given `span` and with the `msg`. + /// Cancel the builder if warnings cannot be emitted 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`. + 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, @@ -552,6 +564,7 @@ impl Handler { } /// Construct a builder at the `Warning` level with the `msg`. + /// Cancel the builder if warnings cannot be emitted pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); if !self.flags.can_emit_warnings { @@ -560,6 +573,11 @@ impl Handler { result } + /// Construct a builder at the `Warning` level with the `msg`. + pub fn struct_force_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { + DiagnosticBuilder::new(self, Level::Warning, msg) + } + /// Construct a builder at the `Allow` level with the `msg`. pub fn struct_allow(&self, msg: &str) -> DiagnosticBuilder<'_> { DiagnosticBuilder::new(self, Level::Allow, msg) |
