@@ -2306,22 +2306,15 @@ impl Function {
23062306 self ,
23072307 db : & dyn HirDatabase ,
23082308 span_formatter : impl Fn ( FileId , TextRange ) -> String ,
2309- ) -> String {
2309+ ) -> Result < String , ConstEvalError > {
23102310 let krate = HasModule :: krate ( & self . id , db. upcast ( ) ) ;
23112311 let edition = db. crate_graph ( ) [ krate] . edition ;
2312- let body = match db. monomorphized_mir_body (
2312+ let body = db. monomorphized_mir_body (
23132313 self . id . into ( ) ,
23142314 Substitution :: empty ( Interner ) ,
23152315 db. trait_environment ( self . id . into ( ) ) ,
2316- ) {
2317- Ok ( body) => body,
2318- Err ( e) => {
2319- let mut r = String :: new ( ) ;
2320- _ = e. pretty_print ( & mut r, db, & span_formatter, edition) ;
2321- return r;
2322- }
2323- } ;
2324- let ( result, output) = interpret_mir ( db, body, false , None ) ;
2316+ ) ?;
2317+ let ( result, output) = interpret_mir ( db, body, false , None ) ?;
23252318 let mut text = match result {
23262319 Ok ( _) => "pass" . to_owned ( ) ,
23272320 Err ( e) => {
@@ -2340,7 +2333,7 @@ impl Function {
23402333 text += "\n --------- stderr ---------\n " ;
23412334 text += & stderr;
23422335 }
2343- text
2336+ Ok ( text)
23442337 }
23452338}
23462339
@@ -2563,9 +2556,9 @@ impl Const {
25632556 /// Evaluate the constant and return the result as a string.
25642557 ///
25652558 /// This function is intended for IDE assistance, different from [`Const::render_eval`].
2566- pub fn eval ( self , db : & dyn HirDatabase , edition : Edition ) -> Result < String , ConstEvalError > {
2559+ pub fn eval ( self , db : & dyn HirDatabase ) -> Result < String , ConstEvalError > {
25672560 let c = db. const_eval ( self . id . into ( ) , Substitution :: empty ( Interner ) , None ) ?;
2568- Ok ( format ! ( "{}" , c. display( db, edition) ) )
2561+ Ok ( format ! ( "{}" , c. display( db, self . krate ( db ) . edition( db ) ) ) )
25692562 }
25702563
25712564 /// Evaluate the constant and return the result as a string, with more detailed information.
@@ -2640,7 +2633,15 @@ impl Static {
26402633 Type :: from_value_def ( db, self . id )
26412634 }
26422635
2643- /// Evaluate the constant and return the result as a string, with more detailed information.
2636+ /// Evaluate the static and return the result as a string.
2637+ ///
2638+ /// This function is intended for IDE assistance, different from [`Static::render_eval`].
2639+ pub fn eval ( self , db : & dyn HirDatabase ) -> Result < String , ConstEvalError > {
2640+ let c = db. const_eval ( self . id . into ( ) , Substitution :: empty ( Interner ) , None ) ?;
2641+ Ok ( format ! ( "{}" , c. display( db, self . krate( db) . edition( db) ) ) )
2642+ }
2643+
2644+ /// Evaluate the static and return the result as a string, with more detailed information.
26442645 ///
26452646 /// This function is intended for user-facing display.
26462647 pub fn render_eval (
0 commit comments