mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
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:
@@ -30,7 +30,7 @@
|
|||||||
walk_native_lib_search_dirs,
|
walk_native_lib_search_dirs,
|
||||||
};
|
};
|
||||||
use rustc_middle::bug;
|
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::debugger_visualizer::DebuggerVisualizerFile;
|
||||||
use rustc_middle::middle::dependency_format::Linkage;
|
use rustc_middle::middle::dependency_format::Linkage;
|
||||||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
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| {
|
let lint_msg = |msg| {
|
||||||
diag_lint_level(
|
emit_lint_base(
|
||||||
sess,
|
sess,
|
||||||
LINKER_MESSAGES,
|
LINKER_MESSAGES,
|
||||||
levels.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| {
|
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() {
|
if !escaped_stderr.is_empty() {
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ pub trait LintContext {
|
|||||||
// set the span in their `decorate` function (preferably using set_span).
|
// set the span in their `decorate` function (preferably using set_span).
|
||||||
/// Emit a lint at the appropriate level, with an optional associated 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]
|
#[track_caller]
|
||||||
fn opt_span_diag_lint<S: Into<MultiSpan>>(
|
fn opt_span_diag_lint<S: Into<MultiSpan>>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_middle::lint::{
|
use rustc_middle::lint::{
|
||||||
LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, diag_lint_level,
|
LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, emit_lint_base,
|
||||||
reveal_actual_level,
|
reveal_actual_level,
|
||||||
};
|
};
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
@@ -981,7 +981,7 @@ fn into_diag(
|
|||||||
if self.lint_added_lints {
|
if self.lint_added_lints {
|
||||||
let lint = builtin::UNKNOWN_LINTS;
|
let lint = builtin::UNKNOWN_LINTS;
|
||||||
let level = self.lint_level(builtin::UNKNOWN_LINTS);
|
let level = self.lint_level(builtin::UNKNOWN_LINTS);
|
||||||
diag_lint_level(
|
emit_lint_base(
|
||||||
self.sess,
|
self.sess,
|
||||||
lint,
|
lint,
|
||||||
level,
|
level,
|
||||||
@@ -1008,7 +1008,7 @@ pub(crate) fn opt_span_diag_lint(
|
|||||||
decorator: impl for<'a> Diagnostic<'a, ()>,
|
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let level = self.lint_level(lint);
|
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]
|
#[track_caller]
|
||||||
@@ -1019,13 +1019,13 @@ pub fn emit_span_lint(
|
|||||||
decorator: impl for<'a> Diagnostic<'a, ()>,
|
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let level = self.lint_level(lint);
|
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]
|
#[track_caller]
|
||||||
pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) {
|
pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) {
|
||||||
let level = self.lint_level(lint);
|
let level = self.lint_level(lint);
|
||||||
diag_lint_level(self.sess, lint, level, None, decorator);
|
emit_lint_base(self.sess, lint, level, None, decorator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,11 +300,8 @@ fn explain_lint_level_source(
|
|||||||
///
|
///
|
||||||
/// - [`TyCtxt::emit_node_span_lint`]
|
/// - [`TyCtxt::emit_node_span_lint`]
|
||||||
/// - `LintContext::opt_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]
|
#[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,
|
sess: &'a Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: LevelAndSource,
|
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
|
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
||||||
// the "real" work.
|
// the "real" work.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn diag_lint_level_impl<'a>(
|
fn emit_lint_base_impl<'a>(
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: LevelAndSource,
|
level: LevelAndSource,
|
||||||
@@ -498,7 +495,7 @@ fn diag_lint_level_impl<'a>(
|
|||||||
explain_lint_level_source(sess, lint, level, src, &mut err);
|
explain_lint_level_source(sess, lint, level, src, &mut err);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
diag_lint_level_impl(
|
emit_lint_base_impl(
|
||||||
sess,
|
sess,
|
||||||
lint,
|
lint,
|
||||||
level,
|
level,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
use crate::dep_graph::{DepGraph, DepKindVTable, DepNodeIndex};
|
use crate::dep_graph::{DepGraph, DepKindVTable, DepNodeIndex};
|
||||||
use crate::ich::StableHashingContext;
|
use crate::ich::StableHashingContext;
|
||||||
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind};
|
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind};
|
||||||
use crate::lint::diag_lint_level;
|
use crate::lint::emit_lint_base;
|
||||||
use crate::metadata::ModChild;
|
use crate::metadata::ModChild;
|
||||||
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
|
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};
|
||||||
use crate::middle::resolve_bound_vars;
|
use crate::middle::resolve_bound_vars;
|
||||||
@@ -2539,7 +2539,7 @@ pub fn emit_node_span_lint(
|
|||||||
decorator: impl for<'a> Diagnostic<'a, ()>,
|
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let level = self.lint_level_at_node(lint, hir_id);
|
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.
|
/// 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, ()>,
|
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let level = self.lint_level_at_node(lint, id);
|
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>]> {
|
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate<'tcx>]> {
|
||||||
|
|||||||
@@ -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>();
|
||||||
|
}
|
||||||
@@ -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());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user