Auto merge of #153791 - JonathanBrouwer:rollup-BMzX17I, r=JonathanBrouwer

Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#153787 (Rename `rustc_middle::lint::diag_lint_level` into `lint_level`)
 - rust-lang/rust#153321 (Add high-priority ICEs to tests/crashes)
This commit is contained in:
bors
2026-03-12 21:55:45 +00:00
7 changed files with 65 additions and 18 deletions
+3 -3
View File
@@ -30,7 +30,7 @@
walk_native_lib_search_dirs,
};
use rustc_middle::bug;
use rustc_middle::lint::diag_lint_level;
use rustc_middle::lint::emit_lint_base;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
@@ -784,7 +784,7 @@ fn for_each(bytes: &[u8], mut f: impl FnMut(&str, &mut String)) -> String {
}
let lint_msg = |msg| {
diag_lint_level(
emit_lint_base(
sess,
LINKER_MESSAGES,
levels.linker_messages,
@@ -793,7 +793,7 @@ fn for_each(bytes: &[u8], mut f: impl FnMut(&str, &mut String)) -> String {
);
};
let lint_info = |msg| {
diag_lint_level(sess, LINKER_INFO, levels.linker_info, None, LinkerOutput { inner: msg });
emit_lint_base(sess, LINKER_INFO, levels.linker_info, None, LinkerOutput { inner: msg });
};
if !escaped_stderr.is_empty() {
+1 -1
View File
@@ -514,7 +514,7 @@ pub trait LintContext {
// set the span in their `decorate` function (preferably using set_span).
/// Emit a lint at the appropriate level, with an optional associated span.
///
/// [`diag_lint_level`]: rustc_middle::lint::diag_lint_level#decorate-signature
/// [`emit_lint_base`]: rustc_middle::lint::emit_lint_base#decorate-signature
#[track_caller]
fn opt_span_diag_lint<S: Into<MultiSpan>>(
&self,
+5 -5
View File
@@ -12,7 +12,7 @@
use rustc_middle::bug;
use rustc_middle::hir::nested_filter;
use rustc_middle::lint::{
LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, diag_lint_level,
LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, emit_lint_base,
reveal_actual_level,
};
use rustc_middle::query::Providers;
@@ -981,7 +981,7 @@ fn into_diag(
if self.lint_added_lints {
let lint = builtin::UNKNOWN_LINTS;
let level = self.lint_level(builtin::UNKNOWN_LINTS);
diag_lint_level(
emit_lint_base(
self.sess,
lint,
level,
@@ -1008,7 +1008,7 @@ pub(crate) fn opt_span_diag_lint(
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
let level = self.lint_level(lint);
diag_lint_level(self.sess, lint, level, span, decorator)
emit_lint_base(self.sess, lint, level, span, decorator)
}
#[track_caller]
@@ -1019,13 +1019,13 @@ pub fn emit_span_lint(
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
let level = self.lint_level(lint);
diag_lint_level(self.sess, lint, level, Some(span), decorator);
emit_lint_base(self.sess, lint, level, Some(span), decorator);
}
#[track_caller]
pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) {
let level = self.lint_level(lint);
diag_lint_level(self.sess, lint, level, None, decorator);
emit_lint_base(self.sess, lint, level, None, decorator);
}
}
+3 -6
View File
@@ -300,11 +300,8 @@ fn explain_lint_level_source(
///
/// - [`TyCtxt::emit_node_span_lint`]
/// - `LintContext::opt_span_lint`
///
/// This function will replace `lint_level` once all its callers have been replaced
/// with `diag_lint_level`.
#[track_caller]
pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
pub fn emit_lint_base<'a, D: Diagnostic<'a, ()> + 'a>(
sess: &'a Session,
lint: &'static Lint,
level: LevelAndSource,
@@ -314,7 +311,7 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
// the "real" work.
#[track_caller]
fn diag_lint_level_impl<'a>(
fn emit_lint_base_impl<'a>(
sess: &'a Session,
lint: &'static Lint,
level: LevelAndSource,
@@ -498,7 +495,7 @@ fn diag_lint_level_impl<'a>(
explain_lint_level_source(sess, lint, level, src, &mut err);
err.emit();
}
diag_lint_level_impl(
emit_lint_base_impl(
sess,
lint,
level,
+3 -3
View File
@@ -55,7 +55,7 @@
use crate::dep_graph::{DepGraph, DepKindVTable, DepNodeIndex};
use crate::ich::StableHashingContext;
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind};
use crate::lint::diag_lint_level;
use crate::lint::emit_lint_base;
use crate::metadata::ModChild;
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
use crate::middle::resolve_bound_vars;
@@ -2539,7 +2539,7 @@ pub fn emit_node_span_lint(
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
let level = self.lint_level_at_node(lint, hir_id);
diag_lint_level(self.sess, lint, level, Some(span.into()), decorator)
emit_lint_base(self.sess, lint, level, Some(span.into()), decorator)
}
/// Find the appropriate span where `use` and outer attributes can be inserted at.
@@ -2582,7 +2582,7 @@ pub fn emit_node_lint(
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
let level = self.lint_level_at_node(lint, id);
diag_lint_level(self.sess, lint, level, None, decorator);
emit_lint_base(self.sess, lint, level, None, decorator);
}
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate<'tcx>]> {
+29
View File
@@ -0,0 +1,29 @@
//@ known-bug: #146965
//@ compile-flags: --crate-type lib -C opt-level=3
fn conjure<T>() -> T {
panic!()
}
pub trait Ring {
type Element;
}
impl<T> Ring for T {
type Element = u16;
}
// Removing the : Ring bound makes it not ICE
fn map_coeff<T: Ring>(f: impl Fn(<T as Ring>::Element)) {
let c = conjure::<<T as Ring>::Element>();
f(c);
}
// Adding a : Ring bound makes it not ICE
fn gcd<T>() {
map_coeff::<T>(|_: u16| {});
}
// Removing the : Ring bound makes it not ICE
pub fn bivariate_factorization<T: Ring>() {
gcd::<T>();
}
+21
View File
@@ -0,0 +1,21 @@
//@ known-bug: #150263
//@ compile-flags: --crate-type lib -C opt-level=3
pub trait Scope {
type Timestamp;
}
impl<G> Scope for G {
type Timestamp = ();
}
pub fn create<G: Scope>() {
enter::<G>();
}
fn enter<G>() {
unary::<G>(|_: <G as Scope>::Timestamp| {});
}
fn unary<G: Scope>(constructor: impl FnOnce(G::Timestamp)) {
constructor(None.unwrap());
}