summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/middle
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_middle/src/middle
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_middle/src/middle')
-rw-r--r--compiler/rustc_middle/src/middle/limits.rs11
-rw-r--r--compiler/rustc_middle/src/middle/privacy.rs35
-rw-r--r--compiler/rustc_middle/src/middle/stability.rs12
3 files changed, 27 insertions, 31 deletions
diff --git a/compiler/rustc_middle/src/middle/limits.rs b/compiler/rustc_middle/src/middle/limits.rs
index bd859d4d6..d4f023958 100644
--- a/compiler/rustc_middle/src/middle/limits.rs
+++ b/compiler/rustc_middle/src/middle/limits.rs
@@ -1,8 +1,7 @@
//! Registering limits:
//! * recursion_limit,
-//! * move_size_limit,
-//! * type_length_limit, and
-//! * const_eval_limit
+//! * move_size_limit, and
+//! * type_length_limit
//!
//! There are various parts of the compiler that must impose arbitrary limits
//! on how deeply they recurse to prevent stack overflow. Users can override
@@ -34,12 +33,6 @@ pub fn provide(providers: &mut Providers) {
sym::type_length_limit,
1048576,
),
- const_eval_limit: get_limit(
- tcx.hir().krate_attrs(),
- tcx.sess,
- sym::const_eval_limit,
- 2_000_000,
- ),
}
}
diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs
index f45cf788d..5baeb1ee0 100644
--- a/compiler/rustc_middle/src/middle/privacy.rs
+++ b/compiler/rustc_middle/src/middle/privacy.rs
@@ -4,6 +4,7 @@
use crate::ty::{TyCtxt, Visibility};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
+use rustc_hir::def::DefKind;
use rustc_macros::HashStable;
use rustc_query_system::ich::StableHashingContext;
use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
@@ -148,13 +149,12 @@ impl EffectiveVisibilities {
};
}
- pub fn check_invariants(&self, tcx: TyCtxt<'_>, early: bool) {
+ pub fn check_invariants(&self, tcx: TyCtxt<'_>) {
if !cfg!(debug_assertions) {
return;
}
for (&def_id, ev) in &self.map {
// More direct visibility levels can never go farther than less direct ones,
- // neither of effective visibilities can go farther than nominal visibility,
// and all effective visibilities are larger or equal than private visibility.
let private_vis = Visibility::Restricted(tcx.parent_module_from_def_id(def_id));
let span = tcx.def_span(def_id.to_def_id());
@@ -175,17 +175,20 @@ impl EffectiveVisibilities {
ev.reachable_through_impl_trait
);
}
- let nominal_vis = tcx.visibility(def_id);
- // FIXME: `rustc_privacy` is not yet updated for the new logic and can set
- // effective visibilities that are larger than the nominal one.
- if !nominal_vis.is_at_least(ev.reachable_through_impl_trait, tcx) && early {
- span_bug!(
- span,
- "{:?}: reachable_through_impl_trait {:?} > nominal {:?}",
- def_id,
- ev.reachable_through_impl_trait,
- nominal_vis
- );
+ // All effective visibilities except `reachable_through_impl_trait` are limited to
+ // nominal visibility. For some items nominal visibility doesn't make sense so we
+ // don't check this condition for them.
+ if !matches!(tcx.def_kind(def_id), DefKind::Impl { .. }) {
+ let nominal_vis = tcx.visibility(def_id);
+ if !nominal_vis.is_at_least(ev.reachable, tcx) {
+ span_bug!(
+ span,
+ "{:?}: reachable {:?} > nominal {:?}",
+ def_id,
+ ev.reachable,
+ nominal_vis
+ );
+ }
}
}
}
@@ -212,7 +215,7 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
pub fn update(
&mut self,
id: Id,
- nominal_vis: Option<Visibility>,
+ max_vis: Option<Visibility>,
lazy_private_vis: impl FnOnce() -> Visibility,
inherited_effective_vis: EffectiveVisibility,
level: Level,
@@ -236,8 +239,8 @@ impl<Id: Eq + Hash> EffectiveVisibilities<Id> {
if !(inherited_effective_vis_at_prev_level == inherited_effective_vis_at_level
&& level != l)
{
- calculated_effective_vis = if let Some(nominal_vis) = nominal_vis && !nominal_vis.is_at_least(inherited_effective_vis_at_level, tcx) {
- nominal_vis
+ calculated_effective_vis = if let Some(max_vis) = max_vis && !max_vis.is_at_least(inherited_effective_vis_at_level, tcx) {
+ max_vis
} else {
inherited_effective_vis_at_level
}
diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs
index 6354c0aab..60844c17e 100644
--- a/compiler/rustc_middle/src/middle/stability.rs
+++ b/compiler/rustc_middle/src/middle/stability.rs
@@ -104,7 +104,7 @@ pub fn report_unstable(
suggestion: Option<(Span, String, String, Applicability)>,
is_soft: bool,
span: Span,
- soft_handler: impl FnOnce(&'static Lint, Span, &str),
+ soft_handler: impl FnOnce(&'static Lint, Span, String),
) {
let msg = match reason {
Some(r) => format!("use of unstable library feature '{}': {}", feature, r),
@@ -112,7 +112,7 @@ pub fn report_unstable(
};
if is_soft {
- soft_handler(SOFT_UNSTABLE, span, &msg)
+ soft_handler(SOFT_UNSTABLE, span, msg)
} else {
let mut err =
feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), msg);
@@ -225,7 +225,7 @@ pub fn deprecation_message_and_lint(
pub fn early_report_deprecation(
lint_buffer: &mut LintBuffer,
- message: &str,
+ message: String,
suggestion: Option<Symbol>,
lint: &'static Lint,
span: Span,
@@ -241,7 +241,7 @@ pub fn early_report_deprecation(
fn late_report_deprecation(
tcx: TyCtxt<'_>,
- message: &str,
+ message: String,
suggestion: Option<Symbol>,
lint: &'static Lint,
span: Span,
@@ -396,7 +396,7 @@ impl<'tcx> TyCtxt<'tcx> {
late_report_deprecation(
self,
- &deprecation_message(
+ deprecation_message(
is_in_effect,
depr_attr.since,
depr_attr.note,
@@ -619,7 +619,7 @@ impl<'tcx> TyCtxt<'tcx> {
allow_unstable: AllowUnstable,
unmarked: impl FnOnce(Span, DefId),
) -> bool {
- let soft_handler = |lint, span, msg: &_| {
+ let soft_handler = |lint, span, msg: String| {
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |lint| lint)
};
let eval_result =