File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //! Supporting implementation for parsing Thrust annotations.
2+
13use rustc_ast:: ast:: Attribute ;
24use rustc_ast:: tokenstream:: TokenStream ;
35use rustc_index:: IndexVec ;
@@ -31,6 +33,10 @@ pub fn callable_path() -> [Symbol; 2] {
3133 [ Symbol :: intern ( "thrust" ) , Symbol :: intern ( "callable" ) ]
3234}
3335
36+ /// A [`annot::Resolver`] implementation for resolving function parameters.
37+ ///
38+ /// The parameter names and their sorts needs to be configured via
39+ /// [`ParamResolver::push_param`] before use.
3440#[ derive( Debug , Clone , Default ) ]
3541pub struct ParamResolver {
3642 params : IndexVec < rty:: FunctionParamIdx , ( Symbol , chc:: Sort ) > ,
@@ -52,6 +58,10 @@ impl ParamResolver {
5258 }
5359}
5460
61+ /// A [`annot::Resolver`] implementation for resolving the special identifier `result`.
62+ ///
63+ /// The `result` identifier is used to refer to [`rty::RefinedTypeVar::Value`] in postconditions, denoting
64+ /// the return value of a function.
5565#[ derive( Debug , Clone ) ]
5666pub struct ResultResolver {
5767 result_symbol : Symbol ,
Original file line number Diff line number Diff line change 1+ //! Analyze a local crate.
2+
13use std:: collections:: HashSet ;
24
35use rustc_hir:: def:: DefKind ;
@@ -12,6 +14,16 @@ use crate::chc;
1214use crate :: refine:: { self , TemplateTypeGenerator , UnrefinedTypeGenerator } ;
1315use crate :: rty:: { self , ClauseBuilderExt as _} ;
1416
17+ /// An implementation of local crate analysis.
18+ ///
19+ /// The entry point is [`Analyzer::run`], which performs the following steps in order:
20+ ///
21+ /// 1. Register enum definitions found in the crate.
22+ /// 2. Give initial refinement types to local function definitions based on their signatures and
23+ /// annotations. This generates template refinement types with predicate variables for parameters and
24+ /// return types that are not known via annotations.
25+ /// 3. Type local function definition bodies via [`super::local_def::Analyzer`] using the refinement types
26+ /// generated in the previous step.
1527pub struct Analyzer < ' tcx , ' ctx > {
1628 tcx : TyCtxt < ' tcx > ,
1729 ctx : & ' ctx mut analyze:: Analyzer < ' tcx > ,
Original file line number Diff line number Diff line change 1+ //! Retrieves and caches well-known [`DefId`]s.
2+
13use std:: cell:: OnceCell ;
24
35use rustc_middle:: ty:: TyCtxt ;
@@ -10,6 +12,10 @@ struct DefIds {
1012 nonnull : OnceCell < Option < DefId > > ,
1113}
1214
15+ /// Retrieves and caches well-known [`DefId`]s.
16+ ///
17+ /// [`DefId`]s of some well-known types can be retrieved as lang items or via the definition of
18+ /// lang items. This struct implements that logic and caches the results.
1319#[ derive( Clone ) ]
1420pub struct DefIdCache < ' tcx > {
1521 tcx : TyCtxt < ' tcx > ,
Original file line number Diff line number Diff line change 1+ //! Analyze a local definition.
2+
13use std:: collections:: { HashMap , HashSet } ;
24
35use rustc_index:: bit_set:: BitSet ;
@@ -12,6 +14,10 @@ use crate::pretty::PrettyDisplayExt as _;
1214use crate :: refine:: { BasicBlockType , TemplateTypeGenerator } ;
1315use crate :: rty;
1416
17+ /// An implementation of the typing of local definitions.
18+ ///
19+ /// The current implementation only applies to function definitions. The entry point is
20+ /// [`Analyzer::run`], which generates constraints during typing, given the expected type of the function.
1521pub struct Analyzer < ' tcx , ' ctx > {
1622 ctx : & ' ctx mut analyze:: Analyzer < ' tcx > ,
1723 tcx : TyCtxt < ' tcx > ,
You can’t perform that action at this time.
0 commit comments