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

@ -17,8 +17,8 @@ use std::fmt::Debug;
pub use rustc_infer::infer::*;
#[extension]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtExt<'tcx>)]
impl<'tcx> InferCtxt<'tcx> {
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
let ty = self.resolve_vars_if_possible(ty);
@ -105,8 +105,8 @@ pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
}
}
#[extension]
pub impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
#[extension(pub trait InferCtxtBuilderExt<'tcx>)]
impl<'tcx> InferCtxtBuilder<'tcx> {
/// The "main method" for a canonicalized trait query. Given the
/// canonical key `canonical_key`, this method will create a new
/// 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::ObligationCause;
#[extension]
pub impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtRegionExt<'tcx>)]
impl<'tcx> InferCtxt<'tcx> {
/// Resolve regions, using the deep normalizer to normalize any type-outlives
/// obligations in the process. This is in `rustc_trait_selection` because
/// we need to normalize.

View file

@ -131,8 +131,8 @@ pub enum GenerateProofTree {
Never,
}
#[extension]
pub impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtEvalExt<'tcx>)]
impl<'tcx> InferCtxt<'tcx> {
/// Evaluates a goal from **outside** of the trait solver.
///
/// 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::TraitEngineExt;
#[extension]
pub impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtSelectExt<'tcx>)]
impl<'tcx> InferCtxt<'tcx> {
fn select_in_new_trait_solver(
&self,
obligation: &PolyTraitObligation<'tcx>,

View file

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

View file

@ -61,8 +61,8 @@ enum GoalEvaluationKind {
Nested { is_normalizes_to_hack: IsNormalizesToHack },
}
#[extension]
impl<'tcx> CanonicalResponseExt for Canonical<'tcx, Response<'tcx>> {
#[extension(trait CanonicalResponseExt)]
impl<'tcx> Canonical<'tcx, Response<'tcx>> {
fn has_no_inference_or_external_constraints(&self) -> bool {
self.value.external_constraints.region_constraints.is_empty()
&& 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::{self, Ty, TyCtxt};
#[extension]
pub impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
#[extension(pub trait TraitEngineExt<'tcx>)]
impl<'tcx> dyn TraitEngine<'tcx> {
fn new(infcx: &InferCtxt<'tcx>) -> Box<Self> {
if infcx.next_trait_solver() {
Box::new(NextFulfillmentCtxt::new(infcx))

View file

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

View file

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

View file

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

View file

@ -57,8 +57,8 @@ use super::{
pub use rustc_infer::traits::error_reporting::*;
#[extension]
pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
#[extension(pub trait TypeErrCtxtExt<'tcx>)]
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
fn report_fulfillment_errors(
&self,
mut errors: Vec<FulfillmentError<'tcx>>,
@ -1326,8 +1326,8 @@ pub impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
}
#[extension]
pub(super) impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
#[extension(pub(super) trait InferCtxtPrivExt<'tcx>)]
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// returns if `cond` not occurring implies that `error` does not occur - i.e., that
// `error` occurring implies that `cond` occurs.
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
}
#[extension]
pub impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtExt<'a, 'tcx>)]
impl<'a, 'tcx: 'a> InferCtxt<'tcx> {
/// Do *NOT* call this directly.
fn implied_bounds_tys_compat(
&'a self,

View file

@ -52,8 +52,8 @@ pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::AliasTy<'tcx>>;
pub(super) struct InProgress;
#[extension]
pub impl<'tcx> NormalizeExt<'tcx> for At<'_, 'tcx> {
#[extension(pub trait NormalizeExt<'tcx>)]
impl<'tcx> At<'_, 'tcx> {
/// Normalize a value using the `AssocTypeNormalizer`.
///
/// 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::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext};
#[extension]
pub impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
#[extension(pub trait InferCtxtExt<'tcx>)]
impl<'tcx> InferCtxt<'tcx> {
/// Evaluates whether the predicate can be satisfied (by any means)
/// in the given `ParamEnv`.
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;
#[extension]
pub impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> {
#[extension(pub trait QueryNormalizeExt<'tcx>)]
impl<'cx, 'tcx> At<'cx, 'tcx> {
/// Normalize `value` in the context of the inference context,
/// yielding a resulting type, or an error if `value` cannot be
/// normalized. If you don't care about regions, you should prefer

View file

@ -33,8 +33,8 @@ enum Inserted<'tcx> {
ShouldRecurseOn(DefId),
}
#[extension]
impl<'tcx> ChildrenExt<'tcx> for Children {
#[extension(trait ChildrenExt<'tcx>)]
impl<'tcx> Children {
/// 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) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().skip_binder();
@ -235,8 +235,8 @@ where
}
}
#[extension]
pub impl<'tcx> GraphExt<'tcx> for Graph {
#[extension(pub trait GraphExt<'tcx>)]
impl<'tcx> Graph {
/// Insert a local impl into the specialization graph. If an existing impl
/// conflicts with it (has overlap, but neither specializes the other),
/// 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};
#[extension]
pub impl<'tcx> StructurallyNormalizeExt<'tcx> for At<'_, 'tcx> {
#[extension(pub trait StructurallyNormalizeExt<'tcx>)]
impl<'tcx> At<'_, 'tcx> {
fn structurally_normalize(
&self,
ty: Ty<'tcx>,