diff options
| author | bors <bors@rust-lang.org> | 2022-11-01 05:34:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-01 05:34:00 +0000 |
| commit | dc05f60c1ff4e2cb2e6eb80c9b3afa612ce28c7f (patch) | |
| tree | b0ae44f23cbf5efc6300d241a6eb94cac1d61915 /compiler/rustc_middle/src | |
| parent | 024207ab43aceb49f2ca957509c503ccf12089d7 (diff) | |
| parent | 669e3cde1c24c10223fca6dfe51c2ee6d722545b (diff) | |
| download | rust-dc05f60c1ff4e2cb2e6eb80c9b3afa612ce28c7f.tar.gz rust-dc05f60c1ff4e2cb2e6eb80c9b3afa612ce28c7f.zip | |
Auto merge of #103829 - JohnTitor:rollup-o03nzr8, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #103007 (Add better python discovery) - #103674 (Update note about unstable split-debuginfo flag.) - #103692 (Add `walk_generic_arg`) - #103749 (Reduce span of let else irrefutable_let_patterns warning) - #103772 (better error for `rustc_strict_coherence` misuse) - #103788 (Fix ICE in checking transmutability of NaughtyLenArray) - #103793 (rustdoc: add margins to all impl-item toggles, not just methods) - #103798 (interpret: move type_name implementation to an interpreter-independent helper file) - #103799 (Remove generation of tuple struct fields in the search index) - #103805 (Enable RUSTC_BOOTSTRAP for a few steps) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/error.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/traits/specialization_graph.rs | 17 |
2 files changed, 24 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index a7a7ac0599d..43903e6739f 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -55,3 +55,12 @@ pub struct ConstEvalNonIntError { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag(middle_strict_coherence_needs_negative_coherence)] +pub(crate) struct StrictCoherenceNeedsNegativeCoherence { + #[primary_span] + pub span: Span, + #[label] + pub attr_span: Option<Span>, +} diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index 0a2819feecf..f1c21588261 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -1,3 +1,4 @@ +use crate::error::StrictCoherenceNeedsNegativeCoherence; use crate::ty::fast_reject::SimplifiedType; use crate::ty::visit::TypeVisitable; use crate::ty::{self, TyCtxt}; @@ -65,9 +66,21 @@ impl OverlapMode { if with_negative_coherence { if strict_coherence { OverlapMode::Strict } else { OverlapMode::WithNegative } - } else if strict_coherence { - bug!("To use strict_coherence you need to set with_negative_coherence feature flag"); } else { + if strict_coherence { + let attr_span = trait_id + .as_local() + .into_iter() + .flat_map(|local_def_id| { + tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(local_def_id)) + }) + .find(|attr| attr.has_name(sym::rustc_strict_coherence)) + .map(|attr| attr.span); + tcx.sess.emit_err(StrictCoherenceNeedsNegativeCoherence { + span: tcx.def_span(trait_id), + attr_span, + }); + } OverlapMode::Stable } } |
