Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #122151

Merged
merged 32 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d013b5a
Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimple…
weiznich Jan 12, 2024
7d428db
AST validation: Improve handling of inherent impls nested within func…
fmease Mar 4, 2024
2149c45
Bubble up the TyCtxtFeed
oli-obk Feb 14, 2024
31d0a64
Keep `TyCtxtFeed` around longer in the resolver
oli-obk Feb 14, 2024
3b9dfd3
Preserve the `Feed` in local tables
oli-obk Feb 14, 2024
30f2ec2
Eliminate all non-CRATE_DEF_ID uses of `feed_def_id`
oli-obk Feb 14, 2024
5a0c46a
Get rid of `feed_local_def_id`
oli-obk Feb 14, 2024
890dd58
Prevent leaking `Feed`s into query results
oli-obk Feb 19, 2024
3845be6
Prevent feeding `CRATE_DEF_ID` queries outside the resolver
oli-obk Feb 19, 2024
c696d4c
Remove a use of feed_local_crate and make it fail if used within queries
oli-obk Feb 19, 2024
ef00fae
Avoid using feed_unit_query from within queries
oli-obk Feb 19, 2024
b69607c
Add missing background color for top-level rust documentation page an…
GuillaumeGomez Mar 6, 2024
4a1f4ff
Include all library files in artifact summary on CI
Kobzol Mar 7, 2024
570376c
Don't pass a break scope to `Builder::break_for_else`
Zalathar Mar 1, 2024
b91ceb8
use file to write llvm linker script
lqd Mar 7, 2024
1c3fe15
record mtime in llvm linker script
lqd Mar 7, 2024
6ebeb1c
remove empty folder
lcnr Mar 7, 2024
de3c965
move mod into folder
lcnr Mar 7, 2024
cd549ae
sync (try_)instantiate_mir_and_normalize_erasing_regions implementation
klensy Mar 7, 2024
2339317
move snapshot handling into mod
lcnr Mar 7, 2024
f9405ed
cleanup imports
lcnr Mar 7, 2024
5ce3db2
make `std::os::unix::ucred` module private
kadiwa4 Mar 7, 2024
b0d7f2b
Rollup merge of #119888 - weiznich:stablize_diagnostic_namespace, r=c…
GuillaumeGomez Mar 7, 2024
4de78d2
Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkov
GuillaumeGomez Mar 7, 2024
2e3bde2
Rollup merge of #122004 - fmease:astvalidator-min-fix, r=compiler-errors
GuillaumeGomez Mar 7, 2024
3257e86
Rollup merge of #122087 - GuillaumeGomez:fix-rust-index-page, r=notri…
GuillaumeGomez Mar 7, 2024
fcb2cbc
Rollup merge of #122136 - Kobzol:opt-dist-lookup-logic, r=Mark-Simula…
GuillaumeGomez Mar 7, 2024
57aea38
Rollup merge of #122137 - Zalathar:if-break-scope, r=matthewjasper
GuillaumeGomez Mar 7, 2024
9e92e2a
Rollup merge of #122138 - lqd:llvm-mtime, r=clubby789
GuillaumeGomez Mar 7, 2024
010fc20
Rollup merge of #122141 - klensy:sync-me, r=lcnr
GuillaumeGomez Mar 7, 2024
cc6a570
Rollup merge of #122142 - lcnr:rustc_infer-cleanup, r=compiler-errors
GuillaumeGomez Mar 7, 2024
92d7e02
Rollup merge of #122147 - kadiwa4:private_impl_mods, r=workingjubilee
GuillaumeGomez Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> {
tcx.ensure_with_value().early_lint_checks(());
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
tcx.ensure_with_value().get_lang_items(());
let (mut resolver, krate) = tcx.resolver_for_lowering(()).steal();
let (mut resolver, krate) = tcx.resolver_for_lowering().steal();

let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
let mut owners = IndexVec::from_fn_n(
Expand Down
57 changes: 30 additions & 27 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,35 +929,38 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
only_trait: only_trait.then_some(()),
};

self.visibility_not_permitted(
&item.vis,
errors::VisibilityNotPermittedNote::IndividualImplItems,
);
if let &Unsafe::Yes(span) = unsafety {
self.dcx().emit_err(errors::InherentImplCannotUnsafe {
span: self_ty.span,
annotation_span: span,
annotation: "unsafe",
self_ty: self_ty.span,
});
}
if let &ImplPolarity::Negative(span) = polarity {
self.dcx().emit_err(error(span, "negative", false));
}
if let &Defaultness::Default(def_span) = defaultness {
self.dcx().emit_err(error(def_span, "`default`", true));
}
if let &Const::Yes(span) = constness {
self.dcx().emit_err(error(span, "`const`", true));
}
self.with_in_trait_impl(None, |this| {
this.visibility_not_permitted(
&item.vis,
errors::VisibilityNotPermittedNote::IndividualImplItems,
);
if let &Unsafe::Yes(span) = unsafety {
this.dcx().emit_err(errors::InherentImplCannotUnsafe {
span: self_ty.span,
annotation_span: span,
annotation: "unsafe",
self_ty: self_ty.span,
});
}
if let &ImplPolarity::Negative(span) = polarity {
this.dcx().emit_err(error(span, "negative", false));
}
if let &Defaultness::Default(def_span) = defaultness {
this.dcx().emit_err(error(def_span, "`default`", true));
}
if let &Const::Yes(span) = constness {
this.dcx().emit_err(error(span, "`const`", true));
}

self.visit_vis(&item.vis);
self.visit_ident(item.ident);
self.with_tilde_const(Some(DisallowTildeConstContext::Impl(item.span)), |this| {
this.visit_generics(generics)
this.visit_vis(&item.vis);
this.visit_ident(item.ident);
this.with_tilde_const(
Some(DisallowTildeConstContext::Impl(item.span)),
|this| this.visit_generics(generics),
);
this.visit_ty(self_ty);
walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
});
self.visit_ty(self_ty);
walk_list!(self, visit_assoc_item, items, AssocCtxt::Impl);
walk_list!(self, visit_attribute, &item.attrs);
return; // Avoid visiting again.
}
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
);
}
}
if !attr.is_doc_comment()
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
&& seg.ident.name == sym::diagnostic
&& !self.features.diagnostic_namespace
{
let msg = "`#[diagnostic]` attribute name space is experimental";
gate!(self, diagnostic_namespace, seg.ident.span, msg);
}

// Emit errors for non-staged-api crates.
if !self.features.staged_api {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ fn run_compiler(
}

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

if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
return early_exit();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
{
match self {
PrintExtra::AfterParsing { krate, .. } => f(krate),
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).borrow().1),
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering().borrow().1),
}
}

Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
}
AstTreeExpanded => {
debug!("pretty-printing expanded AST");
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1)
format!("{:#?}", ex.tcx().resolver_for_lowering().borrow().1)
}
Hir(s) => {
debug!("pretty printing HIR {:?}", s);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ declare_features! (
(accepted, derive_default_enum, "1.62.0", Some(86985)),
/// Allows the use of destructuring assignments.
(accepted, destructuring_assignment, "1.59.0", Some(71126)),
/// Allows using the `#[diagnostic]` attribute tool namespace
(accepted, diagnostic_namespace, "CURRENT_RUSTC_VERSION", Some(111996)),
/// Allows `#[doc(alias = "...")]`.
(accepted, doc_alias, "1.48.0", Some(50146)),
/// Allows `..` in tuple (struct) patterns.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ declare_features! (
(unstable, deprecated_safe, "1.61.0", Some(94978)),
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
/// Allows using the `#[diagnostic]` attribute tool namespace
(unstable, diagnostic_namespace, "1.73.0", Some(111996)),
/// Controls errors in trait implementations.
(unstable, do_not_recommend, "1.67.0", Some(51992)),
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_infer/src/infer/higher_ranked/README.md

This file was deleted.

143 changes: 22 additions & 121 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
pub use self::at::DefineOpaqueTypes;
pub use self::freshen::TypeFreshener;
pub use self::lexical_region_resolve::RegionResolutionError;
pub use self::BoundRegionConversionTime::*;
pub use self::RegionVariableOrigin::*;
pub use self::SubregionOrigin::*;
pub use self::ValuePairs::*;
pub use at::DefineOpaqueTypes;
pub use freshen::TypeFreshener;
pub use lexical_region_resolve::RegionResolutionError;
pub use relate::combine::CombineFields;
pub use relate::combine::ObligationEmittingRelation;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::infer::unify_key::EffectVarValue;
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};

use self::opaque_types::OpaqueTypeStorage;
pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
pub use relate::StructurallyRelateAliases;
pub use rustc_middle::ty::IntVarValue;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
pub use SubregionOrigin::*;
pub use ValuePairs::*;

use crate::traits::{
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine, TraitEngineExt,
};

use error_reporting::TypeErrCtxt;
use free_regions::RegionRelations;
use lexical_region_resolve::LexicalRegionResolutions;
use opaque_types::OpaqueTypeStorage;
use region_constraints::{GenericKind, VarInfos, VerifyBound};
use region_constraints::{RegionConstraintCollector, RegionConstraintStorage};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
Expand All @@ -27,7 +29,9 @@ use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::ConstVariableValue;
use rustc_middle::infer::unify_key::EffectVarValue;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::{select, DefiningAnchor};
Expand All @@ -36,42 +40,30 @@ use rustc_middle::ty::fold::BoundVarReplacerDelegate;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::relate::RelateResult;
use rustc_middle::ty::visit::TypeVisitableExt;
pub use rustc_middle::ty::IntVarValue;
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
use rustc_span::symbol::Symbol;
use rustc_span::Span;

use snapshot::undo_log::InferCtxtUndoLogs;
use std::cell::{Cell, RefCell};
use std::fmt;

use self::error_reporting::TypeErrCtxt;
use self::free_regions::RegionRelations;
use self::lexical_region_resolve::LexicalRegionResolutions;
use self::region_constraints::{GenericKind, VarInfos, VerifyBound};
use self::region_constraints::{
RegionConstraintCollector, RegionConstraintStorage, RegionSnapshot,
};
pub use self::relate::combine::CombineFields;
pub use self::relate::StructurallyRelateAliases;
use self::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use type_variable::{TypeVariableOrigin, TypeVariableOriginKind};

pub mod at;
pub mod canonical;
pub mod error_reporting;
pub mod free_regions;
mod freshen;
mod fudge;
mod lexical_region_resolve;
pub mod opaque_types;
pub mod outlives;
mod projection;
pub mod region_constraints;
mod relate;
pub mod resolve;
pub(crate) mod snapshot;
pub mod type_variable;
mod undo_log;

#[must_use]
#[derive(Debug)]
Expand Down Expand Up @@ -738,13 +730,6 @@ impl<'tcx> InferOk<'tcx, ()> {
}
}

#[must_use = "once you start a snapshot, you should always consume it"]
pub struct CombinedSnapshot<'tcx> {
undo_snapshot: Snapshot<'tcx>,
region_constraints_snapshot: RegionSnapshot,
universe: ty::UniverseIndex,
}

impl<'tcx> InferCtxt<'tcx> {
pub fn dcx(&self) -> &'tcx DiagCtxt {
self.tcx.dcx()
Expand Down Expand Up @@ -842,90 +827,6 @@ impl<'tcx> InferCtxt<'tcx> {
}
}

pub fn in_snapshot(&self) -> bool {
UndoLogs::<UndoLog<'tcx>>::in_snapshot(&self.inner.borrow_mut().undo_log)
}

pub fn num_open_snapshots(&self) -> usize {
UndoLogs::<UndoLog<'tcx>>::num_open_snapshots(&self.inner.borrow_mut().undo_log)
}

fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
debug!("start_snapshot()");

let mut inner = self.inner.borrow_mut();

CombinedSnapshot {
undo_snapshot: inner.undo_log.start_snapshot(),
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
universe: self.universe(),
}
}

#[instrument(skip(self, snapshot), level = "debug")]
fn rollback_to(&self, snapshot: CombinedSnapshot<'tcx>) {
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe } = snapshot;

self.universe.set(universe);

let mut inner = self.inner.borrow_mut();
inner.rollback_to(undo_snapshot);
inner.unwrap_region_constraints().rollback_to(region_constraints_snapshot);
}

#[instrument(skip(self, snapshot), level = "debug")]
fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) {
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot: _, universe: _ } =
snapshot;

self.inner.borrow_mut().commit(undo_snapshot);
}

/// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`.
#[instrument(skip(self, f), level = "debug")]
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
where
F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,
{
let snapshot = self.start_snapshot();
let r = f(&snapshot);
debug!("commit_if_ok() -- r.is_ok() = {}", r.is_ok());
match r {
Ok(_) => {
self.commit_from(snapshot);
}
Err(_) => {
self.rollback_to(snapshot);
}
}
r
}

/// Execute `f` then unroll any bindings it creates.
#[instrument(skip(self, f), level = "debug")]
pub fn probe<R, F>(&self, f: F) -> R
where
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
{
let snapshot = self.start_snapshot();
let r = f(&snapshot);
self.rollback_to(snapshot);
r
}

/// Scan the constraints produced since `snapshot` and check whether
/// we added any region constraints.
pub fn region_constraints_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
self.inner
.borrow_mut()
.unwrap_region_constraints()
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
}

pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
}

pub fn can_sub<T>(&self, param_env: ty::ParamEnv<'tcx>, expected: T, actual: T) -> bool
where
T: at::ToTrace<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/opaque_types/table.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};

use crate::infer::{InferCtxtUndoLogs, UndoLog};
use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};

use super::{OpaqueTypeDecl, OpaqueTypeMap};

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::outlives::verify::VerifyBoundCx;
use crate::infer::resolve::OpportunisticRegionResolver;
use crate::infer::{
self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound,
};
use crate::infer::snapshot::undo_log::UndoLog;
use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::mir::ConstraintCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::*;
use crate::infer::CombinedSnapshot;
use rustc_data_structures::{
fx::FxIndexMap,
graph::{scc::Sccs, vec_graph::VecGraph},
};
use crate::infer::snapshot::CombinedSnapshot;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::graph::{scc::Sccs, vec_graph::VecGraph};
use rustc_index::Idx;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::relate::RelateResult;
Expand Down
Loading
Loading