Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@

- Load a compiled module's interface into its first dependent without decoding it again, and keep the syntax tree nodes the built-in frontend pass leaves unchanged instead of copying them. https://github.com/jfrolich/rescript-rust/pull/89 https://github.com/jfrolich/rescript-rust/pull/85

- Print the path of a value or type for a deprecation warning only when the item is deprecated, instead of on every use. https://github.com/jfrolich/rescript-rust/pull/98

- Compute the item digests and item references of a compiled module's interface once, when it is published, instead of decoding the stored interface again for each. https://github.com/jfrolich/rescript-rust/pull/87

- Type-check faster: lower argument levels directly, settle the checks before binding a type variable in one walk, and skip the inclusion check of a unit against its own inferred signature. https://github.com/jfrolich/rescript-rust/pull/84
Expand Down
18 changes: 16 additions & 2 deletions compiler-rust/src/types/typecore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7667,6 +7667,20 @@ fn deprecated_warning_from_attrs(
.map(|(reason, can_be_automigrated)| deprecated_warning(name, reason, can_be_automigrated)))
}

/// `deprecated_warning_from_attrs` for an item named by its path. The name is
/// printed only for a deprecated item: this runs on every use of a value or
/// type, and almost none of them is deprecated.
fn deprecated_warning_for_path(
path: &Path,
attrs: &[crate::types::decl::Attribute],
) -> Result<Option<Warning>, crate::types::DeclLoc> {
Ok(
deprecated_attr_payload(attrs)?.map(|(reason, can_be_automigrated)| {
deprecated_warning(path.name().as_str(), reason, can_be_automigrated)
}),
)
}

/// `Builtin_attributes.deprecated_of_attrs` (builtin_attributes.ml:59-62):
/// `string_of_opt_payload` of the first `deprecated` attribute, the record
/// form reading as `""`; `Err` where it raises.
Expand Down Expand Up @@ -7835,14 +7849,14 @@ fn deprecated_warning_for_value(
path: &Path,
desc: &ValueDescription,
) -> Result<Option<Warning>, crate::types::DeclLoc> {
deprecated_warning_from_attrs(path.name().as_str(), &desc.val_attributes)
deprecated_warning_for_path(path, &desc.val_attributes)
}

fn deprecated_warning_for_type(
path: &Path,
decl: &crate::types::decl::TypeDeclaration,
) -> Result<Option<Warning>, crate::types::DeclLoc> {
deprecated_warning_from_attrs(path.name().as_str(), &decl.type_attributes)
deprecated_warning_for_path(path, &decl.type_attributes)
}

/// Type check an expression against an expected type.
Expand Down
Loading