/// Trait implemented by error types. This should not be implemented manually. Instead, use
/// `#[derive(SessionDiagnostic)]` -- see [rustc_macros::SessionDiagnostic].
+#[rustc_diagnostic_item = "SessionDiagnostic"]
pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
/// Write out as a diagnostic out of `sess`.
#[must_use]
self.crate_types.set(crate_types).expect("`crate_types` was initialized twice")
}
+ #[rustc_lint_diagnostics]
pub fn struct_span_warn<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_span_warn(sp, msg)
}
+ #[rustc_lint_diagnostics]
+ pub fn struct_span_warn_with_expectation<S: Into<MultiSpan>>(
+ &self,
+ sp: S,
+ msg: impl Into<DiagnosticMessage>,
+ id: lint::LintExpectationId,
+ ) -> DiagnosticBuilder<'_, ()> {
+ self.diagnostic().struct_span_warn_with_expectation(sp, msg, id)
+ }
+ #[rustc_lint_diagnostics]
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_span_warn_with_code(sp, msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_warn(msg)
}
+ #[rustc_lint_diagnostics]
+ pub fn struct_warn_with_expectation(
+ &self,
+ msg: impl Into<DiagnosticMessage>,
+ id: lint::LintExpectationId,
+ ) -> DiagnosticBuilder<'_, ()> {
+ self.diagnostic().struct_warn_with_expectation(msg, id)
+ }
+ #[rustc_lint_diagnostics]
pub fn struct_span_allow<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_span_allow(sp, msg)
}
+ #[rustc_lint_diagnostics]
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_allow(msg)
}
+ #[rustc_lint_diagnostics]
pub fn struct_expect(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_expect(msg, id)
}
+ #[rustc_lint_diagnostics]
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_err(sp, msg)
}
+ #[rustc_lint_diagnostics]
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
self.diagnostic().struct_span_err_with_code(sp, msg, code)
}
// FIXME: This method should be removed (every error should have an associated error code).
+ #[rustc_lint_diagnostics]
pub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.parse_sess.struct_err(msg)
}
+ #[rustc_lint_diagnostics]
pub fn struct_err_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err_with_code(msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn struct_warn_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_warn_with_code(msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, !> {
self.diagnostic().struct_span_fatal(sp, msg)
}
+ #[rustc_lint_diagnostics]
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
) -> DiagnosticBuilder<'_, !> {
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
self.diagnostic().struct_fatal(msg)
}
+ #[rustc_lint_diagnostics]
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
self.diagnostic().span_fatal(sp, msg)
}
+ #[rustc_lint_diagnostics]
pub fn span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
) -> ! {
self.diagnostic().span_fatal_with_code(sp, msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
self.diagnostic().fatal(msg).raise()
}
+ #[rustc_lint_diagnostics]
pub fn span_err_or_warn<S: Into<MultiSpan>>(
&self,
is_warning: bool,
self.span_err(sp, msg);
}
}
+ #[rustc_lint_diagnostics]
pub fn span_err<S: Into<MultiSpan>>(
&self,
sp: S,
) -> ErrorGuaranteed {
self.diagnostic().span_err(sp, msg)
}
+ #[rustc_lint_diagnostics]
pub fn span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
) {
self.diagnostic().span_err_with_code(sp, msg, code)
}
+ #[rustc_lint_diagnostics]
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
self.diagnostic().err(msg)
}
let profiler = SelfProfiler::new(
directory,
sopts.crate_name.as_deref(),
- &sopts.debugging_opts.self_profile_events,
+ sopts.debugging_opts.self_profile_events.as_ref().map(|xs| &xs[..]),
+ &sopts.debugging_opts.self_profile_counter,
);
match profiler {
Ok(profiler) => Some(Arc::new(profiler)),
);
}
- // LLVM CFI requires LTO.
- if sess.is_sanitizer_cfi_enabled() {
- if sess.opts.cg.lto == config::LtoCli::Unspecified
- || sess.opts.cg.lto == config::LtoCli::No
- || sess.opts.cg.lto == config::LtoCli::Thin
- {
+ // LLVM CFI and VFE both require LTO.
+ if sess.lto() != config::Lto::Fat {
+ if sess.is_sanitizer_cfi_enabled() {
sess.err("`-Zsanitizer=cfi` requires `-Clto`");
}
+ if sess.opts.debugging_opts.virtual_function_elimination {
+ sess.err("`-Zvirtual-function-elimination` requires `-Clto`");
+ }
}
if sess.opts.debugging_opts.stack_protector != StackProtector::None {