Move trait into attr so it's greppable

This commit is contained in:
Michael Goulet 2024-02-14 17:18:56 +00:00
parent 9c25823bb4
commit a9dbf63087
31 changed files with 91 additions and 80 deletions

View File

@ -191,8 +191,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
} }
#[extension] #[extension(trait ResolverAstLoweringExt)]
impl ResolverAstLoweringExt for ResolverAstLowering { impl ResolverAstLowering {
fn legacy_const_generic_args(&self, expr: &Expr) -> Option<Vec<usize>> { fn legacy_const_generic_args(&self, expr: &Expr) -> Option<Vec<usize>> {
if let ExprKind::Path(None, path) = &expr.kind { if let ExprKind::Path(None, path) = &expr.kind {
// Don't perform legacy const generics rewriting if the path already // Don't perform legacy const generics rewriting if the path already

View File

@ -25,8 +25,8 @@ impl polonius_engine::FactTypes for RustcFacts {
pub type AllFacts = PoloniusFacts<RustcFacts>; pub type AllFacts = PoloniusFacts<RustcFacts>;
#[extension] #[extension(pub(crate) trait AllFactsExt)]
pub(crate) impl AllFactsExt for AllFacts { impl AllFacts {
/// Returns `true` if there is a need to gather `AllFacts` given the /// Returns `true` if there is a need to gather `AllFacts` given the
/// current `-Z` flags. /// current `-Z` flags.
fn enabled(tcx: TyCtxt<'_>) -> bool { fn enabled(tcx: TyCtxt<'_>) -> bool {

View File

@ -5,8 +5,8 @@ use rustc_middle::mir::ProjectionElem;
use rustc_middle::mir::{Body, Mutability, Place}; use rustc_middle::mir::{Body, Mutability, Place};
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
#[extension] #[extension(pub trait PlaceExt<'tcx>)]
pub impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { impl<'tcx> Place<'tcx> {
/// Returns `true` if we can safely ignore borrows of this place. /// Returns `true` if we can safely ignore borrows of this place.
/// This is true whenever there is no action that the user can do /// This is true whenever there is no action that the user can do
/// to the place `self` that would invalidate the borrow. This is true /// to the place `self` that would invalidate the borrow. This is true

View File

@ -226,8 +226,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
} }
} }
#[extension] #[extension(pub trait InferCtxtExt<'tcx>)]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
/// Given the fully resolved, instantiated type for an opaque /// Given the fully resolved, instantiated type for an opaque
/// type, i.e., the value of an inference variable like C1 or C2 /// type, i.e., the value of an inference variable like C1 or C2
/// (*), computes the "definition type" for an opaque type /// (*), computes the "definition type" for an opaque type

View File

@ -794,8 +794,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
} }
} }
#[extension] #[extension(trait InferCtxtExt<'tcx>)]
impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
#[instrument(skip(self), level = "debug")] #[instrument(skip(self), level = "debug")]
fn replace_free_regions_with_nll_infer_vars<T>( fn replace_free_regions_with_nll_infer_vars<T>(
&self, &self,

View File

@ -28,8 +28,8 @@ use std::fmt;
use crate::errors; use crate::errors;
#[extension] #[extension(trait RegionExt)]
impl RegionExt for ResolvedArg { impl ResolvedArg {
fn early(param: &GenericParam<'_>) -> (LocalDefId, ResolvedArg) { fn early(param: &GenericParam<'_>) -> (LocalDefId, ResolvedArg) {
debug!("ResolvedArg::early: def_id={:?}", param.def_id); debug!("ResolvedArg::early: def_id={:?}", param.def_id);
(param.def_id, ResolvedArg::EarlyBound(param.def_id.to_def_id())) (param.def_id, ResolvedArg::EarlyBound(param.def_id.to_def_id()))

View File

@ -13,8 +13,8 @@ use rustc_middle::ty::{self, TyCtxt};
/// FIXME(-Znext-solver): This or public because it is shared with the /// FIXME(-Znext-solver): This or public because it is shared with the
/// new trait solver implementation. We should deduplicate canonicalization. /// new trait solver implementation. We should deduplicate canonicalization.
#[extension] #[extension(pub trait CanonicalExt<'tcx, V>)]
pub impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<'tcx, V> { impl<'tcx, V> Canonical<'tcx, V> {
/// Instantiate the wrapped value, replacing each canonical value /// Instantiate the wrapped value, replacing each canonical value
/// with the value given in `var_values`. /// with the value given in `var_values`.
fn instantiate(&self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V fn instantiate(&self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V

View File

@ -2786,8 +2786,8 @@ pub enum FailureCode {
Error0644, Error0644,
} }
#[extension] #[extension(pub trait ObligationCauseExt<'tcx>)]
pub impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> { impl<'tcx> ObligationCause<'tcx> {
fn as_failure_code(&self, terr: TypeError<'tcx>) -> FailureCode { fn as_failure_code(&self, terr: TypeError<'tcx>) -> FailureCode {
use self::FailureCode::*; use self::FailureCode::*;
use crate::traits::ObligationCauseCode::*; use crate::traits::ObligationCauseCode::*;

View File

@ -626,8 +626,8 @@ pub struct InferCtxtBuilder<'tcx> {
next_trait_solver: bool, next_trait_solver: bool,
} }
#[extension] #[extension(pub trait TyCtxtInferExt<'tcx>)]
pub impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> { impl<'tcx> TyCtxt<'tcx> {
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> { fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
InferCtxtBuilder { InferCtxtBuilder {
tcx: self, tcx: self,

View File

@ -52,8 +52,8 @@ pub trait TraitEngine<'tcx>: 'tcx {
) -> Vec<PredicateObligation<'tcx>>; ) -> Vec<PredicateObligation<'tcx>>;
} }
#[extension] #[extension(pub trait TraitEngineExt<'tcx>)]
pub impl<'tcx, T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T { impl<'tcx, T: ?Sized + TraitEngine<'tcx>> T {
fn register_predicate_obligations( fn register_predicate_obligations(
&mut self, &mut self,
infcx: &InferCtxt<'tcx>, infcx: &InferCtxt<'tcx>,

View File

@ -8,10 +8,12 @@ use syn::{
Token, TraitItem, TraitItemConst, TraitItemFn, TraitItemMacro, TraitItemType, Type, Visibility, Token, TraitItem, TraitItemConst, TraitItemFn, TraitItemMacro, TraitItemType, Type, Visibility,
}; };
pub(crate) fn extension(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub(crate) fn extension(
// Parse the input tokens into a syntax tree attr: proc_macro::TokenStream,
let Extension { attrs, generics, vis, trait_, self_ty, items } = input: proc_macro::TokenStream,
parse_macro_input!(input as Extension); ) -> proc_macro::TokenStream {
let ExtensionAttr { vis, trait_ } = parse_macro_input!(attr as ExtensionAttr);
let Impl { attrs, generics, self_ty, items } = parse_macro_input!(input as Impl);
let headers: Vec<_> = items let headers: Vec<_> = items
.iter() .iter()
.map(|item| match item { .map(|item| match item {
@ -105,23 +107,32 @@ fn scrub_header(mut sig: Signature) -> Signature {
sig sig
} }
struct Extension { struct ExtensionAttr {
attrs: Vec<Attribute>,
vis: Visibility, vis: Visibility,
generics: Generics,
trait_: Path, trait_: Path,
}
impl Parse for ExtensionAttr {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let vis = input.parse()?;
let _: Token![trait] = input.parse()?;
let trait_ = input.parse()?;
Ok(ExtensionAttr { vis, trait_ })
}
}
struct Impl {
attrs: Vec<Attribute>,
generics: Generics,
self_ty: Type, self_ty: Type,
items: Vec<ImplItem>, items: Vec<ImplItem>,
} }
impl Parse for Extension { impl Parse for Impl {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> { fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let attrs = input.call(Attribute::parse_outer)?; let attrs = input.call(Attribute::parse_outer)?;
let vis = input.parse()?;
let _: Token![impl] = input.parse()?; let _: Token![impl] = input.parse()?;
let generics = input.parse()?; let generics = input.parse()?;
let trait_ = input.parse()?;
let _: Token![for] = input.parse()?;
let self_ty = input.parse()?; let self_ty = input.parse()?;
let content; let content;
@ -131,6 +142,6 @@ impl Parse for Extension {
items.push(content.parse()?); items.push(content.parse()?);
} }
Ok(Extension { attrs, generics, vis, trait_, self_ty, items }) Ok(Impl { attrs, generics, self_ty, items })
} }
} }

View File

@ -42,8 +42,8 @@ pub fn symbols(input: TokenStream) -> TokenStream {
} }
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn extension(_attr: TokenStream, input: TokenStream) -> TokenStream { pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream {
extension::extension(input) extension::extension(attr, input)
} }
decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive); decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);

View File

@ -23,8 +23,8 @@ use std::fmt;
use std::num::NonZero; use std::num::NonZero;
use std::ops::Bound; use std::ops::Bound;
#[extension] #[extension(pub trait IntegerExt)]
pub impl IntegerExt for Integer { impl Integer {
#[inline] #[inline]
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx> { fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx> {
match (*self, signed) { match (*self, signed) {
@ -111,8 +111,8 @@ pub impl IntegerExt for Integer {
} }
} }
#[extension] #[extension(pub trait PrimitiveExt)]
pub impl PrimitiveExt for Primitive { impl Primitive {
#[inline] #[inline]
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match *self { match *self {

View File

@ -96,8 +96,8 @@ impl<'tcx> Discr<'tcx> {
} }
} }
#[extension] #[extension(pub trait IntTypeExt)]
pub impl IntTypeExt for IntegerType { impl IntegerType {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self { match self {
IntegerType::Pointer(true) => tcx.types.isize, IntegerType::Pointer(true) => tcx.types.isize,

View File

@ -17,8 +17,8 @@ use std::fmt::Debug;
pub use rustc_infer::infer::*; pub use rustc_infer::infer::*;
#[extension] #[extension(pub trait InferCtxtExt<'tcx>)]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool { fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
let ty = self.resolve_vars_if_possible(ty); let ty = self.resolve_vars_if_possible(ty);
@ -105,8 +105,8 @@ pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
} }
} }
#[extension] #[extension(pub trait InferCtxtBuilderExt<'tcx>)]
pub impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> { impl<'tcx> InferCtxtBuilder<'tcx> {
/// The "main method" for a canonicalized trait query. Given the /// The "main method" for a canonicalized trait query. Given the
/// canonical key `canonical_key`, this method will create a new /// canonical key `canonical_key`, this method will create a new
/// inference context, instantiate the key, and run your operation /// inference context, instantiate the key, and run your operation

View File

@ -3,8 +3,8 @@ use rustc_infer::infer::{InferCtxt, RegionResolutionError};
use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
#[extension] #[extension(pub trait InferCtxtRegionExt<'tcx>)]
pub impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
/// Resolve regions, using the deep normalizer to normalize any type-outlives /// Resolve regions, using the deep normalizer to normalize any type-outlives
/// obligations in the process. This is in `rustc_trait_selection` because /// obligations in the process. This is in `rustc_trait_selection` because
/// we need to normalize. /// we need to normalize.

View File

@ -131,8 +131,8 @@ pub enum GenerateProofTree {
Never, Never,
} }
#[extension] #[extension(pub trait InferCtxtEvalExt<'tcx>)]
pub impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
/// Evaluates a goal from **outside** of the trait solver. /// Evaluates a goal from **outside** of the trait solver.
/// ///
/// Using this while inside of the solver is wrong as it uses a new /// Using this while inside of the solver is wrong as it uses a new

View File

@ -17,8 +17,8 @@ use crate::solve::inspect::ProofTreeBuilder;
use crate::traits::StructurallyNormalizeExt; use crate::traits::StructurallyNormalizeExt;
use crate::traits::TraitEngineExt; use crate::traits::TraitEngineExt;
#[extension] #[extension(pub trait InferCtxtSelectExt<'tcx>)]
pub impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
fn select_in_new_trait_solver( fn select_in_new_trait_solver(
&self, &self,
obligation: &PolyTraitObligation<'tcx>, obligation: &PolyTraitObligation<'tcx>,

View File

@ -216,8 +216,8 @@ pub trait ProofTreeVisitor<'tcx> {
fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) -> ControlFlow<Self::BreakTy>; fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) -> ControlFlow<Self::BreakTy>;
} }
#[extension] #[extension(pub trait ProofTreeInferCtxtExt<'tcx>)]
pub impl<'tcx> ProofTreeInferCtxtExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
fn visit_proof_tree<V: ProofTreeVisitor<'tcx>>( fn visit_proof_tree<V: ProofTreeVisitor<'tcx>>(
&self, &self,
goal: Goal<'tcx, ty::Predicate<'tcx>>, goal: Goal<'tcx, ty::Predicate<'tcx>>,

View File

@ -61,8 +61,8 @@ enum GoalEvaluationKind {
Nested { is_normalizes_to_hack: IsNormalizesToHack }, Nested { is_normalizes_to_hack: IsNormalizesToHack },
} }
#[extension] #[extension(trait CanonicalResponseExt)]
impl<'tcx> CanonicalResponseExt for Canonical<'tcx, Response<'tcx>> { impl<'tcx> Canonical<'tcx, Response<'tcx>> {
fn has_no_inference_or_external_constraints(&self) -> bool { fn has_no_inference_or_external_constraints(&self) -> bool {
self.value.external_constraints.region_constraints.is_empty() self.value.external_constraints.region_constraints.is_empty()
&& self.value.var_values.is_identity() && self.value.var_values.is_identity()

View File

@ -27,8 +27,8 @@ use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::Variance; use rustc_middle::ty::Variance;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
#[extension] #[extension(pub trait TraitEngineExt<'tcx>)]
pub impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> { impl<'tcx> dyn TraitEngine<'tcx> {
fn new(infcx: &InferCtxt<'tcx>) -> Box<Self> { fn new(infcx: &InferCtxt<'tcx>) -> Box<Self> {
if infcx.next_trait_solver() { if infcx.next_trait_solver() {
Box::new(NextFulfillmentCtxt::new(infcx)) Box::new(NextFulfillmentCtxt::new(infcx))

View File

@ -11,8 +11,8 @@ use super::ArgKind;
pub use rustc_infer::traits::error_reporting::*; pub use rustc_infer::traits::error_reporting::*;
#[extension] #[extension(pub trait InferCtxtExt<'tcx>)]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
/// Given some node representing a fn-like thing in the HIR map, /// Given some node representing a fn-like thing in the HIR map,
/// returns a span and `ArgKind` information that describes the /// returns a span and `ArgKind` information that describes the
/// arguments it expects. This can be supplied to /// arguments it expects. This can be supplied to

View File

@ -38,8 +38,8 @@ static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[
sym::Trait, sym::Trait,
]; ];
#[extension] #[extension(pub trait TypeErrCtxtExt<'tcx>)]
pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> {
fn impl_similar_to( fn impl_similar_to(
&self, &self,
trait_ref: ty::PolyTraitRef<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>,

View File

@ -236,8 +236,8 @@ pub fn suggest_restriction<'tcx>(
} }
} }
#[extension] #[extension(pub trait TypeErrCtxtExt<'tcx>)]
pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> {
fn suggest_restricting_param_bound( fn suggest_restricting_param_bound(
&self, &self,
err: &mut Diagnostic, err: &mut Diagnostic,

View File

@ -57,8 +57,8 @@ use super::{
pub use rustc_infer::traits::error_reporting::*; pub use rustc_infer::traits::error_reporting::*;
#[extension] #[extension(pub trait TypeErrCtxtExt<'tcx>)]
pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> {
fn report_fulfillment_errors( fn report_fulfillment_errors(
&self, &self,
mut errors: Vec<FulfillmentError<'tcx>>, mut errors: Vec<FulfillmentError<'tcx>>,
@ -1326,8 +1326,8 @@ pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
} }
#[extension] #[extension(pub(super) trait InferCtxtPrivExt<'tcx>)]
pub(super) impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// returns if `cond` not occurring implies that `error` does not occur - i.e., that // returns if `cond` not occurring implies that `error` does not occur - i.e., that
// `error` occurring implies that `cond` occurs. // `error` occurring implies that `cond` occurs.
fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool { fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool {

View File

@ -111,8 +111,8 @@ fn implied_outlives_bounds<'a, 'tcx>(
bounds bounds
} }
#[extension] #[extension(pub trait InferCtxtExt<'a, 'tcx>)]
pub impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { impl<'a, 'tcx: 'a> InferCtxt<'tcx> {
/// Do *NOT* call this directly. /// Do *NOT* call this directly.
fn implied_bounds_tys_compat( fn implied_bounds_tys_compat(
&'a self, &'a self,

View File

@ -52,8 +52,8 @@ pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::AliasTy<'tcx>>;
pub(super) struct InProgress; pub(super) struct InProgress;
#[extension] #[extension(pub trait NormalizeExt<'tcx>)]
pub impl<'tcx> NormalizeExt<'tcx> for At<'_, 'tcx> { impl<'tcx> At<'_, 'tcx> {
/// Normalize a value using the `AssocTypeNormalizer`. /// Normalize a value using the `AssocTypeNormalizer`.
/// ///
/// This normalization should be used when the type contains inference variables or the /// This normalization should be used when the type contains inference variables or the

View File

@ -4,8 +4,8 @@ use crate::infer::canonical::OriginalQueryValues;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use crate::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext}; use crate::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext};
#[extension] #[extension(pub trait InferCtxtExt<'tcx>)]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
/// Evaluates whether the predicate can be satisfied (by any means) /// Evaluates whether the predicate can be satisfied (by any means)
/// in the given `ParamEnv`. /// in the given `ParamEnv`.
fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool { fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool {

View File

@ -22,8 +22,8 @@ use super::NoSolution;
pub use rustc_middle::traits::query::NormalizationResult; pub use rustc_middle::traits::query::NormalizationResult;
#[extension] #[extension(pub trait QueryNormalizeExt<'tcx>)]
pub impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> { impl<'cx, 'tcx> At<'cx, 'tcx> {
/// Normalize `value` in the context of the inference context, /// Normalize `value` in the context of the inference context,
/// yielding a resulting type, or an error if `value` cannot be /// yielding a resulting type, or an error if `value` cannot be
/// normalized. If you don't care about regions, you should prefer /// normalized. If you don't care about regions, you should prefer

View File

@ -33,8 +33,8 @@ enum Inserted<'tcx> {
ShouldRecurseOn(DefId), ShouldRecurseOn(DefId),
} }
#[extension] #[extension(trait ChildrenExt<'tcx>)]
impl<'tcx> ChildrenExt<'tcx> for Children { impl<'tcx> Children {
/// Insert an impl into this set of children without comparing to any existing impls. /// Insert an impl into this set of children without comparing to any existing impls.
fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) { fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().skip_binder(); let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().skip_binder();
@ -235,8 +235,8 @@ where
} }
} }
#[extension] #[extension(pub trait GraphExt<'tcx>)]
pub impl<'tcx> GraphExt<'tcx> for Graph { impl<'tcx> Graph {
/// Insert a local impl into the specialization graph. If an existing impl /// Insert a local impl into the specialization graph. If an existing impl
/// conflicts with it (has overlap, but neither specializes the other), /// conflicts with it (has overlap, but neither specializes the other),
/// information about the area of overlap is returned in the `Err`. /// information about the area of overlap is returned in the `Err`.

View File

@ -5,8 +5,8 @@ use rustc_middle::ty::{self, Ty};
use crate::traits::{NormalizeExt, Obligation}; use crate::traits::{NormalizeExt, Obligation};
#[extension] #[extension(pub trait StructurallyNormalizeExt<'tcx>)]
pub impl<'tcx> StructurallyNormalizeExt<'tcx> for At<'_, 'tcx> { impl<'tcx> At<'_, 'tcx> {
fn structurally_normalize( fn structurally_normalize(
&self, &self,
ty: Ty<'tcx>, ty: Ty<'tcx>,