Skip to content

Commit 9823f17

Browse files
committed
Auto merge of rust-lang#122151 - GuillaumeGomez:rollup-hfxr9kv, r=GuillaumeGomez
Rollup of 10 pull requests Successful merges: - rust-lang#119888 (Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimplemented]` attribute) - rust-lang#121089 (Remove `feed_local_def_id`) - rust-lang#122004 (AST validation: Improve handling of inherent impls nested within functions and anon consts) - rust-lang#122087 (Add missing background color for top-level rust documentation page and increase contrast by setting text color to black) - rust-lang#122136 (Include all library files in artifact summary on CI) - rust-lang#122137 (Don't pass a break scope to `Builder::break_for_else`) - rust-lang#122138 (Record mtime in bootstrap's LLVM linker script) - rust-lang#122141 (sync (try_)instantiate_mir_and_normalize_erasing_regions implementation) - rust-lang#122142 (cleanup rustc_infer) - rust-lang#122147 (Make `std::os::unix::ucred` module private) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9c3ad80 + 92d7e02 commit 9823f17

File tree

70 files changed

+594
-639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+594
-639
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> {
427427
tcx.ensure_with_value().early_lint_checks(());
428428
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
429429
tcx.ensure_with_value().get_lang_items(());
430-
let (mut resolver, krate) = tcx.resolver_for_lowering(()).steal();
430+
let (mut resolver, krate) = tcx.resolver_for_lowering().steal();
431431

432432
let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
433433
let mut owners = IndexVec::from_fn_n(

compiler/rustc_ast_passes/src/ast_validation.rs

+30-27
Original file line numberDiff line numberDiff line change
@@ -929,35 +929,38 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
929929
only_trait: only_trait.then_some(()),
930930
};
931931

932-
self.visibility_not_permitted(
933-
&item.vis,
934-
errors::VisibilityNotPermittedNote::IndividualImplItems,
935-
);
936-
if let &Unsafe::Yes(span) = unsafety {
937-
self.dcx().emit_err(errors::InherentImplCannotUnsafe {
938-
span: self_ty.span,
939-
annotation_span: span,
940-
annotation: "unsafe",
941-
self_ty: self_ty.span,
942-
});
943-
}
944-
if let &ImplPolarity::Negative(span) = polarity {
945-
self.dcx().emit_err(error(span, "negative", false));
946-
}
947-
if let &Defaultness::Default(def_span) = defaultness {
948-
self.dcx().emit_err(error(def_span, "`default`", true));
949-
}
950-
if let &Const::Yes(span) = constness {
951-
self.dcx().emit_err(error(span, "`const`", true));
952-
}
932+
self.with_in_trait_impl(None, |this| {
933+
this.visibility_not_permitted(
934+
&item.vis,
935+
errors::VisibilityNotPermittedNote::IndividualImplItems,
936+
);
937+
if let &Unsafe::Yes(span) = unsafety {
938+
this.dcx().emit_err(errors::InherentImplCannotUnsafe {
939+
span: self_ty.span,
940+
annotation_span: span,
941+
annotation: "unsafe",
942+
self_ty: self_ty.span,
943+
});
944+
}
945+
if let &ImplPolarity::Negative(span) = polarity {
946+
this.dcx().emit_err(error(span, "negative", false));
947+
}
948+
if let &Defaultness::Default(def_span) = defaultness {
949+
this.dcx().emit_err(error(def_span, "`default`", true));
950+
}
951+
if let &Const::Yes(span) = constness {
952+
this.dcx().emit_err(error(span, "`const`", true));
953+
}
953954

954-
self.visit_vis(&item.vis);
955-
self.visit_ident(item.ident);
956-
self.with_tilde_const(Some(DisallowTildeConstContext::Impl(item.span)), |this| {
957-
this.visit_generics(generics)
955+
this.visit_vis(&item.vis);
956+
this.visit_ident(item.ident);
957+
this.with_tilde_const(
958+
Some(DisallowTildeConstContext::Impl(item.span)),
959+
|this| this.visit_generics(generics),
960+
);
961+
this.visit_ty(self_ty);
962+
walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
958963
});
959-
self.visit_ty(self_ty);
960-
walk_list!(self, visit_assoc_item, items, AssocCtxt::Impl);
961964
walk_list!(self, visit_attribute, &item.attrs);
962965
return; // Avoid visiting again.
963966
}

compiler/rustc_ast_passes/src/feature_gate.rs

-8
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
206206
);
207207
}
208208
}
209-
if !attr.is_doc_comment()
210-
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
211-
&& seg.ident.name == sym::diagnostic
212-
&& !self.features.diagnostic_namespace
213-
{
214-
let msg = "`#[diagnostic]` attribute name space is experimental";
215-
gate!(self, diagnostic_namespace, seg.ident.span, msg);
216-
}
217209

218210
// Emit errors for non-staged-api crates.
219211
if !self.features.staged_api {

compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ fn run_compiler(
418418
}
419419

420420
// Make sure name resolution and macro expansion is run.
421-
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering(()));
421+
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering());
422422

423423
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
424424
return early_exit();

compiler/rustc_driver_impl/src/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
229229
{
230230
match self {
231231
PrintExtra::AfterParsing { krate, .. } => f(krate),
232-
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).borrow().1),
232+
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering().borrow().1),
233233
}
234234
}
235235

@@ -281,7 +281,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
281281
}
282282
AstTreeExpanded => {
283283
debug!("pretty-printing expanded AST");
284-
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1)
284+
format!("{:#?}", ex.tcx().resolver_for_lowering().borrow().1)
285285
}
286286
Hir(s) => {
287287
debug!("pretty printing HIR {:?}", s);

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ declare_features! (
146146
(accepted, derive_default_enum, "1.62.0", Some(86985)),
147147
/// Allows the use of destructuring assignments.
148148
(accepted, destructuring_assignment, "1.59.0", Some(71126)),
149+
/// Allows using the `#[diagnostic]` attribute tool namespace
150+
(accepted, diagnostic_namespace, "CURRENT_RUSTC_VERSION", Some(111996)),
149151
/// Allows `#[doc(alias = "...")]`.
150152
(accepted, doc_alias, "1.48.0", Some(50146)),
151153
/// Allows `..` in tuple (struct) patterns.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ declare_features! (
436436
(unstable, deprecated_safe, "1.61.0", Some(94978)),
437437
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
438438
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
439-
/// Allows using the `#[diagnostic]` attribute tool namespace
440-
(unstable, diagnostic_namespace, "1.73.0", Some(111996)),
441439
/// Controls errors in trait implementations.
442440
(unstable, do_not_recommend, "1.67.0", Some(51992)),
443441
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.

compiler/rustc_infer/src/infer/higher_ranked/README.md

-8
This file was deleted.

compiler/rustc_infer/src/infer/mod.rs

+22-121
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
pub use self::at::DefineOpaqueTypes;
2-
pub use self::freshen::TypeFreshener;
3-
pub use self::lexical_region_resolve::RegionResolutionError;
4-
pub use self::BoundRegionConversionTime::*;
5-
pub use self::RegionVariableOrigin::*;
6-
pub use self::SubregionOrigin::*;
7-
pub use self::ValuePairs::*;
1+
pub use at::DefineOpaqueTypes;
2+
pub use freshen::TypeFreshener;
3+
pub use lexical_region_resolve::RegionResolutionError;
4+
pub use relate::combine::CombineFields;
85
pub use relate::combine::ObligationEmittingRelation;
9-
use rustc_data_structures::captures::Captures;
10-
use rustc_data_structures::undo_log::UndoLogs;
11-
use rustc_middle::infer::unify_key::EffectVarValue;
12-
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
13-
14-
use self::opaque_types::OpaqueTypeStorage;
15-
pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
6+
pub use relate::StructurallyRelateAliases;
7+
pub use rustc_middle::ty::IntVarValue;
8+
pub use BoundRegionConversionTime::*;
9+
pub use RegionVariableOrigin::*;
10+
pub use SubregionOrigin::*;
11+
pub use ValuePairs::*;
1612

1713
use crate::traits::{
1814
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine, TraitEngineExt,
1915
};
20-
16+
use error_reporting::TypeErrCtxt;
17+
use free_regions::RegionRelations;
18+
use lexical_region_resolve::LexicalRegionResolutions;
19+
use opaque_types::OpaqueTypeStorage;
20+
use region_constraints::{GenericKind, VarInfos, VerifyBound};
21+
use region_constraints::{RegionConstraintCollector, RegionConstraintStorage};
22+
use rustc_data_structures::captures::Captures;
2123
use rustc_data_structures::fx::FxIndexMap;
2224
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2325
use rustc_data_structures::sync::Lrc;
@@ -27,7 +29,9 @@ use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
2729
use rustc_hir::def_id::{DefId, LocalDefId};
2830
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
2931
use rustc_middle::infer::unify_key::ConstVariableValue;
32+
use rustc_middle::infer::unify_key::EffectVarValue;
3033
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
34+
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
3135
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
3236
use rustc_middle::mir::ConstraintCategory;
3337
use rustc_middle::traits::{select, DefiningAnchor};
@@ -36,42 +40,30 @@ use rustc_middle::ty::fold::BoundVarReplacerDelegate;
3640
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
3741
use rustc_middle::ty::relate::RelateResult;
3842
use rustc_middle::ty::visit::TypeVisitableExt;
39-
pub use rustc_middle::ty::IntVarValue;
4043
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
4144
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
4245
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
4346
use rustc_span::symbol::Symbol;
4447
use rustc_span::Span;
45-
48+
use snapshot::undo_log::InferCtxtUndoLogs;
4649
use std::cell::{Cell, RefCell};
4750
use std::fmt;
48-
49-
use self::error_reporting::TypeErrCtxt;
50-
use self::free_regions::RegionRelations;
51-
use self::lexical_region_resolve::LexicalRegionResolutions;
52-
use self::region_constraints::{GenericKind, VarInfos, VerifyBound};
53-
use self::region_constraints::{
54-
RegionConstraintCollector, RegionConstraintStorage, RegionSnapshot,
55-
};
56-
pub use self::relate::combine::CombineFields;
57-
pub use self::relate::StructurallyRelateAliases;
58-
use self::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
51+
use type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
5952

6053
pub mod at;
6154
pub mod canonical;
6255
pub mod error_reporting;
6356
pub mod free_regions;
6457
mod freshen;
65-
mod fudge;
6658
mod lexical_region_resolve;
6759
pub mod opaque_types;
6860
pub mod outlives;
6961
mod projection;
7062
pub mod region_constraints;
7163
mod relate;
7264
pub mod resolve;
65+
pub(crate) mod snapshot;
7366
pub mod type_variable;
74-
mod undo_log;
7567

7668
#[must_use]
7769
#[derive(Debug)]
@@ -738,13 +730,6 @@ impl<'tcx> InferOk<'tcx, ()> {
738730
}
739731
}
740732

741-
#[must_use = "once you start a snapshot, you should always consume it"]
742-
pub struct CombinedSnapshot<'tcx> {
743-
undo_snapshot: Snapshot<'tcx>,
744-
region_constraints_snapshot: RegionSnapshot,
745-
universe: ty::UniverseIndex,
746-
}
747-
748733
impl<'tcx> InferCtxt<'tcx> {
749734
pub fn dcx(&self) -> &'tcx DiagCtxt {
750735
self.tcx.dcx()
@@ -842,90 +827,6 @@ impl<'tcx> InferCtxt<'tcx> {
842827
}
843828
}
844829

845-
pub fn in_snapshot(&self) -> bool {
846-
UndoLogs::<UndoLog<'tcx>>::in_snapshot(&self.inner.borrow_mut().undo_log)
847-
}
848-
849-
pub fn num_open_snapshots(&self) -> usize {
850-
UndoLogs::<UndoLog<'tcx>>::num_open_snapshots(&self.inner.borrow_mut().undo_log)
851-
}
852-
853-
fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
854-
debug!("start_snapshot()");
855-
856-
let mut inner = self.inner.borrow_mut();
857-
858-
CombinedSnapshot {
859-
undo_snapshot: inner.undo_log.start_snapshot(),
860-
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
861-
universe: self.universe(),
862-
}
863-
}
864-
865-
#[instrument(skip(self, snapshot), level = "debug")]
866-
fn rollback_to(&self, snapshot: CombinedSnapshot<'tcx>) {
867-
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe } = snapshot;
868-
869-
self.universe.set(universe);
870-
871-
let mut inner = self.inner.borrow_mut();
872-
inner.rollback_to(undo_snapshot);
873-
inner.unwrap_region_constraints().rollback_to(region_constraints_snapshot);
874-
}
875-
876-
#[instrument(skip(self, snapshot), level = "debug")]
877-
fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) {
878-
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot: _, universe: _ } =
879-
snapshot;
880-
881-
self.inner.borrow_mut().commit(undo_snapshot);
882-
}
883-
884-
/// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`.
885-
#[instrument(skip(self, f), level = "debug")]
886-
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
887-
where
888-
F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,
889-
{
890-
let snapshot = self.start_snapshot();
891-
let r = f(&snapshot);
892-
debug!("commit_if_ok() -- r.is_ok() = {}", r.is_ok());
893-
match r {
894-
Ok(_) => {
895-
self.commit_from(snapshot);
896-
}
897-
Err(_) => {
898-
self.rollback_to(snapshot);
899-
}
900-
}
901-
r
902-
}
903-
904-
/// Execute `f` then unroll any bindings it creates.
905-
#[instrument(skip(self, f), level = "debug")]
906-
pub fn probe<R, F>(&self, f: F) -> R
907-
where
908-
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
909-
{
910-
let snapshot = self.start_snapshot();
911-
let r = f(&snapshot);
912-
self.rollback_to(snapshot);
913-
r
914-
}
915-
916-
/// Scan the constraints produced since `snapshot` and check whether
917-
/// we added any region constraints.
918-
pub fn region_constraints_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
919-
self.inner
920-
.borrow_mut()
921-
.unwrap_region_constraints()
922-
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
923-
}
924-
925-
pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
926-
self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
927-
}
928-
929830
pub fn can_sub<T>(&self, param_env: ty::ParamEnv<'tcx>, expected: T, actual: T) -> bool
930831
where
931832
T: at::ToTrace<'tcx>,

compiler/rustc_infer/src/infer/opaque_types/table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_data_structures::undo_log::UndoLogs;
22
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
33

4-
use crate::infer::{InferCtxtUndoLogs, UndoLog};
4+
use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
55

66
use super::{OpaqueTypeDecl, OpaqueTypeMap};
77

compiler/rustc_infer/src/infer/outlives/obligations.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ use crate::infer::outlives::components::{push_outlives_components, Component};
6363
use crate::infer::outlives::env::RegionBoundPairs;
6464
use crate::infer::outlives::verify::VerifyBoundCx;
6565
use crate::infer::resolve::OpportunisticRegionResolver;
66-
use crate::infer::{
67-
self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound,
68-
};
66+
use crate::infer::snapshot::undo_log::UndoLog;
67+
use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};
6968
use crate::traits::{ObligationCause, ObligationCauseCode};
7069
use rustc_data_structures::undo_log::UndoLogs;
7170
use rustc_middle::mir::ConstraintCategory;

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use super::*;
2-
use crate::infer::CombinedSnapshot;
3-
use rustc_data_structures::{
4-
fx::FxIndexMap,
5-
graph::{scc::Sccs, vec_graph::VecGraph},
6-
};
2+
use crate::infer::snapshot::CombinedSnapshot;
3+
use rustc_data_structures::fx::FxIndexMap;
4+
use rustc_data_structures::graph::{scc::Sccs, vec_graph::VecGraph};
75
use rustc_index::Idx;
86
use rustc_middle::ty::error::TypeError;
97
use rustc_middle::ty::relate::RelateResult;

0 commit comments

Comments
 (0)