Returns a constant value that is a reference to a function
(
function_id: usize,
def_id: DefId,
generic_args: Option<GenericArgsRef<'tcx>>,
tcx: TyCtxt<'tcx>,
known_names_cache: &mut KnownNamesCache,
)
| 95 | impl ConstantValue { |
| 96 | /// Returns a constant value that is a reference to a function |
| 97 | pub fn for_function<'a, 'tcx, 'compiler>( |
| 98 | function_id: usize, |
| 99 | def_id: DefId, |
| 100 | generic_args: Option<GenericArgsRef<'tcx>>, |
| 101 | tcx: TyCtxt<'tcx>, |
| 102 | known_names_cache: &mut KnownNamesCache, |
| 103 | ) -> ConstantValue { |
| 104 | let function_name = utils::summary_key_str(tcx, def_id).to_string(); |
| 105 | let generic_arguments = if let Some(generic_args) = generic_args { |
| 106 | generic_args.types().map(|t| t.kind().into()).collect() |
| 107 | } else { |
| 108 | vec![] |
| 109 | }; |
| 110 | |
| 111 | let known_name = known_names_cache.get(tcx, def_id); |
| 112 | info!("The direct string of the function name is: {}",function_name); |
| 113 | info!("The known_name of the function: {:?}", known_name); |
| 114 | ConstantValue::Function(Rc::new(FunctionReference { |
| 115 | def_id: Some(def_id), |
| 116 | function_id: Some(function_id), |
| 117 | generic_arguments, |
| 118 | known_name, |
| 119 | function_name: Rc::new(function_name.clone()), |
| 120 | })) |
| 121 | } |
| 122 | |
| 123 | pub fn is_top(&self) -> bool { |
| 124 | matches!(self, ConstantValue::Top) |
nothing calls this directly
no test coverage detected