File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,7 +138,33 @@ impl Analyzer<'_> {
138138 ) ,
139139 ) ;
140140 }
141- if param. effect . is_none ( ) && !param. ty . name . is_empty ( ) && !is_copy_type ( & param. ty ) {
141+ if param. effect . is_none ( ) && param. ty . name == "share" {
142+ self . diagnostics . push (
143+ Diagnostic :: error (
144+ code:: REMOVED_SHARE_EFFECT ,
145+ format ! (
146+ "parameter `{}` in `{}` uses removed `share` data effect." ,
147+ param. name, function. name
148+ ) ,
149+ param. ty . span . clone ( ) ,
150+ "removed share data effect" ,
151+ )
152+ . with_cause ( "RSScript v0.4.1 has exactly three data effects: `read`, `mut`, and `take`." )
153+ . with_fix (
154+ "replace_share_effect" ,
155+ format ! (
156+ "Use `{}: read T` and add `effects(retains({}))` if the function retains it." ,
157+ param. name, param. name
158+ ) ,
159+ "manual" ,
160+ ) ,
161+ ) ;
162+ }
163+ if param. effect . is_none ( )
164+ && !param. ty . name . is_empty ( )
165+ && param. ty . name != "share"
166+ && !is_copy_type ( & param. ty )
167+ {
142168 self . diagnostics . push (
143169 Diagnostic :: error (
144170 code:: MISSING_PARAMETER_EFFECT ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pub mod code {
1111 pub const MISSING_PARAMETER_EFFECT : & str = "RS0008" ;
1212 pub const INVALID_PURE_EFFECT : & str = "RS0009" ;
1313 pub const REMOVED_PROFILE_DECLARATION : & str = "RS0010" ;
14+ pub const REMOVED_SHARE_EFFECT : & str = "RS0011" ;
1415 pub const FILE_MODE_VIOLATION : & str = "RS0101" ;
1516 pub const UNNAMED_ARGUMENT : & str = "RS0201" ;
1617 pub const MISSING_DATA_EFFECT : & str = "RS0202" ;
@@ -249,6 +250,11 @@ static DIAGNOSTIC_EXPLANATIONS: &[DiagnosticExplanation] = &[
249250 title : "removed profile declaration" ,
250251 explanation : "RSScript v0.4.1 removed `profile:` declarations. The only top-level semantic file declaration is `mode:`." ,
251252 } ,
253+ DiagnosticExplanation {
254+ code : code:: REMOVED_SHARE_EFFECT ,
255+ title : "removed share data effect" ,
256+ explanation : "RSScript v0.4.1 removed `share` as a data effect. Retention must be declared with `effects(retains(param))`." ,
257+ } ,
252258 DiagnosticExplanation {
253259 code : code:: FILE_MODE_VIOLATION ,
254260 title : "file mode violation" ,
Original file line number Diff line number Diff line change 1+ // expect: RS0011
2+ mode: managed
3+
4+ struct Image {
5+ pixels: Buffer
6+ }
7+
8+ fn cache_put(value: share Image) -> Unit {
9+ return Unit
10+ }
You can’t perform that action at this time.
0 commit comments