summaryrefslogtreecommitdiff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-17 06:42:07 +0000
committerbors <bors@rust-lang.org>2023-05-17 06:42:07 +0000
commitc2ccc855e74aec03e434405eca3c247ee2432e53 (patch)
tree123b2319d3e649afa4438cc57830d30f5c87db1d /compiler/rustc_middle
parent6c64870fa67f0227f40f6adc25a6944e95c2959f (diff)
parent072074383627a6e5eb43c72522ae09010eb218c0 (diff)
downloadrust-c2ccc855e74aec03e434405eca3c247ee2432e53.tar.gz
Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #110145 (Share slice of bytes) - #111043 (Stabilize feature `cstr_is_empty`) - #111648 (Remove `LangItems::require`) - #111649 (Add derive for `core::marker::ConstParamTy`) - #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`) - #111661 (Erase regions of type in `offset_of!`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/messages.ftl2
-rw-r--r--compiler/rustc_middle/src/error.rs10
-rw-r--r--compiler/rustc_middle/src/middle/lang_items.rs8
3 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl
index c6bbf2ef0cd..64d511c261a 100644
--- a/compiler/rustc_middle/messages.ftl
+++ b/compiler/rustc_middle/messages.ftl
@@ -39,5 +39,7 @@ middle_strict_coherence_needs_negative_coherence =
to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled
.label = due to this attribute
+middle_requires_lang_item = requires `{$name}` lang_item
+
middle_const_not_used_in_type_alias =
const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias
diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs
index dc4aa18640f..046186d274c 100644
--- a/compiler/rustc_middle/src/error.rs
+++ b/compiler/rustc_middle/src/error.rs
@@ -1,5 +1,5 @@
use rustc_macros::Diagnostic;
-use rustc_span::Span;
+use rustc_span::{Span, Symbol};
use crate::ty::Ty;
@@ -74,6 +74,14 @@ pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
}
#[derive(Diagnostic)]
+#[diag(middle_requires_lang_item)]
+pub(crate) struct RequiresLangItem {
+ #[primary_span]
+ pub span: Option<Span>,
+ pub name: Symbol,
+}
+
+#[derive(Diagnostic)]
#[diag(middle_const_not_used_in_type_alias)]
pub(super) struct ConstNotUsedTraitAlias {
pub ct: String,
diff --git a/compiler/rustc_middle/src/middle/lang_items.rs b/compiler/rustc_middle/src/middle/lang_items.rs
index 343ea1f00f5..9a633e04ce7 100644
--- a/compiler/rustc_middle/src/middle/lang_items.rs
+++ b/compiler/rustc_middle/src/middle/lang_items.rs
@@ -18,12 +18,8 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns the `DefId` for a given `LangItem`.
/// If not found, fatally aborts compilation.
pub fn require_lang_item(self, lang_item: LangItem, span: Option<Span>) -> DefId {
- self.lang_items().require(lang_item).unwrap_or_else(|err| {
- if let Some(span) = span {
- self.sess.span_fatal(span, err.to_string())
- } else {
- self.sess.fatal(err.to_string())
- }
+ self.lang_items().get(lang_item).unwrap_or_else(|| {
+ self.sess.emit_fatal(crate::error::RequiresLangItem { span, name: lang_item.name() });
})
}