tangled
alpha
login
or
join now
daniellemaywood.uk
/
gleam
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
Deprecation message
Louis Pilfold
2 years ago
16d1c3a9
ea31b902
+117
-67
17 changed files
expand all
collapse all
unified
split
compiler-core
build.rs
generated
schema_capnp.rs
schema.capnp
src
analyse.rs
ast
tests.rs
ast.rs
call_graph
into_dependency_order_tests.rs
metadata
module_decoder.rs
module_encoder.rs
tests.rs
parse.rs
type_
environment.rs
expression.rs
pipe.rs
prelude.rs
tests
functions.rs
type_.rs
+5
-5
compiler-core/build.rs
···
1
fn main() {
2
-
capnpc::CompilerCommand::new()
3
-
.file("schema.capnp")
4
-
.output_path("generated/")
5
-
.run()
6
-
.expect("compiling schema.capnp");
7
}
···
1
fn main() {
2
+
// capnpc::CompilerCommand::new()
3
+
// .file("schema.capnp")
4
+
// .output_path("generated/")
5
+
// .run()
6
+
// .expect("compiling schema.capnp");
7
}
+19
-7
compiler-core/generated/schema_capnp.rs
···
2052
self.reader.get_bool_field(0)
2053
}
2054
#[inline]
2055
-
pub fn get_deprecated(self) -> bool {
2056
-
self.reader.get_bool_field(1)
0
0
0
0
2057
}
2058
}
2059
···
2146
self.builder.set_bool_field(0, value);
2147
}
2148
#[inline]
2149
-
pub fn get_deprecated(self) -> bool {
2150
-
self.builder.get_bool_field(1)
2151
}
2152
#[inline]
2153
-
pub fn set_deprecated(&mut self, value: bool) {
2154
-
self.builder.set_bool_field(1, value);
0
0
0
0
0
0
0
0
2155
}
2156
}
2157
···
2171
}
2172
mod _private {
2173
use capnp::private::layout;
2174
-
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 1, pointers: 2 };
2175
pub const TYPE_ID: u64 = 0xd4c6_d8f1_a8fb_051c;
2176
}
2177
}
···
2052
self.reader.get_bool_field(0)
2053
}
2054
#[inline]
2055
+
pub fn get_deprecated(self) -> ::capnp::Result<::capnp::text::Reader<'a>> {
2056
+
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None)
2057
+
}
2058
+
#[inline]
2059
+
pub fn has_deprecated(&self) -> bool {
2060
+
!self.reader.get_pointer_field(2).is_null()
2061
}
2062
}
2063
···
2150
self.builder.set_bool_field(0, value);
2151
}
2152
#[inline]
2153
+
pub fn get_deprecated(self) -> ::capnp::Result<::capnp::text::Builder<'a>> {
2154
+
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None)
2155
}
2156
#[inline]
2157
+
pub fn set_deprecated(&mut self, value: ::capnp::text::Reader<'_>) {
2158
+
self.builder.get_pointer_field(2).set_text(value);
2159
+
}
2160
+
#[inline]
2161
+
pub fn init_deprecated(self, size: u32) -> ::capnp::text::Builder<'a> {
2162
+
self.builder.get_pointer_field(2).init_text(size)
2163
+
}
2164
+
#[inline]
2165
+
pub fn has_deprecated(&self) -> bool {
2166
+
!self.builder.get_pointer_field(2).is_null()
2167
}
2168
}
2169
···
2183
}
2184
mod _private {
2185
use capnp::private::layout;
2186
+
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 1, pointers: 3 };
2187
pub const TYPE_ID: u64 = 0xd4c6_d8f1_a8fb_051c;
2188
}
2189
}
+1
-1
compiler-core/schema.capnp
···
76
type @0 :Type;
77
variant @1 :ValueConstructorVariant;
78
public @2 :Bool;
79
-
deprecated @3 :Bool;
80
}
81
82
struct ValueConstructorVariant {
···
76
type @0 :Type;
77
variant @1 :ValueConstructorVariant;
78
public @2 :Bool;
79
+
deprecated @3 :Text;
80
}
81
82
struct ValueConstructorVariant {
+20
-13
compiler-core/src/analyse.rs
···
3
4
use crate::ast::{UntypedArg, UntypedStatement};
5
use crate::type_::error::MissingAnnotation;
0
6
use crate::{
7
ast::{
8
self, BitStringSegmentOption, CustomType, Definition, DefinitionLocation, Function,
···
286
value.variant.clone(),
287
value.type_.clone(),
288
true,
289
-
false,
290
);
291
variant = Some(&value.variant);
292
value_imported = true;
···
538
environment.insert_module_value(
539
constructor.name.clone(),
540
ValueConstructor {
541
-
deprecated: false,
542
public: *public && !opaque,
543
type_: typ.clone(),
544
variant: constructor_info.clone(),
···
558
constructor_info,
559
typ,
560
*public,
561
-
false,
562
);
563
}
564
Ok(())
···
580
documentation,
581
external_erlang,
582
external_javascript,
583
-
deprecated,
584
end_position: _,
585
body: _,
586
return_type: _,
···
618
arity: args.len(),
619
location: *location,
620
};
621
-
environment.insert_variable(name.clone(), variant, typ, *public, *deprecated);
622
if !public {
623
environment.init_usage(name.clone(), EntityKind::PrivateFunction, *location);
624
};
···
672
body,
673
return_annotation,
674
end_position: end_location,
675
-
deprecated,
676
external_erlang,
677
external_javascript,
678
return_type: (),
···
733
arity: args.len(),
734
location,
735
};
736
-
environment.insert_variable(name.clone(), variant, type_.clone(), public, deprecated);
0
0
0
0
0
0
737
738
Ok(Definition::Function(Function {
739
documentation: doc,
740
location,
741
name,
742
public,
743
-
deprecated,
744
arguments: args,
745
end_position: end_location,
746
return_annotation,
···
997
let type_ = typed_expr.type_();
998
let variant = ValueConstructor {
999
public,
1000
-
deprecated: false,
1001
variant: ValueConstructorVariant::ModuleConstant {
1002
documentation: doc.clone(),
1003
location,
···
1012
variant.variant.clone(),
1013
type_.clone(),
1014
public,
1015
-
false,
1016
);
1017
environment.insert_module_value(name.clone(), variant);
1018
···
1124
location,
1125
name,
1126
public,
1127
-
deprecated,
1128
arguments: args,
1129
body,
1130
return_annotation,
···
1151
name.clone(),
1152
ValueConstructor {
1153
public,
1154
-
deprecated,
1155
type_: typ,
1156
variant: ValueConstructorVariant::ModuleFn {
1157
documentation: doc.clone(),
···
1169
location,
1170
name,
1171
public,
1172
-
deprecated,
1173
arguments: args,
1174
end_position: end_location,
1175
return_annotation,
···
3
4
use crate::ast::{UntypedArg, UntypedStatement};
5
use crate::type_::error::MissingAnnotation;
6
+
use crate::type_::Deprecation;
7
use crate::{
8
ast::{
9
self, BitStringSegmentOption, CustomType, Definition, DefinitionLocation, Function,
···
287
value.variant.clone(),
288
value.type_.clone(),
289
true,
290
+
Deprecation::NotDeprecated,
291
);
292
variant = Some(&value.variant);
293
value_imported = true;
···
539
environment.insert_module_value(
540
constructor.name.clone(),
541
ValueConstructor {
542
+
deprecation: Deprecation::NotDeprecated,
543
public: *public && !opaque,
544
type_: typ.clone(),
545
variant: constructor_info.clone(),
···
559
constructor_info,
560
typ,
561
*public,
562
+
Deprecation::NotDeprecated,
563
);
564
}
565
Ok(())
···
581
documentation,
582
external_erlang,
583
external_javascript,
584
+
deprecation,
585
end_position: _,
586
body: _,
587
return_type: _,
···
619
arity: args.len(),
620
location: *location,
621
};
622
+
environment.insert_variable(name.clone(), variant, typ, *public, deprecation.clone());
623
if !public {
624
environment.init_usage(name.clone(), EntityKind::PrivateFunction, *location);
625
};
···
673
body,
674
return_annotation,
675
end_position: end_location,
676
+
deprecation,
677
external_erlang,
678
external_javascript,
679
return_type: (),
···
734
arity: args.len(),
735
location,
736
};
737
+
environment.insert_variable(
738
+
name.clone(),
739
+
variant,
740
+
type_.clone(),
741
+
public,
742
+
deprecation.clone(),
743
+
);
744
745
Ok(Definition::Function(Function {
746
documentation: doc,
747
location,
748
name,
749
public,
750
+
deprecation,
751
arguments: args,
752
end_position: end_location,
753
return_annotation,
···
1004
let type_ = typed_expr.type_();
1005
let variant = ValueConstructor {
1006
public,
1007
+
deprecation: Deprecation::NotDeprecated,
1008
variant: ValueConstructorVariant::ModuleConstant {
1009
documentation: doc.clone(),
1010
location,
···
1019
variant.variant.clone(),
1020
type_.clone(),
1021
public,
1022
+
Deprecation::NotDeprecated,
1023
);
1024
environment.insert_module_value(name.clone(), variant);
1025
···
1131
location,
1132
name,
1133
public,
1134
+
deprecation,
1135
arguments: args,
1136
body,
1137
return_annotation,
···
1158
name.clone(),
1159
ValueConstructor {
1160
public,
1161
+
deprecation: deprecation.clone(),
1162
type_: typ,
1163
variant: ValueConstructorVariant::ModuleFn {
1164
documentation: doc.clone(),
···
1176
location,
1177
name,
1178
public,
1179
+
deprecation,
1180
arguments: args,
1181
end_position: end_location,
1182
return_annotation,
+4
-2
compiler-core/src/ast.rs
···
12
13
use crate::analyse::Inferred;
14
use crate::build::{Located, Target};
15
-
use crate::type_::{self, ModuleValueConstructor, PatternConstructor, Type, ValueConstructor};
0
0
16
use std::sync::Arc;
17
18
#[cfg(test)]
···
343
pub arguments: Vec<Arg<T>>,
344
pub body: Vec1<Statement<T, Expr>>,
345
pub public: bool,
346
-
pub deprecated: bool,
347
pub return_annotation: Option<TypeAst>,
348
pub return_type: T,
349
pub documentation: Option<SmolStr>,
···
12
13
use crate::analyse::Inferred;
14
use crate::build::{Located, Target};
15
+
use crate::type_::{
16
+
self, Deprecation, ModuleValueConstructor, PatternConstructor, Type, ValueConstructor,
17
+
};
18
use std::sync::Arc;
19
20
#[cfg(test)]
···
345
pub arguments: Vec<Arg<T>>,
346
pub body: Vec1<Statement<T, Expr>>,
347
pub public: bool,
348
+
pub deprecation: Deprecation,
349
pub return_annotation: Option<TypeAst>,
350
pub return_type: T,
351
pub documentation: Option<SmolStr>,
+4
-4
compiler-core/src/ast/tests.rs
···
1
use std::sync::Arc;
2
3
use crate::build::Target;
4
-
use crate::type_::PRELUDE_MODULE_NAME;
5
use crate::{
6
ast::{SrcSpan, TypedExpr},
7
build::Located,
···
85
variant,
86
type_::fn_(vec![type_::string(), type_::int()], cat_type.clone()),
87
true,
88
-
false,
89
);
90
91
environment.insert_accessors(
···
182
let var = TypedExpr::Var {
183
location: SrcSpan { start: 16, end: 22 },
184
constructor: ValueConstructor {
185
-
deprecated: false,
186
public: false,
187
variant: ValueConstructorVariant::LocalVariable {
188
location: SrcSpan { start: 5, end: 11 },
···
467
let bool = TypedExpr::Var {
468
location: SrcSpan { start: 1, end: 5 },
469
constructor: ValueConstructor {
470
-
deprecated: false,
471
public: true,
472
variant: ValueConstructorVariant::Record {
473
documentation: None,
···
1
use std::sync::Arc;
2
3
use crate::build::Target;
4
+
use crate::type_::{Deprecation, PRELUDE_MODULE_NAME};
5
use crate::{
6
ast::{SrcSpan, TypedExpr},
7
build::Located,
···
85
variant,
86
type_::fn_(vec![type_::string(), type_::int()], cat_type.clone()),
87
true,
88
+
Deprecation::NotDeprecated,
89
);
90
91
environment.insert_accessors(
···
182
let var = TypedExpr::Var {
183
location: SrcSpan { start: 16, end: 22 },
184
constructor: ValueConstructor {
185
+
deprecation: Deprecation::NotDeprecated,
186
public: false,
187
variant: ValueConstructorVariant::LocalVariable {
188
location: SrcSpan { start: 5, end: 11 },
···
467
let bool = TypedExpr::Var {
468
location: SrcSpan { start: 1, end: 5 },
469
constructor: ValueConstructor {
470
+
deprecation: Deprecation::NotDeprecated,
471
public: true,
472
variant: ValueConstructorVariant::Record {
473
documentation: None,
+5
-2
compiler-core/src/call_graph/into_dependency_order_tests.rs
···
1
use super::*;
2
-
use crate::ast::{Arg, Function};
0
0
0
3
use smol_str::SmolStr;
4
5
type Input = (&'static str, &'static [&'static str], &'static str);
···
22
location: Default::default(),
23
return_annotation: None,
24
public: true,
25
-
deprecated: false,
26
end_position: src.len() as u32,
27
return_type: (),
28
documentation: None,
···
1
use super::*;
2
+
use crate::{
3
+
ast::{Arg, Function},
4
+
type_::Deprecation,
5
+
};
6
use smol_str::SmolStr;
7
8
type Input = (&'static str, &'static [&'static str], &'static str);
···
25
location: Default::default(),
26
return_annotation: None,
27
public: true,
28
+
deprecation: Deprecation::NotDeprecated,
29
end_position: src.len() as u32,
30
return_type: (),
31
documentation: None,
+9
-4
compiler-core/src/metadata/module_decoder.rs
···
11
build::Origin,
12
schema_capnp::{self as schema, *},
13
type_::{
14
-
self, AccessorsMap, FieldMap, ModuleInterface, RecordAccessor, Type, TypeConstructor,
15
-
ValueConstructor, ValueConstructorVariant,
16
},
17
uid::UniqueIdGenerator,
18
Result,
···
149
let type_ = self.type_(&reader.get_type()?)?;
150
let variant = self.value_constructor_variant(&reader.get_variant()?)?;
151
let public = reader.get_public();
152
-
let deprecated = reader.get_deprecated();
0
0
0
0
0
153
Ok(ValueConstructor {
154
-
deprecated,
155
public,
156
type_,
157
variant,
···
11
build::Origin,
12
schema_capnp::{self as schema, *},
13
type_::{
14
+
self, AccessorsMap, Deprecation, FieldMap, ModuleInterface, RecordAccessor, Type,
15
+
TypeConstructor, ValueConstructor, ValueConstructorVariant,
16
},
17
uid::UniqueIdGenerator,
18
Result,
···
149
let type_ = self.type_(&reader.get_type()?)?;
150
let variant = self.value_constructor_variant(&reader.get_variant()?)?;
151
let public = reader.get_public();
152
+
let deprecation = match reader.get_deprecated()? {
153
+
"" => Deprecation::NotDeprecated,
154
+
message => Deprecation::Deprecated {
155
+
message: message.into(),
156
+
},
157
+
};
158
Ok(ValueConstructor {
159
+
deprecation,
160
public,
161
type_,
162
variant,
+5
-2
compiler-core/src/metadata/module_encoder.rs
···
7
},
8
schema_capnp::{self as schema, *},
9
type_::{
10
-
self, AccessorsMap, FieldMap, RecordAccessor, Type, TypeConstructor, TypeVar,
11
ValueConstructor, ValueConstructorVariant,
12
},
13
};
···
152
constructor: &ValueConstructor,
153
) {
154
builder.set_public(constructor.public);
155
-
builder.set_deprecated(constructor.deprecated);
0
0
0
156
self.build_type(builder.reborrow().init_type(), &constructor.type_);
157
self.build_value_constructor_variant(builder.init_variant(), &constructor.variant);
158
}
···
7
},
8
schema_capnp::{self as schema, *},
9
type_::{
10
+
self, AccessorsMap, Deprecation, FieldMap, RecordAccessor, Type, TypeConstructor, TypeVar,
11
ValueConstructor, ValueConstructorVariant,
12
},
13
};
···
152
constructor: &ValueConstructor,
153
) {
154
builder.set_public(constructor.public);
155
+
builder.set_deprecated(match &constructor.deprecation {
156
+
Deprecation::NotDeprecated => "",
157
+
Deprecation::Deprecated { message } => message,
158
+
});
159
self.build_type(builder.reborrow().init_type(), &constructor.type_);
160
self.build_value_constructor_variant(builder.init_variant(), &constructor.variant);
161
}
+15
-12
compiler-core/src/metadata/tests.rs
···
9
},
10
build::Origin,
11
type_::{
12
-
self, ModuleInterface, Type, TypeConstructor, ValueConstructor, ValueConstructorVariant,
0
13
},
14
uid::UniqueIdGenerator,
15
};
···
37
"one".into(),
38
ValueConstructor {
39
public: true,
40
-
deprecated: false,
41
type_: type_::int(),
42
variant: ValueConstructorVariant::ModuleConstant {
43
documentation: Some("Some documentation".into()),
···
268
"one".into(),
269
ValueConstructor {
270
public: true,
271
-
deprecated: false,
272
type_: type_::int(),
273
variant: ValueConstructorVariant::ModuleFn {
274
documentation: Some("wobble!".into()),
···
301
"one".into(),
302
ValueConstructor {
303
public: true,
304
-
deprecated: true,
0
0
305
type_: type_::int(),
306
variant: ValueConstructorVariant::ModuleFn {
307
documentation: Some("wobble!".into()),
···
334
"one".into(),
335
ValueConstructor {
336
public: false,
337
-
deprecated: false,
338
type_: type_::int(),
339
variant: ValueConstructorVariant::ModuleFn {
340
documentation: Some("wobble!".into()),
···
369
"one".into(),
370
ValueConstructor {
371
public: true,
372
-
deprecated: false,
373
type_: type_::int(),
374
variant: ValueConstructorVariant::ModuleFn {
375
documentation: Some("wabble!".into()),
···
403
"one".into(),
404
ValueConstructor {
405
public: true,
406
-
deprecated: false,
407
type_: type_::int(),
408
variant: ValueConstructorVariant::ModuleFn {
409
documentation: Some("wubble!".into()),
···
439
"one".into(),
440
ValueConstructor {
441
public: true,
442
-
deprecated: false,
443
type_: type_::int(),
444
variant: ValueConstructorVariant::Record {
445
documentation: Some("webble!".into()),
···
476
"one".into(),
477
ValueConstructor {
478
public: true,
479
-
deprecated: false,
480
type_: type_::int(),
481
variant: ValueConstructorVariant::Record {
482
documentation: Some("wybble!".into()),
···
694
typ: type_::int(),
695
constructor: Some(Box::from(ValueConstructor {
696
public: true,
697
-
deprecated: false,
698
type_: type_::int(),
699
variant: ValueConstructorVariant::ModuleConstant {
700
documentation: Some("some doc".into()),
···
717
"one".into(),
718
ValueConstructor {
719
public: true,
720
-
deprecated: false,
721
type_: type_::int(),
722
variant: ValueConstructorVariant::ModuleConstant {
723
documentation: Some("some doc!!!!!!!!!".into()),
···
731
"one_original".into(),
732
ValueConstructor {
733
public: true,
734
-
deprecated: false,
735
type_: type_::int(),
736
variant: ValueConstructorVariant::ModuleConstant {
737
documentation: Some("some doc yeah".into()),
···
9
},
10
build::Origin,
11
type_::{
12
+
self, Deprecation, ModuleInterface, Type, TypeConstructor, ValueConstructor,
13
+
ValueConstructorVariant,
14
},
15
uid::UniqueIdGenerator,
16
};
···
38
"one".into(),
39
ValueConstructor {
40
public: true,
41
+
deprecation: Deprecation::NotDeprecated,
42
type_: type_::int(),
43
variant: ValueConstructorVariant::ModuleConstant {
44
documentation: Some("Some documentation".into()),
···
269
"one".into(),
270
ValueConstructor {
271
public: true,
272
+
deprecation: Deprecation::NotDeprecated,
273
type_: type_::int(),
274
variant: ValueConstructorVariant::ModuleFn {
275
documentation: Some("wobble!".into()),
···
302
"one".into(),
303
ValueConstructor {
304
public: true,
305
+
deprecation: Deprecation::Deprecated {
306
+
message: "wibble wobble".into(),
307
+
},
308
type_: type_::int(),
309
variant: ValueConstructorVariant::ModuleFn {
310
documentation: Some("wobble!".into()),
···
337
"one".into(),
338
ValueConstructor {
339
public: false,
340
+
deprecation: Deprecation::NotDeprecated,
341
type_: type_::int(),
342
variant: ValueConstructorVariant::ModuleFn {
343
documentation: Some("wobble!".into()),
···
372
"one".into(),
373
ValueConstructor {
374
public: true,
375
+
deprecation: Deprecation::NotDeprecated,
376
type_: type_::int(),
377
variant: ValueConstructorVariant::ModuleFn {
378
documentation: Some("wabble!".into()),
···
406
"one".into(),
407
ValueConstructor {
408
public: true,
409
+
deprecation: Deprecation::NotDeprecated,
410
type_: type_::int(),
411
variant: ValueConstructorVariant::ModuleFn {
412
documentation: Some("wubble!".into()),
···
442
"one".into(),
443
ValueConstructor {
444
public: true,
445
+
deprecation: Deprecation::NotDeprecated,
446
type_: type_::int(),
447
variant: ValueConstructorVariant::Record {
448
documentation: Some("webble!".into()),
···
479
"one".into(),
480
ValueConstructor {
481
public: true,
482
+
deprecation: Deprecation::NotDeprecated,
483
type_: type_::int(),
484
variant: ValueConstructorVariant::Record {
485
documentation: Some("wybble!".into()),
···
697
typ: type_::int(),
698
constructor: Some(Box::from(ValueConstructor {
699
public: true,
700
+
deprecation: Deprecation::NotDeprecated,
701
type_: type_::int(),
702
variant: ValueConstructorVariant::ModuleConstant {
703
documentation: Some("some doc".into()),
···
720
"one".into(),
721
ValueConstructor {
722
public: true,
723
+
deprecation: Deprecation::NotDeprecated,
724
type_: type_::int(),
725
variant: ValueConstructorVariant::ModuleConstant {
726
documentation: Some("some doc!!!!!!!!!".into()),
···
734
"one_original".into(),
735
ValueConstructor {
736
public: true,
737
+
deprecation: Deprecation::NotDeprecated,
738
type_: type_::int(),
739
variant: ValueConstructorVariant::ModuleConstant {
740
documentation: Some("some doc yeah".into()),
+5
-3
compiler-core/src/parse.rs
···
66
};
67
use crate::build::Target;
68
use crate::parse::extra::ModuleExtra;
0
69
use error::{LexicalError, ParseError, ParseErrorType};
70
use lexer::{LexResult, Spanned};
71
use smol_str::SmolStr;
···
88
#[derive(Debug, Default)]
89
struct Attributes {
90
target: Option<Target>,
91
-
deprecated: bool,
92
external_erlang: Option<(SmolStr, SmolStr)>,
93
external_javascript: Option<(SmolStr, SmolStr)>,
94
}
···
1437
body,
1438
return_type: (),
1439
return_annotation,
1440
-
deprecated: attributes.deprecated,
1441
external_erlang: attributes.external_erlang.take(),
1442
external_javascript: attributes.external_javascript.take(),
1443
})))
···
2738
&mut self,
2739
attributes: &mut Attributes,
2740
) -> Result<(), ParseError> {
0
2741
let (_, _) = self.expect_one(&Token::RightParen)?;
2742
-
attributes.deprecated = true;
2743
Ok(())
2744
}
2745
}
···
66
};
67
use crate::build::Target;
68
use crate::parse::extra::ModuleExtra;
69
+
use crate::type_::Deprecation;
70
use error::{LexicalError, ParseError, ParseErrorType};
71
use lexer::{LexResult, Spanned};
72
use smol_str::SmolStr;
···
89
#[derive(Debug, Default)]
90
struct Attributes {
91
target: Option<Target>,
92
+
deprecated: Deprecation,
93
external_erlang: Option<(SmolStr, SmolStr)>,
94
external_javascript: Option<(SmolStr, SmolStr)>,
95
}
···
1438
body,
1439
return_type: (),
1440
return_annotation,
1441
+
deprecation: std::mem::take(&mut attributes.deprecated),
1442
external_erlang: attributes.external_erlang.take(),
1443
external_javascript: attributes.external_javascript.take(),
1444
})))
···
2739
&mut self,
2740
attributes: &mut Attributes,
2741
) -> Result<(), ParseError> {
2742
+
let (_, message, _) = self.expect_string()?;
2743
let (_, _) = self.expect_one(&Token::RightParen)?;
2744
+
attributes.deprecated = Deprecation::Deprecated { message };
2745
Ok(())
2746
}
2747
}
+13
-1
compiler-core/src/type_.rs
···
621
#[derive(Debug, Clone, PartialEq, Eq)]
622
pub struct ValueConstructor {
623
pub public: bool,
624
-
pub deprecated: bool,
625
pub variant: ValueConstructorVariant,
626
pub type_: Arc<Type>,
0
0
0
0
0
0
0
0
0
0
0
0
627
}
628
629
impl ValueConstructor {
···
621
#[derive(Debug, Clone, PartialEq, Eq)]
622
pub struct ValueConstructor {
623
pub public: bool,
624
+
pub deprecation: Deprecation,
625
pub variant: ValueConstructorVariant,
626
pub type_: Arc<Type>,
627
+
}
628
+
629
+
#[derive(Debug, Clone, PartialEq, Eq)]
630
+
pub enum Deprecation {
631
+
NotDeprecated,
632
+
Deprecated { message: SmolStr },
633
+
}
634
+
635
+
impl Default for Deprecation {
636
+
fn default() -> Self {
637
+
Self::NotDeprecated
638
+
}
639
}
640
641
impl ValueConstructor {
+3
-3
compiler-core/src/type_/environment.rs
···
168
let _ = self.scope.insert(
169
name,
170
ValueConstructor {
171
-
deprecated: false,
172
public: false,
173
variant: ValueConstructorVariant::LocalVariable { location },
174
type_: typ,
···
184
variant: ValueConstructorVariant,
185
typ: Arc<Type>,
186
public: bool,
187
-
deprecated: bool,
188
) {
189
let _ = self.scope.insert(
190
name,
191
ValueConstructor {
192
public,
193
-
deprecated,
194
variant,
195
type_: typ,
196
},
···
168
let _ = self.scope.insert(
169
name,
170
ValueConstructor {
171
+
deprecation: Deprecation::NotDeprecated,
172
public: false,
173
variant: ValueConstructorVariant::LocalVariable { location },
174
type_: typ,
···
184
variant: ValueConstructorVariant,
185
typ: Arc<Type>,
186
public: bool,
187
+
deprecation: Deprecation,
188
) {
189
let _ = self.scope.insert(
190
name,
191
ValueConstructor {
192
public,
193
+
deprecation,
194
variant,
195
type_: typ,
196
},
+2
-2
compiler-core/src/type_/expression.rs
···
1605
public,
1606
variant,
1607
type_: typ,
1608
-
deprecated,
1609
} = constructor;
1610
1611
// Instantiate generic variables into unbound variables for this usage
1612
let typ = self.instantiate(typ, &mut hashmap![]);
1613
Ok(ValueConstructor {
1614
public,
1615
-
deprecated,
1616
variant,
1617
type_: typ,
1618
})
···
1605
public,
1606
variant,
1607
type_: typ,
1608
+
deprecation: deprecated,
1609
} = constructor;
1610
1611
// Instantiate generic variables into unbound variables for this usage
1612
let typ = self.instantiate(typ, &mut hashmap![]);
1613
Ok(ValueConstructor {
1614
public,
1615
+
deprecation: deprecated,
1616
variant,
1617
type_: typ,
1618
})
+1
-1
compiler-core/src/type_/pipe.rs
···
134
name: PIPE_VARIABLE.into(),
135
constructor: ValueConstructor {
136
public: true,
137
-
deprecated: false,
138
type_: self.argument_type.clone(),
139
variant: ValueConstructorVariant::LocalVariable {
140
location: self.argument_location,
···
134
name: PIPE_VARIABLE.into(),
135
constructor: ValueConstructor {
136
public: true,
137
+
deprecation: Deprecation::NotDeprecated,
138
type_: self.argument_type.clone(),
139
variant: ValueConstructorVariant::LocalVariable {
140
location: self.argument_location,
+3
-2
compiler-core/src/type_/prelude.rs
···
3
use crate::{ast::SrcSpan, build::Origin, uid::UniqueIdGenerator};
4
5
use super::{
6
-
ModuleInterface, Type, TypeConstructor, TypeVar, ValueConstructor, ValueConstructorVariant,
0
7
};
8
use std::{cell::RefCell, collections::HashMap, sync::Arc};
9
···
163
pub fn build_prelude(ids: &UniqueIdGenerator) -> ModuleInterface {
164
let value = |variant, type_| ValueConstructor {
165
public: true,
166
-
deprecated: false,
167
variant,
168
type_,
169
};
···
3
use crate::{ast::SrcSpan, build::Origin, uid::UniqueIdGenerator};
4
5
use super::{
6
+
Deprecation, ModuleInterface, Type, TypeConstructor, TypeVar, ValueConstructor,
7
+
ValueConstructorVariant,
8
};
9
use std::{cell::RefCell, collections::HashMap, sync::Arc};
10
···
164
pub fn build_prelude(ids: &UniqueIdGenerator) -> ModuleInterface {
165
let value = |variant, type_| ValueConstructor {
166
public: true,
167
+
deprecation: Deprecation::NotDeprecated,
168
variant,
169
type_,
170
};
+3
-3
compiler-core/src/type_/tests/functions.rs
···
144
#[test]
145
fn deprecated_function() {
146
assert_module_infer!(
147
-
"
148
-
@deprecated()
149
pub fn main() {
150
Nil
151
-
}",
152
vec![(r#"main"#, r#"fn() -> Nil"#)]
153
);
154
}
···
144
#[test]
145
fn deprecated_function() {
146
assert_module_infer!(
147
+
r#"
148
+
@deprecated("use wibble instead")
149
pub fn main() {
150
Nil
151
+
}"#,
152
vec![(r#"main"#, r#"fn() -> Nil"#)]
153
);
154
}