You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug or by design, but it certainly seemed odd so I wanted to note it.
Consider the following file, t.rs:
fnf1(){spawn(proc()println("Variant 1, adapted from tutorial-tasks.md"));}#[cfg(lifted_typed)]fnf2(){let p :proc() = proc() println("Variant 2, lift out expression");spawn(p);}#[cfg(lifted_inferred)]fnf2(){let p = proc() println("Variant 2, lift out expression");spawn(p);}fnmain(){f1();f2();}
When I compile the explicitly typed variant (cfg(lifted_typed)), it compiles and runs; but compiling the type inferred variant fails:
% rustc --cfg lifted_typed /tmp/t.rs && /tmp/t
Variant 2, lift out expression
Variant 1, adapted from tutorial-tasks.md
% rustc --cfg lifted_inferred /tmp/t.rs && /tmp/t
/tmp/t.rs:14:10: 14:11 error: mismatched types: expected `proc:Send()` but found `~fn()` (expected bounds `Send` but found no bounds)
/tmp/t.rs:14 spawn(p);
^
error: aborting due to previous error
The text was updated successfully, but these errors were encountered:
twiddle-fn.rs:2:11: 2:12 error: obsolete syntax: managed or owned closure
twiddle-fn.rs:2 let _: ~fn();
^
note: managed closures have been removed and owned closures are now written `proc()`
so (some part of) it is certainly a bug rather than by design. (I guess the bug could just be the error message... shrugs)
When rustc reads let f = proc() {};, f is inferred as ~fn() rather than proc() (== ~once fn()). I've seen the behavior when ~fn() was not obsolete yet.
Not sure if this is a bug or by design, but it certainly seemed odd so I wanted to note it.
Consider the following file,
t.rs
:When I compile the explicitly typed variant (
cfg(lifted_typed)
), it compiles and runs; but compiling the type inferred variant fails:The text was updated successfully, but these errors were encountered: