Auto merge of #122151 - GuillaumeGomez:rollup-hfxr9kv, r=GuillaumeGomez

Rollup of 10 pull requests

Successful merges:

 - #119888 (Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimplemented]` attribute)
 - #121089 (Remove `feed_local_def_id`)
 - #122004 (AST validation: Improve handling of inherent impls nested within functions and anon consts)
 - #122087 (Add missing background color for top-level rust documentation page and increase contrast by setting text color to black)
 - #122136 (Include all library files in artifact summary on CI)
 - #122137 (Don't pass a break scope to `Builder::break_for_else`)
 - #122138 (Record mtime in bootstrap's LLVM linker script)
 - #122141 (sync (try_)instantiate_mir_and_normalize_erasing_regions implementation)
 - #122142 (cleanup rustc_infer)
 - #122147 (Make `std::os::unix::ucred` module private)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-03-07 22:43:18 +00:00
commit 9823f17315
70 changed files with 599 additions and 644 deletions

View file

@ -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(

View file

@ -929,35 +929,38 @@ fn visit_item(&mut self, item: &'a Item) {
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.
}

View file

@ -206,14 +206,6 @@ macro_rules! gate_doc { ($($s:literal { $($name:ident => $feature:ident)* })*) =
);
}
}
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 {

View file

@ -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();

View file

@ -229,7 +229,7 @@ fn with_krate<F, R>(&self, f: F) -> R
{
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),
}
}
@ -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);

View file

@ -146,6 +146,8 @@ macro_rules! 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.

View file

@ -436,8 +436,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
(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(...))]`.

View file

@ -1,8 +0,0 @@
To learn more about how Higher-ranked trait bounds work in the _old_ trait
solver, see [this chapter][oldhrtb] of the rustc-dev-guide.
To learn more about how they work in the _new_ trait solver, see [this
chapter][newhrtb].
[oldhrtb]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
[newhrtb]: https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference.html#placeholders-and-universes

View file

@ -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;
@ -27,7 +29,9 @@
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};
@ -36,33 +40,21 @@
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;
@ -70,8 +62,8 @@
pub mod region_constraints;
mod relate;
pub mod resolve;
pub(crate) mod snapshot;
pub mod type_variable;
mod undo_log;
#[must_use]
#[derive(Debug)]
@ -738,13 +730,6 @@ pub fn into_obligations(self) -> PredicateObligations<'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()
@ -842,90 +827,6 @@ fn combine_fields<'a>(
}
}
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>,

View file

@ -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};

View file

@ -63,9 +63,8 @@
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;

View file

@ -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;

View file

@ -3,9 +3,8 @@
use self::CombineMapType::*;
use self::UndoLog::*;
use super::{
InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin,
};
use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin};
use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
@ -360,7 +359,7 @@ pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx> {
///
/// Not legal during a snapshot.
pub fn into_infos_and_data(self) -> (VarInfos, RegionConstraintData<'tcx>) {
assert!(!UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
assert!(!UndoLogs::<UndoLog<'_>>::in_snapshot(&self.undo_log));
(mem::take(&mut self.storage.var_infos), mem::take(&mut self.storage.data))
}
@ -377,7 +376,7 @@ pub fn into_infos_and_data(self) -> (VarInfos, RegionConstraintData<'tcx>) {
///
/// Not legal during a snapshot.
pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> {
assert!(!UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
assert!(!UndoLogs::<UndoLog<'_>>::in_snapshot(&self.undo_log));
// If you add a new field to `RegionConstraintCollector`, you
// should think carefully about whether it needs to be cleared

View file

@ -1,7 +1,7 @@
//! Helper routines for higher-ranked things. See the `doc` module at
//! the end of the file for details.
use crate::infer::CombinedSnapshot;
use crate::infer::snapshot::CombinedSnapshot;
use crate::infer::InferCtxt;
use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::relate::RelateResult;

View file

@ -2,9 +2,9 @@
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
use super::type_variable::TypeVariableOrigin;
use super::InferCtxt;
use super::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::InferCtxt;
use crate::infer::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable};
use rustc_data_structures::snapshot_vec as sv;
use rustc_data_structures::unify as ut;

View file

@ -0,0 +1,102 @@
use super::region_constraints::RegionSnapshot;
use super::InferCtxt;
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::ty;
mod fudge;
pub(crate) mod undo_log;
use undo_log::{Snapshot, UndoLog};
#[must_use = "once you start a snapshot, you should always consume it"]
pub struct CombinedSnapshot<'tcx> {
pub(super) undo_snapshot: Snapshot<'tcx>,
region_constraints_snapshot: RegionSnapshot,
universe: ty::UniverseIndex,
}
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)
}
}

View file

@ -2,7 +2,7 @@
use super::PredicateObligation;
use crate::infer::InferCtxtUndoLogs;
use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
use rustc_data_structures::{
snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage},

View file

@ -280,7 +280,7 @@ fn configure_and_expand(
fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
let sess = tcx.sess;
let (resolver, krate) = &*tcx.resolver_for_lowering(()).borrow();
let (resolver, krate) = &*tcx.resolver_for_lowering().borrow();
let mut lint_buffer = resolver.lint_buffer.steal();
if sess.opts.unstable_opts.input_stats {
@ -531,10 +531,10 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}
fn resolver_for_lowering<'tcx>(
fn resolver_for_lowering_raw<'tcx>(
tcx: TyCtxt<'tcx>,
(): (),
) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
let arenas = Resolver::arenas();
let _ = tcx.registered_tools(()); // Uses `crate_for_resolver`.
let (krate, pre_configured_attrs) = tcx.crate_for_resolver(()).steal();
@ -549,16 +549,15 @@ fn resolver_for_lowering<'tcx>(
ast_lowering: untracked_resolver_for_lowering,
} = resolver.into_outputs();
let feed = tcx.feed_unit_query();
feed.resolutions(tcx.arena.alloc(untracked_resolutions));
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
let resolutions = tcx.arena.alloc(untracked_resolutions);
(tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate)))), resolutions)
}
pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) {
// Make sure name resolution and macro expansion is run for
// the side-effect of providing a complete set of all
// accessed files and env vars.
let _ = tcx.resolver_for_lowering(());
let _ = tcx.resolver_for_lowering();
let sess = tcx.sess;
let _timer = sess.timer("write_dep_info");
@ -607,7 +606,10 @@ pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) {
let providers = &mut Providers::default();
providers.analysis = analysis;
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
providers.resolver_for_lowering = resolver_for_lowering;
providers.resolver_for_lowering_raw = resolver_for_lowering_raw;
providers.stripped_cfg_items =
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
providers.early_lint_checks = early_lint_checks;
proc_macro_decls::provide(providers);
rustc_const_eval::provide(providers);

View file

@ -8,8 +8,7 @@
use rustc_data_structures::steal::Steal;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, OnceLock, WorkerLocal};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_hir::definitions::Definitions;
use rustc_incremental::setup_dep_graph;
use rustc_metadata::creader::CStore;
@ -144,10 +143,8 @@ pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>
stable_crate_id,
)) as _);
let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
let source_span = AppendOnlyIndexVec::new();
let _id = source_span.push(krate.spans.inner_span);
debug_assert_eq!(_id, CRATE_DEF_ID);
let untracked = Untracked { cstore, source_span, definitions };
let untracked =
Untracked { cstore, source_span: AppendOnlyIndexVec::new(), definitions };
let qcx = passes::create_global_ctxt(
self.compiler,
@ -172,9 +169,6 @@ pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>
)));
feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs))));
feed.output_filenames(Arc::new(outputs));
let feed = tcx.feed_local_def_id(CRATE_DEF_ID);
feed.def_kind(DefKind::Mod);
});
Ok(qcx)
})

View file

@ -125,12 +125,11 @@
}
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
feedable
no_hash
desc { "getting the resolver outputs" }
}
query resolver_for_lowering(_: ()) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
query resolver_for_lowering_raw(_: ()) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
eval_always
no_hash
desc { "getting the resolver for lowering" }
@ -2216,7 +2215,6 @@
/// Should not be called for the local crate before the resolver outputs are created, as it
/// is only fed there.
query stripped_cfg_items(cnum: CrateNum) -> &'tcx [StrippedCfgItem] {
feedable
desc { "getting cfg-ed out item names" }
separate_provide_extern
}

View file

@ -39,7 +39,7 @@
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal};
use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal};
#[cfg(parallel_compiler)]
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordSet;
@ -60,7 +60,7 @@
use rustc_session::cstore::{CrateStoreDyn, Untracked};
use rustc_session::lint::Lint;
use rustc_session::{Limit, MetadataKind, Session};
use rustc_span::def_id::{DefPathHash, StableCrateId};
use rustc_span::def_id::{DefPathHash, StableCrateId, CRATE_DEF_ID};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx};
@ -74,6 +74,7 @@
use std::fmt;
use std::hash::{Hash, Hasher};
use std::iter;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Bound, Deref};
@ -498,14 +499,55 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
key: KEY,
}
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY> {}
/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
/// Use this to pass around when you have a `TyCtxt` elsewhere.
/// Just an optimization to save space and not store hundreds of
/// `TyCtxtFeed` in the resolver.
#[derive(Copy, Clone)]
pub struct Feed<'tcx, KEY: Copy> {
_tcx: PhantomData<TyCtxt<'tcx>>,
// Do not allow direct access, as downstream code must not mutate this field.
key: KEY,
}
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for Feed<'_, KEY> {}
impl<T: fmt::Debug + Copy> fmt::Debug for Feed<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.key.fmt(f)
}
}
/// Some workarounds to use cases that cannot use `create_def`.
/// Do not add new ways to create `TyCtxtFeed` without consulting
/// with T-compiler and making an analysis about why your addition
/// does not cause incremental compilation issues.
impl<'tcx> TyCtxt<'tcx> {
/// Can only be fed before queries are run, and is thus exempt from any
/// incremental issues. Do not use except for the initial query feeding.
pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()> {
self.dep_graph.assert_ignored();
TyCtxtFeed { tcx: self, key: () }
}
/// Can only be fed before queries are run, and is thus exempt from any
/// incremental issues. Do not use except for the initial query feeding.
pub fn feed_local_crate(self) -> TyCtxtFeed<'tcx, CrateNum> {
self.dep_graph.assert_ignored();
TyCtxtFeed { tcx: self, key: LOCAL_CRATE }
}
pub fn feed_local_def_id(self, key: LocalDefId) -> TyCtxtFeed<'tcx, LocalDefId> {
/// Only used in the resolver to register the `CRATE_DEF_ID` `DefId` and feed
/// some queries for it. It will panic if used twice.
pub fn create_local_crate_def_id(self, span: Span) -> TyCtxtFeed<'tcx, LocalDefId> {
let key = self.untracked().source_span.push(span);
assert_eq!(key, CRATE_DEF_ID);
TyCtxtFeed { tcx: self, key }
}
@ -523,6 +565,23 @@ impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> {
pub fn key(&self) -> KEY {
self.key
}
#[inline(always)]
pub fn downgrade(self) -> Feed<'tcx, KEY> {
Feed { _tcx: PhantomData, key: self.key }
}
}
impl<'tcx, KEY: Copy> Feed<'tcx, KEY> {
#[inline(always)]
pub fn key(&self) -> KEY {
self.key
}
#[inline(always)]
pub fn upgrade(self, tcx: TyCtxt<'tcx>) -> TyCtxtFeed<'tcx, KEY> {
TyCtxtFeed { tcx, key: self.key }
}
}
impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
@ -1067,7 +1126,7 @@ pub fn create_def(
// needs to be re-evaluated.
self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
let feed = self.feed_local_def_id(def_id);
let feed = TyCtxtFeed { tcx: self, key: def_id };
feed.def_kind(def_kind);
// Unique types created for closures participate in type privacy checking.
// They have visibilities inherited from the module they are defined in.
@ -2304,6 +2363,10 @@ pub fn module_children_local(self, def_id: LocalDefId) -> &'tcx [ModChild] {
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
}
pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
self.resolver_for_lowering_raw(()).0
}
/// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl.
pub fn impl_trait_ref(

View file

@ -694,6 +694,7 @@ pub fn instantiate_mir<T>(&self, tcx: TyCtxt<'tcx>, v: EarlyBinder<&T>) -> T
}
#[inline(always)]
// Keep me in sync with try_instantiate_mir_and_normalize_erasing_regions
pub fn instantiate_mir_and_normalize_erasing_regions<T>(
&self,
tcx: TyCtxt<'tcx>,
@ -701,16 +702,17 @@ pub fn instantiate_mir_and_normalize_erasing_regions<T>(
v: EarlyBinder<T>,
) -> T
where
T: TypeFoldable<TyCtxt<'tcx>> + Clone,
T: TypeFoldable<TyCtxt<'tcx>>,
{
if let Some(args) = self.args_for_mir_body() {
tcx.instantiate_and_normalize_erasing_regions(args, param_env, v)
} else {
tcx.normalize_erasing_regions(param_env, v.skip_binder())
tcx.normalize_erasing_regions(param_env, v.instantiate_identity())
}
}
#[inline(always)]
// Keep me in sync with instantiate_mir_and_normalize_erasing_regions
pub fn try_instantiate_mir_and_normalize_erasing_regions<T>(
&self,
tcx: TyCtxt<'tcx>,

View file

@ -32,6 +32,7 @@
pub use generics::*;
pub use intrinsic::IntrinsicDef;
use rustc_ast as ast;
use rustc_ast::expand::StrippedCfgItem;
use rustc_ast::node_id::NodeMap;
pub use rustc_ast_ir::{try_visit, Movability, Mutability};
use rustc_attr as attr;
@ -85,7 +86,8 @@
Const, ConstData, ConstInt, ConstKind, Expr, ScalarInt, UnevaluatedConst, ValTree,
};
pub use self::context::{
tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed,
tls, CtxtInterners, DeducedParamAttrs, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt,
TyCtxtFeed,
};
pub use self::instance::{Instance, InstanceDef, ShortInstance, UnusedGenericParams};
pub use self::list::List;
@ -189,6 +191,7 @@ pub struct ResolverGlobalCtxt {
pub doc_link_resolutions: FxHashMap<LocalDefId, DocLinkResMap>,
pub doc_link_traits_in_scope: FxHashMap<LocalDefId, Vec<DefId>>,
pub all_macro_rules: FxHashMap<Symbol, Res<ast::NodeId>>,
pub stripped_cfg_items: Steal<Vec<StrippedCfgItem>>,
}
/// Resolutions that should only be used for lowering.

View file

@ -83,7 +83,6 @@ pub(crate) fn expr_into_dest(
block,
cond,
Some(condition_scope), // Temp scope
condition_scope,
source_info,
true, // Declare `let` bindings normally
));
@ -156,7 +155,6 @@ pub(crate) fn expr_into_dest(
block,
lhs,
Some(condition_scope), // Temp scope
condition_scope,
source_info,
// This flag controls how inner `let` expressions are lowered,
// but either way there shouldn't be any of those in here.

View file

@ -37,9 +37,6 @@ struct ThenElseArgs {
/// Used as the temp scope for lowering `expr`. If absent (for match guards),
/// `self.local_scope()` is used.
temp_scope_override: Option<region::Scope>,
/// Scope to pass to [`Builder::break_for_else`]. Must match the scope used
/// by the enclosing call to [`Builder::in_if_then_scope`].
break_scope: region::Scope,
variable_source_info: SourceInfo,
/// Forwarded to [`Builder::lower_let_expr`] when lowering [`ExprKind::Let`].
/// When false (for match guards), `let` bindings won't be declared.
@ -58,19 +55,13 @@ pub(crate) fn then_else_break(
block: BasicBlock,
expr_id: ExprId,
temp_scope_override: Option<region::Scope>,
break_scope: region::Scope,
variable_source_info: SourceInfo,
declare_let_bindings: bool,
) -> BlockAnd<()> {
self.then_else_break_inner(
block,
expr_id,
ThenElseArgs {
temp_scope_override,
break_scope,
variable_source_info,
declare_let_bindings,
},
ThenElseArgs { temp_scope_override, variable_source_info, declare_let_bindings },
)
}
@ -97,11 +88,7 @@ fn then_else_break_inner(
this.then_else_break_inner(
block,
lhs,
ThenElseArgs {
break_scope: local_scope,
declare_let_bindings: true,
..args
},
ThenElseArgs { declare_let_bindings: true, ..args },
)
});
let rhs_success_block = unpack!(this.then_else_break_inner(
@ -130,14 +117,10 @@ fn then_else_break_inner(
this.then_else_break_inner(
block,
arg,
ThenElseArgs {
break_scope: local_scope,
declare_let_bindings: true,
..args
},
ThenElseArgs { declare_let_bindings: true, ..args },
)
});
this.break_for_else(success_block, args.break_scope, args.variable_source_info);
this.break_for_else(success_block, args.variable_source_info);
failure_block.unit()
}
ExprKind::Scope { region_scope, lint_level, value } => {
@ -151,7 +134,6 @@ fn then_else_break_inner(
block,
expr,
pat,
args.break_scope,
Some(args.variable_source_info.scope),
args.variable_source_info.span,
args.declare_let_bindings,
@ -170,7 +152,7 @@ fn then_else_break_inner(
let source_info = this.source_info(expr_span);
this.cfg.terminate(block, source_info, term);
this.break_for_else(else_block, args.break_scope, source_info);
this.break_for_else(else_block, source_info);
then_block.unit()
}
@ -1911,7 +1893,6 @@ pub(crate) fn lower_let_expr(
mut block: BasicBlock,
expr_id: ExprId,
pat: &Pat<'tcx>,
else_target: region::Scope,
source_scope: Option<SourceScope>,
span: Span,
declare_bindings: bool,
@ -1933,7 +1914,7 @@ pub(crate) fn lower_let_expr(
let expr_place = expr_place_builder.try_to_place(self);
let opt_expr_place = expr_place.as_ref().map(|place| (Some(place), expr_span));
let otherwise_post_guard_block = otherwise_candidate.pre_binding_block.unwrap();
self.break_for_else(otherwise_post_guard_block, else_target, self.source_info(expr_span));
self.break_for_else(otherwise_post_guard_block, self.source_info(expr_span));
if declare_bindings {
self.declare_bindings(source_scope, pat.span.to(span), pat, None, opt_expr_place);
@ -2110,7 +2091,6 @@ fn bind_and_guard_matched_candidate<'pat>(
block,
guard,
None, // Use `self.local_scope()` as the temp scope
match_scope,
this.source_info(arm.span),
false, // For guards, `let` bindings are declared separately
)
@ -2443,7 +2423,7 @@ pub(crate) fn ast_let_else(
None,
true,
);
this.break_for_else(failure, *let_else_scope, this.source_info(initializer_span));
this.break_for_else(failure, this.source_info(initializer_span));
matching.unit()
});
matching.and(failure)

View file

@ -683,20 +683,23 @@ pub(crate) fn break_scope(
self.cfg.start_new_block().unit()
}
pub(crate) fn break_for_else(
&mut self,
block: BasicBlock,
target: region::Scope,
source_info: SourceInfo,
) {
let scope_index = self.scopes.scope_index(target, source_info.span);
/// Sets up the drops for breaking from `block` due to an `if` condition
/// that turned out to be false.
///
/// Must be called in the context of [`Builder::in_if_then_scope`], so that
/// there is an if-then scope to tell us what the target scope is.
pub(crate) fn break_for_else(&mut self, block: BasicBlock, source_info: SourceInfo) {
let if_then_scope = self
.scopes
.if_then_scope
.as_mut()
.as_ref()
.unwrap_or_else(|| span_bug!(source_info.span, "no if-then scope found"));
assert_eq!(if_then_scope.region_scope, target, "breaking to incorrect scope");
let target = if_then_scope.region_scope;
let scope_index = self.scopes.scope_index(target, source_info.span);
// Upgrade `if_then_scope` to `&mut`.
let if_then_scope = self.scopes.if_then_scope.as_mut().expect("upgrading & to &mut");
let mut drop_idx = ROOT_NODE;
let drops = &mut if_then_scope.else_drops;

View file

@ -87,7 +87,7 @@ fn visit_attribute(&mut self, attr: &'ast Attribute) {
/// Traverses and collects the debugger visualizers for a specific crate.
fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualizerFile> {
let resolver_and_krate = tcx.resolver_for_lowering(()).borrow();
let resolver_and_krate = tcx.resolver_for_lowering().borrow();
let krate = &*resolver_and_krate.1;
let mut visitor = DebuggerVisualizerCollector { sess: tcx.sess, visualizers: Vec::new() };

View file

@ -243,7 +243,7 @@ fn collect_item_extended(
/// Traverses and collects all the lang items in all crates.
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
let resolver = tcx.resolver_for_lowering(()).borrow();
let resolver = tcx.resolver_for_lowering().borrow();
let (resolver, krate) = &*resolver;
// Initialize the collector.

View file

@ -25,6 +25,7 @@
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
use rustc_metadata::creader::LoadedMacro;
use rustc_middle::metadata::ModChild;
use rustc_middle::ty::Feed;
use rustc_middle::{bug, ty};
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -407,7 +408,7 @@ fn build_reduced_graph_for_use_tree(
// Top level use tree reuses the item's id and list stems reuse their parent
// use tree's ids, so in both cases their visibilities are already filled.
if nested && !list_stem {
self.r.feed_visibility(self.r.local_def_id(id), vis);
self.r.feed_visibility(self.r.feed(id), vis);
}
let mut prefix_iter = parent_prefix
@ -632,7 +633,7 @@ fn build_reduced_graph_for_struct_variant(
&mut self,
fields: &[ast::FieldDef],
ident: Ident,
def_id: LocalDefId,
feed: Feed<'tcx, LocalDefId>,
adt_res: Res,
adt_vis: ty::Visibility,
adt_span: Span,
@ -643,7 +644,8 @@ fn build_reduced_graph_for_struct_variant(
// Define a name in the type namespace if it is not anonymous.
self.r.define(parent, ident, TypeNS, (adt_res, adt_vis, adt_span, expansion));
self.r.feed_visibility(def_id, adt_vis);
self.r.feed_visibility(feed, adt_vis);
let def_id = feed.key();
// Record field names for error reporting.
self.insert_field_def_ids(def_id, fields);
@ -653,14 +655,15 @@ fn build_reduced_graph_for_struct_variant(
match &field.ty.kind {
ast::TyKind::AnonStruct(id, nested_fields)
| ast::TyKind::AnonUnion(id, nested_fields) => {
let local_def_id = self.r.local_def_id(*id);
let feed = self.r.feed(*id);
let local_def_id = feed.key();
let def_id = local_def_id.to_def_id();
let def_kind = self.r.tcx.def_kind(local_def_id);
let res = Res::Def(def_kind, def_id);
self.build_reduced_graph_for_struct_variant(
&nested_fields,
Ident::empty(),
local_def_id,
feed,
res,
// Anonymous adts inherit visibility from their parent adts.
adt_vis,
@ -680,12 +683,13 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
let ident = item.ident;
let sp = item.span;
let vis = self.resolve_visibility(&item.vis);
let local_def_id = self.r.local_def_id(item.id);
let feed = self.r.feed(item.id);
let local_def_id = feed.key();
let def_id = local_def_id.to_def_id();
let def_kind = self.r.tcx.def_kind(def_id);
let res = Res::Def(def_kind, def_id);
self.r.feed_visibility(local_def_id, vis);
self.r.feed_visibility(feed, vis);
match item.kind {
ItemKind::Use(ref use_tree) => {
@ -762,7 +766,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
self.build_reduced_graph_for_struct_variant(
vdata.fields(),
ident,
local_def_id,
feed,
res,
vis,
sp,
@ -795,10 +799,11 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
}
ret_fields.push(field_vis.to_def_id());
}
let ctor_def_id = self.r.local_def_id(ctor_node_id);
let feed = self.r.feed(ctor_node_id);
let ctor_def_id = feed.key();
let ctor_res = self.res(ctor_def_id);
self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, sp, expansion));
self.r.feed_visibility(ctor_def_id, ctor_vis);
self.r.feed_visibility(feed, ctor_vis);
// We need the field visibility spans also for the constructor for E0603.
self.insert_field_visibilities_local(ctor_def_id.to_def_id(), vdata.fields());
@ -812,7 +817,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
self.build_reduced_graph_for_struct_variant(
vdata.fields(),
ident,
local_def_id,
feed,
res,
vis,
sp,
@ -919,7 +924,8 @@ fn build_reduced_graph_for_extern_crate(
/// Constructs the reduced graph for one foreign item.
fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) {
let local_def_id = self.r.local_def_id(item.id);
let feed = self.r.feed(item.id);
let local_def_id = feed.key();
let def_id = local_def_id.to_def_id();
let ns = match item.kind {
ForeignItemKind::Fn(..) => ValueNS,
@ -931,7 +937,7 @@ fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) {
let expansion = self.parent_scope.expansion;
let vis = self.resolve_visibility(&item.vis);
self.r.define(parent, item.ident, ns, (self.res(def_id), vis, item.span, expansion));
self.r.feed_visibility(local_def_id, vis);
self.r.feed_visibility(feed, vis);
}
fn build_reduced_graph_for_block(&mut self, block: &Block) {
@ -1218,7 +1224,8 @@ fn insert_unused_macro(&mut self, ident: Ident, def_id: LocalDefId, node_id: Nod
fn define_macro(&mut self, item: &ast::Item) -> MacroRulesScopeRef<'a> {
let parent_scope = self.parent_scope;
let expansion = parent_scope.expansion;
let def_id = self.r.local_def_id(item.id);
let feed = self.r.feed(item.id);
let def_id = feed.key();
let (res, ident, span, macro_rules) = match &item.kind {
ItemKind::MacroDef(def) => (self.res(def_id), item.ident, item.span, def.macro_rules),
ItemKind::Fn(..) => match self.proc_macro_stub(item) {
@ -1269,7 +1276,7 @@ fn define_macro(&mut self, item: &ast::Item) -> MacroRulesScopeRef<'a> {
self.r.check_reserved_macro_name(ident, res);
self.insert_unused_macro(ident, def_id, item.id);
}
self.r.feed_visibility(def_id, vis);
self.r.feed_visibility(feed, vis);
let scope = self.r.arenas.alloc_macro_rules_scope(MacroRulesScope::Binding(
self.r.arenas.alloc_macro_rules_binding(MacroRulesBinding {
parent_macro_rules_scope: parent_scope.macro_rules,
@ -1293,7 +1300,7 @@ fn define_macro(&mut self, item: &ast::Item) -> MacroRulesScopeRef<'a> {
self.insert_unused_macro(ident, def_id, item.id);
}
self.r.define(module, ident, MacroNS, (res, vis, span, expansion));
self.r.feed_visibility(def_id, vis);
self.r.feed_visibility(feed, vis);
self.parent_scope.macro_rules
}
}
@ -1385,7 +1392,8 @@ fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
}
let vis = self.resolve_visibility(&item.vis);
let local_def_id = self.r.local_def_id(item.id);
let feed = self.r.feed(item.id);
let local_def_id = feed.key();
let def_id = local_def_id.to_def_id();
if !(ctxt == AssocCtxt::Impl
@ -1395,7 +1403,7 @@ fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
// Trait impl item visibility is inherited from its trait when not specified
// explicitly. In that case we cannot determine it here in early resolve,
// so we leave a hole in the visibility table to be filled later.
self.r.feed_visibility(local_def_id, vis);
self.r.feed_visibility(feed, vis);
}
if ctxt == AssocCtxt::Trait {
@ -1469,7 +1477,7 @@ fn visit_field_def(&mut self, sf: &'b ast::FieldDef) {
self.visit_invoc(sf.id);
} else {
let vis = self.resolve_visibility(&sf.vis);
self.r.feed_visibility(self.r.local_def_id(sf.id), vis);
self.r.feed_visibility(self.r.feed(sf.id), vis);
visit::walk_field_def(self, sf);
}
}
@ -1487,10 +1495,11 @@ fn visit_variant(&mut self, variant: &'b ast::Variant) {
let ident = variant.ident;
// Define a name in the type namespace.
let def_id = self.r.local_def_id(variant.id);
let feed = self.r.feed(variant.id);
let def_id = feed.key();
let vis = self.resolve_visibility(&variant.vis);
self.r.define(parent, ident, TypeNS, (self.res(def_id), vis, variant.span, expn_id));
self.r.feed_visibility(def_id, vis);
self.r.feed_visibility(feed, vis);
// If the variant is marked as non_exhaustive then lower the visibility to within the crate.
let ctor_vis =
@ -1502,10 +1511,11 @@ fn visit_variant(&mut self, variant: &'b ast::Variant) {
// Define a constructor name in the value namespace.
if let Some(ctor_node_id) = variant.data.ctor_node_id() {
let ctor_def_id = self.r.local_def_id(ctor_node_id);
let feed = self.r.feed(ctor_node_id);
let ctor_def_id = feed.key();
let ctor_res = self.res(ctor_def_id);
self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, variant.span, expn_id));
self.r.feed_visibility(ctor_def_id, ctor_vis);
self.r.feed_visibility(feed, ctor_vis);
}
// Record field names for error reporting.

View file

@ -38,14 +38,16 @@ fn create_def(
"create_def(node_id={:?}, def_kind={:?}, parent_def={:?})",
node_id, def_kind, parent_def
);
self.resolver.create_def(
parent_def,
node_id,
name,
def_kind,
self.expansion.to_expn_id(),
span.with_parent(None),
)
self.resolver
.create_def(
parent_def,
node_id,
name,
def_kind,
self.expansion.to_expn_id(),
span.with_parent(None),
)
.def_id()
}
fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: LocalDefId, f: F) {

View file

@ -3121,7 +3121,7 @@ fn check_trait_item<F>(
);
rustc_middle::ty::Visibility::Public
};
this.r.feed_visibility(this.r.local_def_id(id), vis);
this.r.feed_visibility(this.r.feed(id), vis);
};
let Some(binding) = binding else {

View file

@ -52,8 +52,8 @@
use rustc_middle::middle::privacy::EffectiveVisibilities;
use rustc_middle::query::Providers;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, MainDefinition, RegisteredTools, TyCtxt};
use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs};
use rustc_middle::ty::{self, MainDefinition, RegisteredTools, TyCtxt, TyCtxtFeed};
use rustc_middle::ty::{Feed, ResolverGlobalCtxt, ResolverOutputs};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
use rustc_session::lint::LintBuffer;
@ -1117,7 +1117,7 @@ pub struct Resolver<'a, 'tcx> {
next_node_id: NodeId,
node_id_to_def_id: NodeMap<LocalDefId>,
node_id_to_def_id: NodeMap<Feed<'tcx, LocalDefId>>,
def_id_to_node_id: IndexVec<LocalDefId, ast::NodeId>,
/// Indices of unnamed struct or variant fields with unresolved attributes.
@ -1233,11 +1233,19 @@ fn as_mut(&mut self) -> &mut Resolver<'a, 'tcx> {
impl<'tcx> Resolver<'_, 'tcx> {
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
self.node_id_to_def_id.get(&node).copied()
self.opt_feed(node).map(|f| f.key())
}
fn local_def_id(&self, node: NodeId) -> LocalDefId {
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
self.feed(node).key()
}
fn opt_feed(&self, node: NodeId) -> Option<Feed<'tcx, LocalDefId>> {
self.node_id_to_def_id.get(&node).copied()
}
fn feed(&self, node: NodeId) -> Feed<'tcx, LocalDefId> {
self.opt_feed(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
}
fn local_def_kind(&self, node: NodeId) -> DefKind {
@ -1253,18 +1261,19 @@ fn create_def(
def_kind: DefKind,
expn_id: ExpnId,
span: Span,
) -> LocalDefId {
) -> TyCtxtFeed<'tcx, LocalDefId> {
let data = def_kind.def_path_data(name);
assert!(
!self.node_id_to_def_id.contains_key(&node_id),
"adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
node_id,
data,
self.tcx.definitions_untracked().def_key(self.node_id_to_def_id[&node_id]),
self.tcx.definitions_untracked().def_key(self.node_id_to_def_id[&node_id].key()),
);
// FIXME: remove `def_span` body, pass in the right spans here and call `tcx.at().create_def()`
let def_id = self.tcx.create_def(parent, name, def_kind).def_id();
let feed = self.tcx.create_def(parent, name, def_kind);
let def_id = feed.def_id();
// Create the definition.
if expn_id != ExpnId::root() {
@ -1281,11 +1290,11 @@ fn create_def(
// we don't need a mapping from `NodeId` to `LocalDefId`.
if node_id != ast::DUMMY_NODE_ID {
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
self.node_id_to_def_id.insert(node_id, def_id);
self.node_id_to_def_id.insert(node_id, feed.downgrade());
}
assert_eq!(self.def_id_to_node_id.push(node_id), def_id);
def_id
feed
}
fn item_generics_num_lifetimes(&self, def_id: DefId) -> usize {
@ -1333,7 +1342,11 @@ pub fn new(
let mut def_id_to_node_id = IndexVec::default();
assert_eq!(def_id_to_node_id.push(CRATE_NODE_ID), CRATE_DEF_ID);
let mut node_id_to_def_id = NodeMap::default();
node_id_to_def_id.insert(CRATE_NODE_ID, CRATE_DEF_ID);
let crate_feed = tcx.create_local_crate_def_id(crate_span);
crate_feed.def_kind(DefKind::Mod);
let crate_feed = crate_feed.downgrade();
node_id_to_def_id.insert(CRATE_NODE_ID, crate_feed);
let mut invocation_parents = FxHashMap::default();
invocation_parents.insert(LocalExpnId::ROOT, (CRATE_DEF_ID, ImplTraitContext::Existential));
@ -1484,7 +1497,7 @@ pub fn new(
let root_parent_scope = ParentScope::module(graph_root, &resolver);
resolver.invocation_parent_scopes.insert(LocalExpnId::ROOT, root_parent_scope);
resolver.feed_visibility(CRATE_DEF_ID, ty::Visibility::Public);
resolver.feed_visibility(crate_feed, ty::Visibility::Public);
resolver
}
@ -1532,9 +1545,10 @@ pub fn arenas() -> ResolverArenas<'a> {
Default::default()
}
fn feed_visibility(&mut self, def_id: LocalDefId, vis: ty::Visibility) {
self.tcx.feed_local_def_id(def_id).visibility(vis.to_def_id());
self.visibilities_for_hashing.push((def_id, vis));
fn feed_visibility(&mut self, feed: Feed<'tcx, LocalDefId>, vis: ty::Visibility) {
let feed = feed.upgrade(self.tcx);
feed.visibility(vis.to_def_id());
self.visibilities_for_hashing.push((feed.def_id(), vis));
}
pub fn into_outputs(self) -> ResolverOutputs {
@ -1547,12 +1561,16 @@ pub fn into_outputs(self) -> ResolverOutputs {
let confused_type_with_std_module = self.confused_type_with_std_module;
let effective_visibilities = self.effective_visibilities;
self.tcx.feed_local_crate().stripped_cfg_items(self.tcx.arena.alloc_from_iter(
self.stripped_cfg_items.into_iter().filter_map(|item| {
let parent_module = self.node_id_to_def_id.get(&item.parent_module)?.to_def_id();
Some(StrippedCfgItem { parent_module, name: item.name, cfg: item.cfg })
}),
));
let stripped_cfg_items = Steal::new(
self.stripped_cfg_items
.into_iter()
.filter_map(|item| {
let parent_module =
self.node_id_to_def_id.get(&item.parent_module)?.key().to_def_id();
Some(StrippedCfgItem { parent_module, name: item.name, cfg: item.cfg })
})
.collect(),
);
let global_ctxt = ResolverGlobalCtxt {
expn_that_defined,
@ -1569,6 +1587,7 @@ pub fn into_outputs(self) -> ResolverOutputs {
doc_link_resolutions: self.doc_link_resolutions,
doc_link_traits_in_scope: self.doc_link_traits_in_scope,
all_macro_rules: self.all_macro_rules,
stripped_cfg_items,
};
let ast_lowering = ty::ResolverAstLowering {
legacy_const_generic_args: self.legacy_const_generic_args,
@ -1578,7 +1597,11 @@ pub fn into_outputs(self) -> ResolverOutputs {
lifetimes_res_map: self.lifetimes_res_map,
extra_lifetime_params_map: self.extra_lifetime_params_map,
next_node_id: self.next_node_id,
node_id_to_def_id: self.node_id_to_def_id,
node_id_to_def_id: self
.node_id_to_def_id
.into_items()
.map(|(k, f)| (k, f.key()))
.collect(),
def_id_to_node_id: self.def_id_to_node_id,
trait_map: self.trait_map,
lifetime_elision_allowed: self.lifetime_elision_allowed,

View file

@ -202,6 +202,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(diagnostic_namespace))]
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
@ -223,7 +224,6 @@
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deprecated_suggestion)]
#![feature(diagnostic_namespace)]
#![feature(doc_cfg)]
#![feature(doc_cfg_hide)]
#![feature(doc_notable_trait)]

View file

@ -95,22 +95,6 @@ mod platform {
pub mod raw;
pub mod thread;
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "nto",
))]
pub mod ucred;
/// A prelude for conveniently writing platform-specific code.
///
/// Includes all extension traits, and some important type definitions.

View file

@ -12,6 +12,20 @@
mod stream;
#[cfg(all(test, not(target_os = "emscripten")))]
mod tests;
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "nto",
))]
mod ucred;
#[stable(feature = "unix_socket", since = "1.10.0")]
pub use self::addr::*;
@ -24,3 +38,18 @@
pub use self::listener::*;
#[stable(feature = "unix_socket", since = "1.10.0")]
pub use self::stream::*;
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "nto",
))]
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
pub use self::ucred::*;

View file

@ -1,3 +1,16 @@
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "macos",
target_os = "watchos",
target_os = "netbsd",
target_os = "openbsd"
))]
use super::{peer_cred, UCred};
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
use super::{sockaddr_un, SocketAddr};
@ -5,40 +18,12 @@
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::Shutdown;
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "macos",
target_os = "watchos",
target_os = "netbsd",
target_os = "openbsd"
))]
use crate::os::unix::ucred;
use crate::path::Path;
use crate::sys::cvt;
use crate::sys::net::Socket;
use crate::sys_common::{AsInner, FromInner};
use crate::time::Duration;
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "tvos",
target_os = "macos",
target_os = "watchos",
target_os = "netbsd",
target_os = "openbsd"
))]
pub use ucred::UCred;
/// A Unix stream socket.
///
/// # Examples
@ -247,7 +232,7 @@ pub fn peer_addr(&self) -> io::Result<SocketAddr> {
target_os = "openbsd"
))]
pub fn peer_cred(&self) -> io::Result<UCred> {
ucred::peer_cred(self)
peer_cred(self)
}
/// Sets the read timeout for the socket.

View file

@ -1,5 +1,3 @@
//! Unix peer credentials.
// NOTE: Code in this file is heavily based on work done in PR 13 from the tokio-uds repository on
// GitHub.
//
@ -26,7 +24,7 @@ pub struct UCred {
}
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use self::impl_linux::peer_cred;
pub(super) use self::impl_linux::peer_cred;
#[cfg(any(
target_os = "dragonfly",
@ -34,13 +32,13 @@ pub struct UCred {
target_os = "openbsd",
target_os = "netbsd"
))]
pub use self::impl_bsd::peer_cred;
pub(super) use self::impl_bsd::peer_cred;
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
pub use self::impl_mac::peer_cred;
pub(super) use self::impl_mac::peer_cred;
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod impl_linux {
mod impl_linux {
use super::UCred;
use crate::os::unix::io::AsRawFd;
use crate::os::unix::net::UnixStream;
@ -82,7 +80,7 @@ pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
target_os = "netbsd",
target_os = "nto",
))]
pub mod impl_bsd {
mod impl_bsd {
use super::UCred;
use crate::io;
use crate::os::unix::io::AsRawFd;
@ -99,7 +97,7 @@ pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
}
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
pub mod impl_mac {
mod impl_mac {
use super::UCred;
use crate::os::unix::io::AsRawFd;
use crate::os::unix::net::UnixStream;

View file

@ -2047,7 +2047,15 @@ fn install_llvm_file(
// projects like miri link against librustc_driver.so. We don't use a symlink, as
// these are not allowed inside rustup components.
let link = t!(fs::read_link(source));
t!(std::fs::write(full_dest, format!("INPUT({})\n", link.display())));
let mut linker_script = t!(fs::File::create(full_dest));
t!(write!(linker_script, "INPUT({})\n", link.display()));
// We also want the linker script to have the same mtime as the source, otherwise it
// can trigger rebuilds.
let meta = t!(fs::metadata(source));
if let Ok(mtime) = meta.modified() {
t!(linker_script.set_modified(mtime));
}
}
} else {
builder.install(&source, destination, 0o644);

View file

@ -5,12 +5,13 @@ body {
margin: 0 auto;
padding: 0 15px;
font-size: 18px;
color: #333;
color: #000;
line-height: 1.428571429;
-webkit-box-sizing: unset;
-moz-box-sizing: unset;
box-sizing: unset;
background: #fff;
}
@media (min-width: 768px) {
body {
@ -39,7 +40,6 @@ h4, h5, h6 {
padding: 5px 10px;
}
h5, h6 {
color: black;
text-decoration: underline;
}

View file

@ -1,84 +0,0 @@
# `diagnostic_namespace`
The tracking issue for this feature is: [#111996]
[#111996]: https://github.com/rust-lang/rust/issues/111996
------------------------
The `diagnostic_namespace` feature permits customization of compilation errors.
## diagnostic::on_unimplemented
With [#114452] support for `diagnostic::on_unimplemented` was added.
When used on a trait declaration, the following options are available:
* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message
The attribute will hint to the compiler to use these in error messages:
```rust
// some library
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
message = "cannot insert element",
label = "cannot be put into a table",
note = "see <link> for more information about the Table api"
)]
pub trait Element {
// ...
}
```
```rust,compile_fail,E0277
# #![feature(diagnostic_namespace)]
#
# #[diagnostic::on_unimplemented(
# message = "cannot insert element",
# label = "cannot be put into a table",
# note = "see <link> for more information about the Table api"
# )]
# pub trait Element {
# // ...
# }
# struct Table;
# impl Table {
# fn insert<T: Element>(&self, element: T) {
# // ..
# }
# }
# fn main() {
# let table = Table;
# let element = ();
// user code
table.insert(element);
# }
```
```text
error[E0277]: cannot insert element
--> src/main.rs:24:18
|
24 | table.insert(element);
| ------ ^^^^^^^ cannot be put into a table
| |
| required by a bound introduced by this call
|
= help: the trait `Element` is not implemented for `<type>`
= note: see <link> for more information about the Table api
note: required by a bound in `Table::insert`
--> src/main.rs:15:18
|
15 | fn insert<T: Element>(&self, element: T) {
| ^^^^^^^ required by this bound in `Table::insert`
For more information about this error, try `rustc --explain E0277`.
```
See [RFC 3368] for more information.
[#114452]: https://github.com/rust-lang/rust/pull/114452
[RFC 3368]: https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md

View file

@ -15,21 +15,8 @@ pub fn print_binary_sizes(env: &Environment) -> anyhow::Result<()> {
let root = env.build_artifacts().join("stage2");
let all_lib_files = get_files_from_dir(&root.join("lib"), None)?;
let mut files = get_files_from_dir(&root.join("bin"), None)?;
files.extend(get_files_from_dir(&root.join("lib"), Some(".so"))?);
// libLLVM.so can be named libLLVM.so.<suffix>, so we try to explicitly add it here if it
// wasn't found by the above call.
if !files.iter().any(|f| f.file_name().unwrap_or_default().starts_with("libLLVM")) {
if let Some(llvm_lib) =
all_lib_files.iter().find(|f| f.file_name().unwrap_or_default().starts_with("libLLVM"))
{
files.push(llvm_lib.clone());
}
}
files.extend(get_files_from_dir(&root.join("lib"), None)?);
files.sort_unstable();
let items: Vec<_> = files

View file

@ -1,4 +1,3 @@
#![feature(diagnostic_namespace)]
//@ check-pass
//@ aux-build:proc-macro-helper.rs

View file

@ -1,13 +0,0 @@
#[diagnostic::non_existing_attribute]
//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658]
//~|WARNING unknown diagnostic attribute [unknown_or_malformed_diagnostic_attributes]
pub trait Bar {
}
#[diagnostic::non_existing_attribute(with_option = "foo")]
//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658]
//~|WARNING unknown diagnostic attribute [unknown_or_malformed_diagnostic_attributes]
struct Foo;
fn main() {
}

View file

@ -1,37 +0,0 @@
error[E0658]: `#[diagnostic]` attribute name space is experimental
--> $DIR/feature-gate-diagnostic_namespace.rs:1:3
|
LL | #[diagnostic::non_existing_attribute]
| ^^^^^^^^^^
|
= note: see issue #111996 <https://github.com/rust-lang/rust/issues/111996> for more information
= help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `#[diagnostic]` attribute name space is experimental
--> $DIR/feature-gate-diagnostic_namespace.rs:7:3
|
LL | #[diagnostic::non_existing_attribute(with_option = "foo")]
| ^^^^^^^^^^
|
= note: see issue #111996 <https://github.com/rust-lang/rust/issues/111996> for more information
= help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
warning: unknown diagnostic attribute
--> $DIR/feature-gate-diagnostic_namespace.rs:1:15
|
LL | #[diagnostic::non_existing_attribute]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: unknown diagnostic attribute
--> $DIR/feature-gate-diagnostic_namespace.rs:7:15
|
LL | #[diagnostic::non_existing_attribute(with_option = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,4 +1,3 @@
#![feature(diagnostic_namespace)]
//@ check-pass
#[diagnostic::non_existing_attribute]
//~^WARN unknown diagnostic attribute

View file

@ -1,5 +1,5 @@
warning: unknown diagnostic attribute
--> $DIR/non_existing_attributes_accepted.rs:3:15
--> $DIR/non_existing_attributes_accepted.rs:2:15
|
LL | #[diagnostic::non_existing_attribute]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[diagnostic::non_existing_attribute]
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: unknown diagnostic attribute
--> $DIR/non_existing_attributes_accepted.rs:8:15
--> $DIR/non_existing_attributes_accepted.rs:7:15
|
LL | #[diagnostic::non_existing_attribute(with_option = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
message = "Message",
note = "Note",

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
on(_Self = "&str"),
//~^WARN malformed `on_unimplemented` attribute

View file

@ -1,5 +1,5 @@
warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definitions
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:24:1
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:22:1
|
LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:4:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:2:5
|
LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here
@ -15,7 +15,7 @@ LL | on(_Self = "&str"),
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:10:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:8:5
|
LL | parent_label = "in this scope",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -23,7 +23,7 @@ LL | parent_label = "in this scope",
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:13:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:11:5
|
LL | append_const_msg
| ^^^^^^^^^^^^^^^^ invalid option found here
@ -31,7 +31,7 @@ LL | append_const_msg
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:19:32
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:17:32
|
LL | #[diagnostic::on_unimplemented = "Message"]
| ^^^^^^^^^^^ invalid option found here
@ -39,7 +39,7 @@ LL | #[diagnostic::on_unimplemented = "Message"]
= help: only `message`, `note` and `label` are allowed as options
warning: there is no parameter `from_desugaring` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -47,7 +47,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `direct` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -55,7 +55,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `cause` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -63,7 +63,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `integral` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -71,7 +71,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `integer` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -79,7 +79,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `float` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -87,7 +87,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `_Self` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -95,7 +95,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `crate_local` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -103,7 +103,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `Trait` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -111,7 +111,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `ItemContext` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -119,7 +119,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= help: expect either a generic argument name or `{Self}` as format argument
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:4:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:2:5
|
LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here
@ -128,7 +128,7 @@ LL | on(_Self = "&str"),
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:10:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:8:5
|
LL | parent_label = "in this scope",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -137,7 +137,7 @@ LL | parent_label = "in this scope",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:13:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:11:5
|
LL | append_const_msg
| ^^^^^^^^^^^^^^^^ invalid option found here
@ -146,7 +146,7 @@ LL | append_const_msg
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: trait has `()` and `i32` as params
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:61:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:59:15
|
LL | takes_foo(());
| --------- ^^ trait has `()` and `i32` as params
@ -156,18 +156,18 @@ LL | takes_foo(());
= help: the trait `Foo<i32>` is not implemented for `()`
= note: trait has `()` and `i32` as params
help: this trait has no implementations, consider adding one
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:17:1
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:15:1
|
LL | trait Foo<T> {}
| ^^^^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:54:22
|
LL | fn takes_foo(_: impl Foo<i32>) {}
| ^^^^^^^^ required by this bound in `takes_foo`
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:19:32
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:17:32
|
LL | #[diagnostic::on_unimplemented = "Message"]
| ^^^^^^^^^^^ invalid option found here
@ -176,7 +176,7 @@ LL | #[diagnostic::on_unimplemented = "Message"]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `(): Bar` is not satisfied
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:63:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:61:15
|
LL | takes_bar(());
| --------- ^^ the trait `Bar` is not implemented for `()`
@ -185,13 +185,13 @@ LL | takes_bar(());
|
= help: the trait `Bar` is implemented for `i32`
note: required by a bound in `takes_bar`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:57:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:55:22
|
LL | fn takes_bar(_: impl Bar) {}
| ^^^ required by this bound in `takes_bar`
warning: there is no parameter `from_desugaring` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -200,7 +200,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `direct` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -209,7 +209,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `cause` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -218,7 +218,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `integral` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -227,7 +227,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `integer` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:31:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:29:5
|
LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -236,7 +236,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `float` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -245,7 +245,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `_Self` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -254,7 +254,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `crate_local` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -263,7 +263,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `Trait` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -272,7 +272,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `ItemContext` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:42:5
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:40:5
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -281,7 +281,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {from_desugaring}{direct}{cause}{integral}{integer}
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:65:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:63:15
|
LL | takes_baz(());
| --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext}
@ -290,12 +290,12 @@ LL | takes_baz(());
|
= help: the trait `Baz` is not implemented for `()`
help: this trait has no implementations, consider adding one
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:54:1
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:52:1
|
LL | trait Baz {}
| ^^^^^^^^^
note: required by a bound in `takes_baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:58:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:22
|
LL | fn takes_baz(_: impl Baz) {}
| ^^^ required by this bound in `takes_baz`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(unsupported = "foo")]
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute

View file

@ -1,5 +1,5 @@
warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definitions
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:8:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:6:1
|
LL | #[diagnostic::on_unimplemented(message = "Baz")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[diagnostic::on_unimplemented(message = "Baz")]
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:1:32
|
LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -15,7 +15,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:12:50
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:10:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -23,7 +23,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:15:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -31,7 +31,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:22:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:20:32
|
LL | #[diagnostic::on_unimplemented = "boom"]
| ^^^^^^^^ invalid option found here
@ -39,7 +39,7 @@ LL | #[diagnostic::on_unimplemented = "boom"]
= help: only `message`, `note` and `label` are allowed as options
warning: missing options for `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:24:1
|
LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -47,7 +47,7 @@ LL | #[diagnostic::on_unimplemented]
= help: at least one of the `message`, `note` and `label` options are expected
warning: there is no parameter `DoesNotExist` on trait `Test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:29:32
|
LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -55,7 +55,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
= help: expect either a generic argument name or `{Self}` as format argument
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:1:32
|
LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -64,7 +64,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:14
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:41:14
|
LL | take_foo(1_i32);
| -------- ^^^^^ the trait `Foo` is not implemented for `i32`
@ -72,18 +72,18 @@ LL | take_foo(1_i32);
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:6:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:4:1
|
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `take_foo`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:36:21
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:34:21
|
LL | fn take_foo(_: impl Foo) {}
| ^^^ required by this bound in `take_foo`
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:12:50
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:10:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -92,7 +92,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:45:14
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:14
|
LL | take_baz(1_i32);
| -------- ^^^^^ the trait `Baz` is not implemented for `i32`
@ -100,18 +100,18 @@ LL | take_baz(1_i32);
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:15:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:13:1
|
LL | trait Baz {}
| ^^^^^^^^^
note: required by a bound in `take_baz`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:37:21
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:35:21
|
LL | fn take_baz(_: impl Baz) {}
| ^^^ required by this bound in `take_baz`
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:15:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -120,7 +120,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:15
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:45:15
|
LL | take_boom(1_i32);
| --------- ^^^^^ the trait `Boom` is not implemented for `i32`
@ -128,18 +128,18 @@ LL | take_boom(1_i32);
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:20:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:18:1
|
LL | trait Boom {}
| ^^^^^^^^^^
note: required by a bound in `take_boom`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:22
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:36:22
|
LL | fn take_boom(_: impl Boom) {}
| ^^^^ required by this bound in `take_boom`
warning: missing options for `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:24:1
|
LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -148,7 +148,7 @@ LL | #[diagnostic::on_unimplemented]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Whatever` is not satisfied
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:19
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:19
|
LL | take_whatever(1_i32);
| ------------- ^^^^^ the trait `Whatever` is not implemented for `i32`
@ -156,18 +156,18 @@ LL | take_whatever(1_i32);
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:29:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:27:1
|
LL | trait Whatever {}
| ^^^^^^^^^^^^^^
note: required by a bound in `take_whatever`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:39:26
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:37:26
|
LL | fn take_whatever(_: impl Whatever) {}
| ^^^^^^^^ required by this bound in `take_whatever`
warning: there is no parameter `DoesNotExist` on trait `Test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:29:32
|
LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -176,7 +176,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {DoesNotExist}
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:51:15
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:15
|
LL | take_test(());
| --------- ^^ the trait `Test` is not implemented for `()`
@ -184,12 +184,12 @@ LL | take_test(());
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:34:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:32:1
|
LL | trait Test {}
| ^^^^^^^^^^
note: required by a bound in `take_test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:40:22
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:22
|
LL | fn take_test(_: impl Test) {}
| ^^^^ required by this bound in `take_test`

View file

@ -1,7 +0,0 @@
#[diagnostic::on_unimplemented(message = "Foo")]
//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658]
pub trait Bar {
}
fn main() {
}

View file

@ -1,13 +0,0 @@
error[E0658]: `#[diagnostic]` attribute name space is experimental
--> $DIR/feature-gate-diagnostic_on_unimplemented.rs:1:3
|
LL | #[diagnostic::on_unimplemented(message = "Foo")]
| ^^^^^^^^^^
|
= note: see issue #111996 <https://github.com/rust-lang/rust/issues/111996> for more information
= help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
if(Self = "()"),
//~^WARN malformed `on_unimplemented` attribute

View file

@ -1,5 +1,5 @@
warning: malformed `on_unimplemented` attribute
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:4:5
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:2:5
|
LL | if(Self = "()"),
| ^^^^^^^^^^^^^^^ invalid option found here
@ -8,7 +8,7 @@ LL | if(Self = "()"),
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: `message` is ignored due to previous definition of `message`
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:10:32
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:8:32
|
LL | message = "custom message",
| -------------------------- `message` is first declared here
@ -17,7 +17,7 @@ LL | #[diagnostic::on_unimplemented(message = "fallback!!")]
| ^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here
warning: malformed `on_unimplemented` attribute
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:4:5
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:2:5
|
LL | if(Self = "()"),
| ^^^^^^^^^^^^^^^ invalid option found here
@ -26,7 +26,7 @@ LL | if(Self = "()"),
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: `message` is ignored due to previous definition of `message`
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:10:32
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:8:32
|
LL | message = "custom message",
| -------------------------- `message` is first declared here
@ -37,7 +37,7 @@ LL | #[diagnostic::on_unimplemented(message = "fallback!!")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: custom message
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:20:15
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:18:15
|
LL | takes_foo(());
| --------- ^^ fallback label
@ -48,12 +48,12 @@ LL | takes_foo(());
= note: custom note
= note: fallback note
help: this trait has no implementations, consider adding one
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:15:1
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:13:1
|
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:17:22
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:15:22
|
LL | fn takes_foo(_: impl Foo) {}
| ^^^ required by this bound in `takes_foo`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(message = "Foo", label = "Bar", note = "Baz", note = "Boom")]
trait Foo {}

View file

@ -1,5 +1,5 @@
error[E0277]: Foo
--> $DIR/multiple_notes.rs:14:15
--> $DIR/multiple_notes.rs:12:15
|
LL | takes_foo(());
| --------- ^^ Bar
@ -10,18 +10,18 @@ LL | takes_foo(());
= note: Baz
= note: Boom
help: this trait has no implementations, consider adding one
--> $DIR/multiple_notes.rs:4:1
--> $DIR/multiple_notes.rs:2:1
|
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/multiple_notes.rs:10:22
--> $DIR/multiple_notes.rs:8:22
|
LL | fn takes_foo(_: impl Foo) {}
| ^^^ required by this bound in `takes_foo`
error[E0277]: Bar
--> $DIR/multiple_notes.rs:16:15
--> $DIR/multiple_notes.rs:14:15
|
LL | takes_bar(());
| --------- ^^ Foo
@ -32,12 +32,12 @@ LL | takes_bar(());
= note: Baz
= note: Baz2
help: this trait has no implementations, consider adding one
--> $DIR/multiple_notes.rs:8:1
--> $DIR/multiple_notes.rs:6:1
|
LL | trait Bar {}
| ^^^^^^^^^
note: required by a bound in `takes_bar`
--> $DIR/multiple_notes.rs:11:22
--> $DIR/multiple_notes.rs:9:22
|
LL | fn takes_bar(_: impl Bar) {}
| ^^^ required by this bound in `takes_bar`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(message = "Foo", label = "Bar", note = "Baz")]
trait Foo {}

View file

@ -1,5 +1,5 @@
error[E0277]: Foo
--> $DIR/on_unimplemented_simple.rs:9:15
--> $DIR/on_unimplemented_simple.rs:7:15
|
LL | takes_foo(());
| --------- ^^ Bar
@ -9,12 +9,12 @@ LL | takes_foo(());
= help: the trait `Foo` is not implemented for `()`
= note: Baz
help: this trait has no implementations, consider adding one
--> $DIR/on_unimplemented_simple.rs:4:1
--> $DIR/on_unimplemented_simple.rs:2:1
|
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/on_unimplemented_simple.rs:6:22
--> $DIR/on_unimplemented_simple.rs:4:22
|
LL | fn takes_foo(_: impl Foo) {}
| ^^^ required by this bound in `takes_foo`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
message = "first message",
label = "first label",

View file

@ -1,5 +1,5 @@
warning: `message` is ignored due to previous definition of `message`
--> $DIR/report_warning_on_duplicated_options.rs:9:5
--> $DIR/report_warning_on_duplicated_options.rs:7:5
|
LL | message = "first message",
| ------------------------- `message` is first declared here
@ -10,7 +10,7 @@ LL | message = "second message",
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: `label` is ignored due to previous definition of `label`
--> $DIR/report_warning_on_duplicated_options.rs:12:5
--> $DIR/report_warning_on_duplicated_options.rs:10:5
|
LL | label = "first label",
| --------------------- `label` is first declared here
@ -19,7 +19,7 @@ LL | label = "second label",
| ^^^^^^^^^^^^^^^^^^^^^^ `label` is already declared here
warning: `message` is ignored due to previous definition of `message`
--> $DIR/report_warning_on_duplicated_options.rs:9:5
--> $DIR/report_warning_on_duplicated_options.rs:7:5
|
LL | message = "first message",
| ------------------------- `message` is first declared here
@ -30,7 +30,7 @@ LL | message = "second message",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: `label` is ignored due to previous definition of `label`
--> $DIR/report_warning_on_duplicated_options.rs:12:5
--> $DIR/report_warning_on_duplicated_options.rs:10:5
|
LL | label = "first label",
| --------------------- `label` is first declared here
@ -41,7 +41,7 @@ LL | label = "second label",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: first message
--> $DIR/report_warning_on_duplicated_options.rs:23:15
--> $DIR/report_warning_on_duplicated_options.rs:21:15
|
LL | takes_foo(());
| --------- ^^ first label
@ -52,12 +52,12 @@ LL | takes_foo(());
= note: custom note
= note: second note
help: this trait has no implementations, consider adding one
--> $DIR/report_warning_on_duplicated_options.rs:17:1
--> $DIR/report_warning_on_duplicated_options.rs:15:1
|
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/report_warning_on_duplicated_options.rs:20:22
--> $DIR/report_warning_on_duplicated_options.rs:18:22
|
LL | fn takes_foo(_: impl Foo) {}
| ^^^ required by this bound in `takes_foo`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic]
//~^ERROR cannot find attribute `diagnostic` in this scope
pub struct Bar;

View file

@ -1,5 +1,5 @@
error: cannot find attribute `diagnostic` in this scope
--> $DIR/requires_path.rs:3:3
--> $DIR/requires_path.rs:1:3
|
LL | #[diagnostic]
| ^^^^^^^^^^

View file

@ -21,5 +21,5 @@ error: the compiler unexpectedly panicked. this is a bug.
query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

View file

@ -0,0 +1,35 @@
// Regression test for issue #89342 and for part of #119924.
//@ check-pass
struct Expr<const N: u32>;
trait Trait0 {
fn required(_: Expr<{
struct Type;
impl Type {
// This visibility qualifier used to get rejected.
pub fn perform() {}
}
0
}>);
}
trait Trait1 {}
impl Trait1 for ()
where
[(); {
struct Type;
impl Type {
// This visibility qualifier used to get rejected.
pub const STORE: Self = Self;
}
0
}]:
{}
fn main() {}

View file

@ -0,0 +1,15 @@
// Regression test for #121607 and for part of issue #119924.
//@ check-pass
trait Trait {
fn provided() {
pub struct Type;
impl Type {
// This visibility qualifier used to get rejected.
pub fn perform() {}
}
}
}
fn main() {}

View file

@ -0,0 +1,22 @@
// Regression test for part of issue #119924.
//@ check-pass
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Trait {
fn required();
}
impl const Trait for () {
fn required() {
pub struct Type;
impl Type {
// This visibility qualifier used to get rejected.
pub fn perform() {}
}
}
}
fn main() {}