1
Fork 0

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().early_lint_checks(());
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE); tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
tcx.ensure_with_value().get_lang_items(()); 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 ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
let mut owners = IndexVec::from_fn_n( let mut owners = IndexVec::from_fn_n(

View file

@ -929,35 +929,38 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
only_trait: only_trait.then_some(()), only_trait: only_trait.then_some(()),
}; };
self.visibility_not_permitted( self.with_in_trait_impl(None, |this| {
&item.vis, this.visibility_not_permitted(
errors::VisibilityNotPermittedNote::IndividualImplItems, &item.vis,
); errors::VisibilityNotPermittedNote::IndividualImplItems,
if let &Unsafe::Yes(span) = unsafety { );
self.dcx().emit_err(errors::InherentImplCannotUnsafe { if let &Unsafe::Yes(span) = unsafety {
span: self_ty.span, this.dcx().emit_err(errors::InherentImplCannotUnsafe {
annotation_span: span, span: self_ty.span,
annotation: "unsafe", annotation_span: span,
self_ty: self_ty.span, annotation: "unsafe",
}); self_ty: self_ty.span,
} });
if let &ImplPolarity::Negative(span) = polarity { }
self.dcx().emit_err(error(span, "negative", false)); if let &ImplPolarity::Negative(span) = polarity {
} this.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 &Defaultness::Default(def_span) = defaultness {
} this.dcx().emit_err(error(def_span, "`default`", true));
if let &Const::Yes(span) = constness { }
self.dcx().emit_err(error(span, "`const`", true)); if let &Const::Yes(span) = constness {
} this.dcx().emit_err(error(span, "`const`", true));
}
self.visit_vis(&item.vis); this.visit_vis(&item.vis);
self.visit_ident(item.ident); this.visit_ident(item.ident);
self.with_tilde_const(Some(DisallowTildeConstContext::Impl(item.span)), |this| { this.with_tilde_const(
this.visit_generics(generics) 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); walk_list!(self, visit_attribute, &item.attrs);
return; // Avoid visiting again. return; // Avoid visiting again.
} }

View file

@ -206,14 +206,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
); );
} }
} }
if !attr.is_doc_comment()
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
&& seg.ident.name == sym::diagnostic
&& !self.features.diagnostic_namespace
{
let msg = "`#[diagnostic]` attribute name space is experimental";
gate!(self, diagnostic_namespace, seg.ident.span, msg);
}
// Emit errors for non-staged-api crates. // Emit errors for non-staged-api crates.
if !self.features.staged_api { if !self.features.staged_api {

View file

@ -418,7 +418,7 @@ fn run_compiler(
} }
// Make sure name resolution and macro expansion is run. // 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 { if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
return early_exit(); return early_exit();

View file

@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
{ {
match self { match self {
PrintExtra::AfterParsing { krate, .. } => f(krate), 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 => { AstTreeExpanded => {
debug!("pretty-printing expanded AST"); debug!("pretty-printing expanded AST");
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1) format!("{:#?}", ex.tcx().resolver_for_lowering().borrow().1)
} }
Hir(s) => { Hir(s) => {
debug!("pretty printing HIR {:?}", s); debug!("pretty printing HIR {:?}", s);

View file

@ -146,6 +146,8 @@ declare_features! (
(accepted, derive_default_enum, "1.62.0", Some(86985)), (accepted, derive_default_enum, "1.62.0", Some(86985)),
/// Allows the use of destructuring assignments. /// Allows the use of destructuring assignments.
(accepted, destructuring_assignment, "1.59.0", Some(71126)), (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 = "...")]`. /// Allows `#[doc(alias = "...")]`.
(accepted, doc_alias, "1.48.0", Some(50146)), (accepted, doc_alias, "1.48.0", Some(50146)),
/// Allows `..` in tuple (struct) patterns. /// Allows `..` in tuple (struct) patterns.

View file

@ -436,8 +436,6 @@ declare_features! (
(unstable, deprecated_safe, "1.61.0", Some(94978)), (unstable, deprecated_safe, "1.61.0", Some(94978)),
/// Allows having using `suggestion` in the `#[deprecated]` attribute. /// Allows having using `suggestion` in the `#[deprecated]` attribute.
(unstable, deprecated_suggestion, "1.61.0", Some(94785)), (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. /// Controls errors in trait implementations.
(unstable, do_not_recommend, "1.67.0", Some(51992)), (unstable, do_not_recommend, "1.67.0", Some(51992)),
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. /// 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 at::DefineOpaqueTypes;
pub use self::freshen::TypeFreshener; pub use freshen::TypeFreshener;
pub use self::lexical_region_resolve::RegionResolutionError; pub use lexical_region_resolve::RegionResolutionError;
pub use self::BoundRegionConversionTime::*; pub use relate::combine::CombineFields;
pub use self::RegionVariableOrigin::*;
pub use self::SubregionOrigin::*;
pub use self::ValuePairs::*;
pub use relate::combine::ObligationEmittingRelation; pub use relate::combine::ObligationEmittingRelation;
use rustc_data_structures::captures::Captures; pub use relate::StructurallyRelateAliases;
use rustc_data_structures::undo_log::UndoLogs; pub use rustc_middle::ty::IntVarValue;
use rustc_middle::infer::unify_key::EffectVarValue; pub use BoundRegionConversionTime::*;
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey}; pub use RegionVariableOrigin::*;
pub use SubregionOrigin::*;
use self::opaque_types::OpaqueTypeStorage; pub use ValuePairs::*;
pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
use crate::traits::{ use crate::traits::{
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine, TraitEngineExt, 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::FxIndexMap;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
@ -27,7 +29,9 @@ use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues}; use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::ConstVariableValue; 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::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult}; use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
use rustc_middle::mir::ConstraintCategory; use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::{select, DefiningAnchor}; use rustc_middle::traits::{select, DefiningAnchor};
@ -36,33 +40,21 @@ use rustc_middle::ty::fold::BoundVarReplacerDelegate;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::relate::RelateResult; use rustc_middle::ty::relate::RelateResult;
use rustc_middle::ty::visit::TypeVisitableExt; 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::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid}; use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef}; use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_span::Span; use rustc_span::Span;
use snapshot::undo_log::InferCtxtUndoLogs;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::fmt; use std::fmt;
use type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
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};
pub mod at; pub mod at;
pub mod canonical; pub mod canonical;
pub mod error_reporting; pub mod error_reporting;
pub mod free_regions; pub mod free_regions;
mod freshen; mod freshen;
mod fudge;
mod lexical_region_resolve; mod lexical_region_resolve;
pub mod opaque_types; pub mod opaque_types;
pub mod outlives; pub mod outlives;
@ -70,8 +62,8 @@ mod projection;
pub mod region_constraints; pub mod region_constraints;
mod relate; mod relate;
pub mod resolve; pub mod resolve;
pub(crate) mod snapshot;
pub mod type_variable; pub mod type_variable;
mod undo_log;
#[must_use] #[must_use]
#[derive(Debug)] #[derive(Debug)]
@ -738,13 +730,6 @@ impl<'tcx> InferOk<'tcx, ()> {
} }
} }
#[must_use = "once you start a snapshot, you should always consume it"]
pub struct CombinedSnapshot<'tcx> {
undo_snapshot: Snapshot<'tcx>,
region_constraints_snapshot: RegionSnapshot,
universe: ty::UniverseIndex,
}
impl<'tcx> InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
pub fn dcx(&self) -> &'tcx DiagCtxt { pub fn dcx(&self) -> &'tcx DiagCtxt {
self.tcx.dcx() self.tcx.dcx()
@ -842,90 +827,6 @@ impl<'tcx> InferCtxt<'tcx> {
} }
} }
pub fn in_snapshot(&self) -> bool {
UndoLogs::<UndoLog<'tcx>>::in_snapshot(&self.inner.borrow_mut().undo_log)
}
pub fn num_open_snapshots(&self) -> usize {
UndoLogs::<UndoLog<'tcx>>::num_open_snapshots(&self.inner.borrow_mut().undo_log)
}
fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
debug!("start_snapshot()");
let mut inner = self.inner.borrow_mut();
CombinedSnapshot {
undo_snapshot: inner.undo_log.start_snapshot(),
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
universe: self.universe(),
}
}
#[instrument(skip(self, snapshot), level = "debug")]
fn rollback_to(&self, snapshot: CombinedSnapshot<'tcx>) {
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe } = snapshot;
self.universe.set(universe);
let mut inner = self.inner.borrow_mut();
inner.rollback_to(undo_snapshot);
inner.unwrap_region_constraints().rollback_to(region_constraints_snapshot);
}
#[instrument(skip(self, snapshot), level = "debug")]
fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) {
let CombinedSnapshot { undo_snapshot, region_constraints_snapshot: _, universe: _ } =
snapshot;
self.inner.borrow_mut().commit(undo_snapshot);
}
/// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`.
#[instrument(skip(self, f), level = "debug")]
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
where
F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,
{
let snapshot = self.start_snapshot();
let r = f(&snapshot);
debug!("commit_if_ok() -- r.is_ok() = {}", r.is_ok());
match r {
Ok(_) => {
self.commit_from(snapshot);
}
Err(_) => {
self.rollback_to(snapshot);
}
}
r
}
/// Execute `f` then unroll any bindings it creates.
#[instrument(skip(self, f), level = "debug")]
pub fn probe<R, F>(&self, f: F) -> R
where
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
{
let snapshot = self.start_snapshot();
let r = f(&snapshot);
self.rollback_to(snapshot);
r
}
/// Scan the constraints produced since `snapshot` and check whether
/// we added any region constraints.
pub fn region_constraints_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
self.inner
.borrow_mut()
.unwrap_region_constraints()
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
}
pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
}
pub fn can_sub<T>(&self, param_env: ty::ParamEnv<'tcx>, expected: T, actual: T) -> bool pub fn can_sub<T>(&self, param_env: ty::ParamEnv<'tcx>, expected: T, actual: T) -> bool
where where
T: at::ToTrace<'tcx>, T: at::ToTrace<'tcx>,

View file

@ -1,7 +1,7 @@
use rustc_data_structures::undo_log::UndoLogs; use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty}; 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}; use super::{OpaqueTypeDecl, OpaqueTypeMap};

View file

@ -63,9 +63,8 @@ use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::infer::outlives::env::RegionBoundPairs; use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::outlives::verify::VerifyBoundCx; use crate::infer::outlives::verify::VerifyBoundCx;
use crate::infer::resolve::OpportunisticRegionResolver; use crate::infer::resolve::OpportunisticRegionResolver;
use crate::infer::{ use crate::infer::snapshot::undo_log::UndoLog;
self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound, use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};
};
use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::undo_log::UndoLogs; use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::mir::ConstraintCategory; use rustc_middle::mir::ConstraintCategory;

View file

@ -1,9 +1,7 @@
use super::*; use super::*;
use crate::infer::CombinedSnapshot; use crate::infer::snapshot::CombinedSnapshot;
use rustc_data_structures::{ use rustc_data_structures::fx::FxIndexMap;
fx::FxIndexMap, use rustc_data_structures::graph::{scc::Sccs, vec_graph::VecGraph};
graph::{scc::Sccs, vec_graph::VecGraph},
};
use rustc_index::Idx; use rustc_index::Idx;
use rustc_middle::ty::error::TypeError; use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::relate::RelateResult; use rustc_middle::ty::relate::RelateResult;

View file

@ -3,9 +3,8 @@
use self::CombineMapType::*; use self::CombineMapType::*;
use self::UndoLog::*; use self::UndoLog::*;
use super::{ use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin};
InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin, use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
@ -360,7 +359,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
/// ///
/// Not legal during a snapshot. /// Not legal during a snapshot.
pub fn into_infos_and_data(self) -> (VarInfos, RegionConstraintData<'tcx>) { 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)) (mem::take(&mut self.storage.var_infos), mem::take(&mut self.storage.data))
} }
@ -377,7 +376,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
/// ///
/// Not legal during a snapshot. /// Not legal during a snapshot.
pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> { 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 // If you add a new field to `RegionConstraintCollector`, you
// should think carefully about whether it needs to be cleared // 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 //! Helper routines for higher-ranked things. See the `doc` module at
//! the end of the file for details. //! the end of the file for details.
use crate::infer::CombinedSnapshot; use crate::infer::snapshot::CombinedSnapshot;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use rustc_middle::ty::fold::FnMutDelegate; use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::relate::RelateResult; use rustc_middle::ty::relate::RelateResult;

View file

@ -2,9 +2,9 @@ use rustc_middle::infer::unify_key::{ConstVariableOriginKind, ConstVariableValue
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid}; use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
use super::type_variable::TypeVariableOrigin; use crate::infer::type_variable::TypeVariableOrigin;
use super::InferCtxt; use crate::infer::InferCtxt;
use super::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable}; use crate::infer::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable};
use rustc_data_structures::snapshot_vec as sv; use rustc_data_structures::snapshot_vec as sv;
use rustc_data_structures::unify as ut; 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 super::PredicateObligation;
use crate::infer::InferCtxtUndoLogs; use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
use rustc_data_structures::{ use rustc_data_structures::{
snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage}, snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage},

View file

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

View file

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

View file

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

View file

@ -39,7 +39,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal; 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)] #[cfg(parallel_compiler)]
use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordSet; use rustc_data_structures::unord::UnordSet;
@ -60,7 +60,7 @@ use rustc_session::config::CrateType;
use rustc_session::cstore::{CrateStoreDyn, Untracked}; use rustc_session::cstore::{CrateStoreDyn, Untracked};
use rustc_session::lint::Lint; use rustc_session::lint::Lint;
use rustc_session::{Limit, MetadataKind, Session}; 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::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx}; use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx};
@ -74,6 +74,7 @@ use std::cmp::Ordering;
use std::fmt; use std::fmt;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::iter; use std::iter;
use std::marker::PhantomData;
use std::mem; use std::mem;
use std::ops::{Bound, Deref}; use std::ops::{Bound, Deref};
@ -498,14 +499,55 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
key: KEY, 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> { 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, ()> { pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()> {
self.dep_graph.assert_ignored();
TyCtxtFeed { tcx: self, key: () } 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> { pub fn feed_local_crate(self) -> TyCtxtFeed<'tcx, CrateNum> {
self.dep_graph.assert_ignored();
TyCtxtFeed { tcx: self, key: LOCAL_CRATE } 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 } TyCtxtFeed { tcx: self, key }
} }
@ -523,6 +565,23 @@ impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> {
pub fn key(&self) -> KEY { pub fn key(&self) -> 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> { impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
@ -1067,7 +1126,7 @@ impl<'tcx> TyCtxt<'tcx> {
// needs to be re-evaluated. // needs to be re-evaluated.
self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE); 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); feed.def_kind(def_kind);
// Unique types created for closures participate in type privacy checking. // Unique types created for closures participate in type privacy checking.
// They have visibilities inherited from the module they are defined in. // They have visibilities inherited from the module they are defined in.
@ -2304,6 +2363,10 @@ impl<'tcx> TyCtxt<'tcx> {
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]) 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. /// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl. /// Return `None` if this is an inherent impl.
pub fn impl_trait_ref( pub fn impl_trait_ref(

View file

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

View file

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

View file

@ -83,7 +83,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
cond, cond,
Some(condition_scope), // Temp scope Some(condition_scope), // Temp scope
condition_scope,
source_info, source_info,
true, // Declare `let` bindings normally true, // Declare `let` bindings normally
)); ));
@ -156,7 +155,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
lhs, lhs,
Some(condition_scope), // Temp scope Some(condition_scope), // Temp scope
condition_scope,
source_info, source_info,
// This flag controls how inner `let` expressions are lowered, // This flag controls how inner `let` expressions are lowered,
// but either way there shouldn't be any of those in here. // 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), /// Used as the temp scope for lowering `expr`. If absent (for match guards),
/// `self.local_scope()` is used. /// `self.local_scope()` is used.
temp_scope_override: Option<region::Scope>, 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, variable_source_info: SourceInfo,
/// Forwarded to [`Builder::lower_let_expr`] when lowering [`ExprKind::Let`]. /// Forwarded to [`Builder::lower_let_expr`] when lowering [`ExprKind::Let`].
/// When false (for match guards), `let` bindings won't be declared. /// When false (for match guards), `let` bindings won't be declared.
@ -58,19 +55,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block: BasicBlock, block: BasicBlock,
expr_id: ExprId, expr_id: ExprId,
temp_scope_override: Option<region::Scope>, temp_scope_override: Option<region::Scope>,
break_scope: region::Scope,
variable_source_info: SourceInfo, variable_source_info: SourceInfo,
declare_let_bindings: bool, declare_let_bindings: bool,
) -> BlockAnd<()> { ) -> BlockAnd<()> {
self.then_else_break_inner( self.then_else_break_inner(
block, block,
expr_id, expr_id,
ThenElseArgs { ThenElseArgs { temp_scope_override, variable_source_info, declare_let_bindings },
temp_scope_override,
break_scope,
variable_source_info,
declare_let_bindings,
},
) )
} }
@ -97,11 +88,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.then_else_break_inner( this.then_else_break_inner(
block, block,
lhs, lhs,
ThenElseArgs { ThenElseArgs { declare_let_bindings: true, ..args },
break_scope: local_scope,
declare_let_bindings: true,
..args
},
) )
}); });
let rhs_success_block = unpack!(this.then_else_break_inner( let rhs_success_block = unpack!(this.then_else_break_inner(
@ -130,14 +117,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.then_else_break_inner( this.then_else_break_inner(
block, block,
arg, arg,
ThenElseArgs { ThenElseArgs { declare_let_bindings: true, ..args },
break_scope: local_scope,
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() failure_block.unit()
} }
ExprKind::Scope { region_scope, lint_level, value } => { ExprKind::Scope { region_scope, lint_level, value } => {
@ -151,7 +134,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
expr, expr,
pat, pat,
args.break_scope,
Some(args.variable_source_info.scope), Some(args.variable_source_info.scope),
args.variable_source_info.span, args.variable_source_info.span,
args.declare_let_bindings, args.declare_let_bindings,
@ -170,7 +152,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let source_info = this.source_info(expr_span); let source_info = this.source_info(expr_span);
this.cfg.terminate(block, source_info, term); 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() then_block.unit()
} }
@ -1911,7 +1893,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
mut block: BasicBlock, mut block: BasicBlock,
expr_id: ExprId, expr_id: ExprId,
pat: &Pat<'tcx>, pat: &Pat<'tcx>,
else_target: region::Scope,
source_scope: Option<SourceScope>, source_scope: Option<SourceScope>,
span: Span, span: Span,
declare_bindings: bool, declare_bindings: bool,
@ -1933,7 +1914,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let expr_place = expr_place_builder.try_to_place(self); 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 opt_expr_place = expr_place.as_ref().map(|place| (Some(place), expr_span));
let otherwise_post_guard_block = otherwise_candidate.pre_binding_block.unwrap(); 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 { if declare_bindings {
self.declare_bindings(source_scope, pat.span.to(span), pat, None, opt_expr_place); self.declare_bindings(source_scope, pat.span.to(span), pat, None, opt_expr_place);
@ -2110,7 +2091,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
guard, guard,
None, // Use `self.local_scope()` as the temp scope None, // Use `self.local_scope()` as the temp scope
match_scope,
this.source_info(arm.span), this.source_info(arm.span),
false, // For guards, `let` bindings are declared separately false, // For guards, `let` bindings are declared separately
) )
@ -2443,7 +2423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
None, None,
true, 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.unit()
}); });
matching.and(failure) matching.and(failure)

View file

@ -683,20 +683,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.cfg.start_new_block().unit() self.cfg.start_new_block().unit()
} }
pub(crate) fn break_for_else( /// Sets up the drops for breaking from `block` due to an `if` condition
&mut self, /// that turned out to be false.
block: BasicBlock, ///
target: region::Scope, /// Must be called in the context of [`Builder::in_if_then_scope`], so that
source_info: SourceInfo, /// 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 scope_index = self.scopes.scope_index(target, source_info.span);
let if_then_scope = self let if_then_scope = self
.scopes .scopes
.if_then_scope .if_then_scope
.as_mut() .as_ref()
.unwrap_or_else(|| span_bug!(source_info.span, "no if-then scope found")); .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 mut drop_idx = ROOT_NODE;
let drops = &mut if_then_scope.else_drops; let drops = &mut if_then_scope.else_drops;

View file

@ -87,7 +87,7 @@ impl<'ast> rustc_ast::visit::Visitor<'ast> for DebuggerVisualizerCollector<'_> {
/// Traverses and collects the debugger visualizers for a specific crate. /// Traverses and collects the debugger visualizers for a specific crate.
fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualizerFile> { 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 krate = &*resolver_and_krate.1;
let mut visitor = DebuggerVisualizerCollector { sess: tcx.sess, visualizers: Vec::new() }; let mut visitor = DebuggerVisualizerCollector { sess: tcx.sess, visualizers: Vec::new() };

View file

@ -243,7 +243,7 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
/// Traverses and collects all the lang items in all crates. /// Traverses and collects all the lang items in all crates.
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems { 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; let (resolver, krate) = &*resolver;
// Initialize the collector. // Initialize the collector.

View file

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

View file

@ -38,14 +38,16 @@ impl<'a, 'b, 'tcx> DefCollector<'a, 'b, 'tcx> {
"create_def(node_id={:?}, def_kind={:?}, parent_def={:?})", "create_def(node_id={:?}, def_kind={:?}, parent_def={:?})",
node_id, def_kind, parent_def node_id, def_kind, parent_def
); );
self.resolver.create_def( self.resolver
parent_def, .create_def(
node_id, parent_def,
name, node_id,
def_kind, name,
self.expansion.to_expn_id(), def_kind,
span.with_parent(None), 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) { fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: LocalDefId, f: F) {

View file

@ -3121,7 +3121,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
); );
rustc_middle::ty::Visibility::Public 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 { let Some(binding) = binding else {

View file

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

View file

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

View file

@ -95,22 +95,6 @@ pub mod process;
pub mod raw; pub mod raw;
pub mod thread; 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. /// A prelude for conveniently writing platform-specific code.
/// ///
/// Includes all extension traits, and some important type definitions. /// Includes all extension traits, and some important type definitions.

View file

@ -12,6 +12,20 @@ mod listener;
mod stream; mod stream;
#[cfg(all(test, not(target_os = "emscripten")))] #[cfg(all(test, not(target_os = "emscripten")))]
mod tests; 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")] #[stable(feature = "unix_socket", since = "1.10.0")]
pub use self::addr::*; pub use self::addr::*;
@ -24,3 +38,18 @@ pub use self::datagram::*;
pub use self::listener::*; pub use self::listener::*;
#[stable(feature = "unix_socket", since = "1.10.0")] #[stable(feature = "unix_socket", since = "1.10.0")]
pub use self::stream::*; 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"))] #[cfg(any(doc, target_os = "android", target_os = "linux"))]
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary}; use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
use super::{sockaddr_un, SocketAddr}; use super::{sockaddr_un, SocketAddr};
@ -5,40 +18,12 @@ use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::Shutdown; use crate::net::Shutdown;
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; 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::path::Path;
use crate::sys::cvt; use crate::sys::cvt;
use crate::sys::net::Socket; use crate::sys::net::Socket;
use crate::sys_common::{AsInner, FromInner}; use crate::sys_common::{AsInner, FromInner};
use crate::time::Duration; 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. /// A Unix stream socket.
/// ///
/// # Examples /// # Examples
@ -247,7 +232,7 @@ impl UnixStream {
target_os = "openbsd" target_os = "openbsd"
))] ))]
pub fn peer_cred(&self) -> io::Result<UCred> { pub fn peer_cred(&self) -> io::Result<UCred> {
ucred::peer_cred(self) peer_cred(self)
} }
/// Sets the read timeout for the socket. /// 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 // NOTE: Code in this file is heavily based on work done in PR 13 from the tokio-uds repository on
// GitHub. // GitHub.
// //
@ -26,7 +24,7 @@ pub struct UCred {
} }
#[cfg(any(target_os = "android", target_os = "linux"))] #[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( #[cfg(any(
target_os = "dragonfly", target_os = "dragonfly",
@ -34,13 +32,13 @@ pub use self::impl_linux::peer_cred;
target_os = "openbsd", target_os = "openbsd",
target_os = "netbsd" 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"))] #[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"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub mod impl_linux { mod impl_linux {
use super::UCred; use super::UCred;
use crate::os::unix::io::AsRawFd; use crate::os::unix::io::AsRawFd;
use crate::os::unix::net::UnixStream; use crate::os::unix::net::UnixStream;
@ -82,7 +80,7 @@ pub mod impl_linux {
target_os = "netbsd", target_os = "netbsd",
target_os = "nto", target_os = "nto",
))] ))]
pub mod impl_bsd { mod impl_bsd {
use super::UCred; use super::UCred;
use crate::io; use crate::io;
use crate::os::unix::io::AsRawFd; use crate::os::unix::io::AsRawFd;
@ -99,7 +97,7 @@ pub mod impl_bsd {
} }
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] #[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 super::UCred;
use crate::os::unix::io::AsRawFd; use crate::os::unix::io::AsRawFd;
use crate::os::unix::net::UnixStream; 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 // projects like miri link against librustc_driver.so. We don't use a symlink, as
// these are not allowed inside rustup components. // these are not allowed inside rustup components.
let link = t!(fs::read_link(source)); 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 { } else {
builder.install(&source, destination, 0o644); builder.install(&source, destination, 0o644);

View file

@ -5,12 +5,13 @@ body {
margin: 0 auto; margin: 0 auto;
padding: 0 15px; padding: 0 15px;
font-size: 18px; font-size: 18px;
color: #333; color: #000;
line-height: 1.428571429; line-height: 1.428571429;
-webkit-box-sizing: unset; -webkit-box-sizing: unset;
-moz-box-sizing: unset; -moz-box-sizing: unset;
box-sizing: unset; box-sizing: unset;
background: #fff;
} }
@media (min-width: 768px) { @media (min-width: 768px) {
body { body {
@ -39,7 +40,6 @@ h4, h5, h6 {
padding: 5px 10px; padding: 5px 10px;
} }
h5, h6 { h5, h6 {
color: black;
text-decoration: underline; 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 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)?; let mut files = get_files_from_dir(&root.join("bin"), None)?;
files.extend(get_files_from_dir(&root.join("lib"), Some(".so"))?); files.extend(get_files_from_dir(&root.join("lib"), None)?);
// 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.sort_unstable(); files.sort_unstable();
let items: Vec<_> = files let items: Vec<_> = files

View file

@ -1,4 +1,3 @@
#![feature(diagnostic_namespace)]
//@ check-pass //@ check-pass
//@ aux-build:proc-macro-helper.rs //@ 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 //@ check-pass
#[diagnostic::non_existing_attribute] #[diagnostic::non_existing_attribute]
//~^WARN unknown diagnostic attribute //~^WARN unknown diagnostic attribute

View file

@ -1,5 +1,5 @@
warning: unknown diagnostic attribute 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] LL | #[diagnostic::non_existing_attribute]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[diagnostic::non_existing_attribute]
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: unknown diagnostic attribute 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")] LL | #[diagnostic::non_existing_attribute(with_option = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^

View file

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

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented( #[diagnostic::on_unimplemented(
on(_Self = "&str"), on(_Self = "&str"),
//~^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 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")] 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 = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: malformed `on_unimplemented` attribute 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"), LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^ invalid option found here
@ -15,7 +15,7 @@ LL | on(_Self = "&str"),
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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", LL | parent_label = "in this scope",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -23,7 +23,7 @@ LL | parent_label = "in this scope",
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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 LL | append_const_msg
| ^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^ invalid option found here
@ -31,7 +31,7 @@ LL | append_const_msg
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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"] LL | #[diagnostic::on_unimplemented = "Message"]
| ^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^ invalid option found here
@ -39,7 +39,7 @@ LL | #[diagnostic::on_unimplemented = "Message"]
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: there is no parameter `from_desugaring` on trait `Baz` 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}", 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `direct` on trait `Baz` 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}", 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `cause` on trait `Baz` 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}", 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `integral` on trait `Baz` 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}", 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `integer` on trait `Baz` 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}", 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `float` on trait `Baz` 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}" 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `_Self` on trait `Baz` 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}" 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `crate_local` on trait `Baz` 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}" 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `Trait` on trait `Baz` 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}" 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `ItemContext` on trait `Baz` 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}" 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: malformed `on_unimplemented` attribute 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"), LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^ invalid option found here
@ -128,7 +128,7 @@ LL | on(_Self = "&str"),
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: malformed `on_unimplemented` attribute 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", LL | parent_label = "in this scope",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -137,7 +137,7 @@ LL | parent_label = "in this scope",
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: malformed `on_unimplemented` attribute 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 LL | append_const_msg
| ^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^ invalid option found here
@ -146,7 +146,7 @@ LL | append_const_msg
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: trait has `()` and `i32` as params 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(()); LL | takes_foo(());
| --------- ^^ trait has `()` and `i32` as params | --------- ^^ trait has `()` and `i32` as params
@ -156,18 +156,18 @@ LL | takes_foo(());
= help: the trait `Foo<i32>` is not implemented for `()` = help: the trait `Foo<i32>` is not implemented for `()`
= note: trait has `()` and `i32` as params = note: trait has `()` and `i32` as params
help: this trait has no implementations, consider adding one 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> {} LL | trait Foo<T> {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: required by a bound in `takes_foo` 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>) {} LL | fn takes_foo(_: impl Foo<i32>) {}
| ^^^^^^^^ required by this bound in `takes_foo` | ^^^^^^^^ required by this bound in `takes_foo`
warning: malformed `on_unimplemented` attribute 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"] LL | #[diagnostic::on_unimplemented = "Message"]
| ^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^ invalid option found here
@ -176,7 +176,7 @@ LL | #[diagnostic::on_unimplemented = "Message"]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `(): Bar` is not satisfied 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(()); LL | takes_bar(());
| --------- ^^ the trait `Bar` is not implemented for `()` | --------- ^^ the trait `Bar` is not implemented for `()`
@ -185,13 +185,13 @@ LL | takes_bar(());
| |
= help: the trait `Bar` is implemented for `i32` = help: the trait `Bar` is implemented for `i32`
note: required by a bound in `takes_bar` 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) {} LL | fn takes_bar(_: impl Bar) {}
| ^^^ required by this bound in `takes_bar` | ^^^ required by this bound in `takes_bar`
warning: there is no parameter `from_desugaring` on trait `Baz` 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}", 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `direct` on trait `Baz` 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}", 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `cause` on trait `Baz` 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}", 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `integral` on trait `Baz` 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}", 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `integer` on trait `Baz` 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}", 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `float` on trait `Baz` 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}" 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `_Self` on trait `Baz` 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}" 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `crate_local` on trait `Baz` 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}" 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `Trait` on trait `Baz` 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}" 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `ItemContext` on trait `Baz` 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}" 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {from_desugaring}{direct}{cause}{integral}{integer} 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(()); LL | takes_baz(());
| --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext} | --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext}
@ -290,12 +290,12 @@ LL | takes_baz(());
| |
= help: the trait `Baz` is not implemented for `()` = help: the trait `Baz` is not implemented for `()`
help: this trait has no implementations, consider adding one 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 {} LL | trait Baz {}
| ^^^^^^^^^ | ^^^^^^^^^
note: required by a bound in `takes_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) {} LL | fn takes_baz(_: impl Baz) {}
| ^^^ required by this bound in `takes_baz` | ^^^ required by this bound in `takes_baz`

View file

@ -1,5 +1,3 @@
#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(unsupported = "foo")] #[diagnostic::on_unimplemented(unsupported = "foo")]
//~^WARN malformed `on_unimplemented` attribute //~^WARN malformed `on_unimplemented` attribute
//~|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 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")] 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 = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: malformed `on_unimplemented` attribute 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")] LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -15,7 +15,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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")] LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^ 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 = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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"))] LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 = help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute 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"] LL | #[diagnostic::on_unimplemented = "boom"]
| ^^^^^^^^ invalid option found here | ^^^^^^^^ invalid option found here
@ -39,7 +39,7 @@ LL | #[diagnostic::on_unimplemented = "boom"]
= help: only `message`, `note` and `label` are allowed as options = help: only `message`, `note` and `label` are allowed as options
warning: missing options for `on_unimplemented` attribute 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] 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 = help: at least one of the `message`, `note` and `label` options are expected
warning: there is no parameter `DoesNotExist` on trait `Test` 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}")] 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 = help: expect either a generic argument name or `{Self}` as format argument
warning: malformed `on_unimplemented` attribute 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")] LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^ invalid option found here
@ -64,7 +64,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Foo` is not satisfied 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); LL | take_foo(1_i32);
| -------- ^^^^^ the trait `Foo` is not implemented for `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 | required by a bound introduced by this call
| |
help: this trait has no implementations, consider adding one 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 {} LL | trait Foo {}
| ^^^^^^^^^ | ^^^^^^^^^
note: required by a bound in `take_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) {} LL | fn take_foo(_: impl Foo) {}
| ^^^ required by this bound in `take_foo` | ^^^ required by this bound in `take_foo`
warning: malformed `on_unimplemented` attribute 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")] LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
| ^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^ 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom 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); LL | take_baz(1_i32);
| -------- ^^^^^ the trait `Baz` is not implemented for `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 | required by a bound introduced by this call
| |
help: this trait has no implementations, consider adding one 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 {} LL | trait Baz {}
| ^^^^^^^^^ | ^^^^^^^^^
note: required by a bound in `take_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) {} LL | fn take_baz(_: impl Baz) {}
| ^^^ required by this bound in `take_baz` | ^^^ required by this bound in `take_baz`
warning: malformed `on_unimplemented` attribute 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"))] LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom 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); LL | take_boom(1_i32);
| --------- ^^^^^ the trait `Boom` is not implemented for `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 | required by a bound introduced by this call
| |
help: this trait has no implementations, consider adding one 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 {} LL | trait Boom {}
| ^^^^^^^^^^ | ^^^^^^^^^^
note: required by a bound in `take_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) {} LL | fn take_boom(_: impl Boom) {}
| ^^^^ required by this bound in `take_boom` | ^^^^ required by this bound in `take_boom`
warning: missing options for `on_unimplemented` attribute 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] LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -148,7 +148,7 @@ LL | #[diagnostic::on_unimplemented]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Whatever` is not satisfied 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); LL | take_whatever(1_i32);
| ------------- ^^^^^ the trait `Whatever` is not implemented for `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 | required by a bound introduced by this call
| |
help: this trait has no implementations, consider adding one 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 {} LL | trait Whatever {}
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
note: required by a bound in `take_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) {} LL | fn take_whatever(_: impl Whatever) {}
| ^^^^^^^^ required by this bound in `take_whatever` | ^^^^^^^^ required by this bound in `take_whatever`
warning: there is no parameter `DoesNotExist` on trait `Test` 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}")] 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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {DoesNotExist} 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(()); LL | take_test(());
| --------- ^^ the trait `Test` is not implemented for `()` | --------- ^^ the trait `Test` is not implemented for `()`
@ -184,12 +184,12 @@ LL | take_test(());
| required by a bound introduced by this call | required by a bound introduced by this call
| |
help: this trait has no implementations, consider adding one 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 {} LL | trait Test {}
| ^^^^^^^^^^ | ^^^^^^^^^^
note: required by a bound in `take_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) {} LL | fn take_test(_: impl Test) {}
| ^^^^ required by this bound in `take_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( #[diagnostic::on_unimplemented(
if(Self = "()"), if(Self = "()"),
//~^WARN malformed `on_unimplemented` attribute //~^WARN malformed `on_unimplemented` attribute

View file

@ -1,5 +1,5 @@
warning: malformed `on_unimplemented` attribute 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 = "()"), LL | if(Self = "()"),
| ^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^ invalid option found here
@ -8,7 +8,7 @@ LL | if(Self = "()"),
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: `message` is ignored due to previous definition of `message` 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", LL | message = "custom message",
| -------------------------- `message` is first declared here | -------------------------- `message` is first declared here
@ -17,7 +17,7 @@ LL | #[diagnostic::on_unimplemented(message = "fallback!!")]
| ^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here | ^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here
warning: malformed `on_unimplemented` attribute 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 = "()"), LL | if(Self = "()"),
| ^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^ invalid option found here
@ -26,7 +26,7 @@ LL | if(Self = "()"),
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: `message` is ignored due to previous definition of `message` 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", LL | message = "custom message",
| -------------------------- `message` is first declared here | -------------------------- `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` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: custom message 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(()); LL | takes_foo(());
| --------- ^^ fallback label | --------- ^^ fallback label
@ -48,12 +48,12 @@ LL | takes_foo(());
= note: custom note = note: custom note
= note: fallback note = note: fallback note
help: this trait has no implementations, consider adding one 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 {} LL | trait Foo {}
| ^^^^^^^^^ | ^^^^^^^^^
note: required by a bound in `takes_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) {} LL | fn takes_foo(_: impl Foo) {}
| ^^^ required by this bound in `takes_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")] #[diagnostic::on_unimplemented(message = "Foo", label = "Bar", note = "Baz", note = "Boom")]
trait Foo {} trait Foo {}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,5 +21,5 @@ error: the compiler unexpectedly panicked. this is a bug.
query stack during panic: 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 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() {}