@@ -210,6 +210,82 @@ fn bad(buffers: read List<Buffer>) -> Unit {
210210 assert_eq ! ( read_view_errors, 3 , "{diagnostics:?}" ) ;
211211}
212212
213+ #[ test]
214+ fn checker_accepts_inline_manage_of_fresh_rvalue ( ) {
215+ // A struct constructor and a `fresh`-returning call are freshly produced,
216+ // owned rvalues: inline `manage` of them is sound and must be accepted.
217+ let source = r#"
218+ features: local
219+
220+ struct Frame {
221+ pixels: Int
222+ }
223+
224+ fn make_frame() -> fresh Frame
225+
226+ fn ok() -> Unit {
227+ let shared = manage Frame(pixels: 0)
228+ let from_call = manage make_frame()
229+ return Unit
230+ }
231+ "# ;
232+ let diagnostics = analyze_source ( "inline-manage-fresh.rss" , source) ;
233+ assert ! (
234+ diagnostics
235+ . iter( )
236+ . all( |diagnostic| diagnostic. code != "RS0307" ) ,
237+ "inline manage of a fresh rvalue must not be rejected: {diagnostics:?}"
238+ ) ;
239+ }
240+
241+ #[ test]
242+ fn checker_rejects_inline_manage_of_unsound_rvalue ( ) {
243+ // Non-fresh rvalues may alias live state and must still be rejected with
244+ // RS0307: a class constructor (managed identity, not fresh) and a plain
245+ // (non-fresh) function call result.
246+ let class_diags = analyze_source (
247+ "inline-manage-class.rss" ,
248+ r#"
249+ features: local
250+
251+ class Session {
252+ id: Int
253+ }
254+
255+ fn bad_class() -> Unit {
256+ let s = manage Session(id: 1)
257+ return Unit
258+ }
259+ "# ,
260+ ) ;
261+ assert ! (
262+ class_diags. iter( ) . any( |d| d. code == "RS0307" ) ,
263+ "inline manage of a class constructor must be rejected: {class_diags:?}"
264+ ) ;
265+
266+ let plain_diags = analyze_source (
267+ "inline-manage-plain.rss" ,
268+ r#"
269+ features: local
270+
271+ struct Frame {
272+ pixels: Int
273+ }
274+
275+ fn plain_frame() -> Frame
276+
277+ fn bad_plain_call() -> Unit {
278+ let v = manage plain_frame()
279+ return Unit
280+ }
281+ "# ,
282+ ) ;
283+ assert ! (
284+ plain_diags. iter( ) . any( |d| d. code == "RS0307" ) ,
285+ "inline manage of a non-fresh call result must be rejected: {plain_diags:?}"
286+ ) ;
287+ }
288+
213289#[ test]
214290fn checker_accepts_closure_parameter_without_treating_closure_as_data_effect_param ( ) {
215291 let source = r#"
0 commit comments