From 4b60c638137d401511e486f1a59ef09f798b903f Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Sun, 29 May 2022 04:22:23 -0500 Subject: [PATCH] Bump MSRV and improve documentation --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- boa_cli/Cargo.toml | 2 +- boa_engine/Cargo.toml | 2 +- boa_engine/src/builtins/intl/mod.rs | 106 ++++++++++++------ boa_engine/src/builtins/map/map_iterator.rs | 2 +- boa_engine/src/builtins/map/mod.rs | 2 +- boa_engine/src/builtins/set/set_iterator.rs | 2 +- boa_engine/src/context/icu.rs | 6 +- boa_engine/src/context/mod.rs | 7 +- boa_engine/src/lib.rs | 2 +- boa_engine/src/syntax/ast/keyword.rs | 4 +- boa_engine/src/syntax/lexer/regex.rs | 2 +- .../hoistable/async_function_decl/mod.rs | 2 +- boa_gc/Cargo.toml | 2 +- boa_interner/Cargo.toml | 2 +- boa_profiler/Cargo.toml | 2 +- boa_tester/Cargo.toml | 2 +- boa_unicode/Cargo.toml | 2 +- boa_wasm/Cargo.toml | 2 +- 20 files changed, 92 insertions(+), 63 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9773988656b..6e249842494 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -34,7 +34,7 @@ Explain what you expected to happen, and what is happening instead. **Build environment (please complete the following information):** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index a78986bab9c..7687b7befe2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -16,7 +16,7 @@ Explain the ECMAScript feature that you'd like to see implemented. **Example code** diff --git a/boa_cli/Cargo.toml b/boa_cli/Cargo.toml index b36c57fe417..e3404680e42 100644 --- a/boa_cli/Cargo.toml +++ b/boa_cli/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_cli" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." repository = "https://github.com/boa-dev/boa" diff --git a/boa_engine/Cargo.toml b/boa_engine/Cargo.toml index 53f4024bd63..5cf50c83a89 100644 --- a/boa_engine/Cargo.toml +++ b/boa_engine/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_engine" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." repository = "https://github.com/boa-dev/boa" diff --git a/boa_engine/src/builtins/intl/mod.rs b/boa_engine/src/builtins/intl/mod.rs index bd5ba0c8ac6..d4a23ee12c3 100644 --- a/boa_engine/src/builtins/intl/mod.rs +++ b/boa_engine/src/builtins/intl/mod.rs @@ -58,6 +58,8 @@ impl BuiltIn for Intl { } impl Intl { + /// `Intl.getCanonicalLocales ( locales )` + /// /// Returns an array containing the canonical locale names. /// /// More information: @@ -91,9 +93,10 @@ struct MatcherRecord { extension: JsString, } -/// The `DefaultLocale` abstract operation returns a String value representing the structurally -/// valid and canonicalized Unicode BCP 47 locale identifier for the host environment's current -/// locale. +/// Abstract operation `DefaultLocale ( )` +/// +/// Returns a String value representing the structurally valid and canonicalized +/// Unicode BCP 47 locale identifier for the host environment's current locale. /// /// More information: /// - [ECMAScript reference][spec] @@ -106,11 +109,13 @@ fn default_locale(canonicalizer: &LocaleCanonicalizer) -> Locale { .unwrap_or(locale!("en-US")) } -/// The `BestAvailableLocale` abstract operation compares the provided argument `locale`, -/// which must be a String value with a structurally valid and canonicalized Unicode BCP 47 -/// locale identifier, against the locales in `availableLocales` and returns either the longest -/// non-empty prefix of `locale` that is an element of `availableLocales`, or undefined if -/// there is no such element. +/// Abstract operation `BestAvailableLocale ( availableLocales, locale )` +/// +/// Compares the provided argument `locale`, which must be a String value with a +/// structurally valid and canonicalized Unicode BCP 47 locale identifier, against +/// the locales in `availableLocales` and returns either the longest non-empty prefix +/// of `locale` that is an element of `availableLocales`, or undefined if there is no +/// such element. /// /// More information: /// - [ECMAScript reference][spec] @@ -146,9 +151,11 @@ fn best_available_locale(available_locales: &[JsString], locale: &JsString) -> O } } -/// The `LookupMatcher` abstract operation compares `requestedLocales`, which must be a `List` -/// as returned by `CanonicalizeLocaleList`, against the locales in `availableLocales` and -/// determines the best available language to meet the request. +/// Abstract operation `LookupMatcher ( availableLocales, requestedLocales )` +/// +/// Compares `requestedLocales`, which must be a `List` as returned by `CanonicalizeLocaleList`, +/// against the locales in `availableLocales` and determines the best available language to +/// meet the request. /// /// More information: /// - [ECMAScript reference][spec] @@ -202,11 +209,13 @@ fn lookup_matcher( } } -/// The `BestFitMatcher` abstract operation compares `requestedLocales`, which must be a `List` -/// as returned by `CanonicalizeLocaleList`, against the locales in `availableLocales` and -/// determines the best available language to meet the request. The algorithm is implementation -/// dependent, but should produce results that a typical user of the requested locales would -/// perceive as at least as good as those produced by the `LookupMatcher` abstract operation. +/// Abstract operation `BestFitMatcher ( availableLocales, requestedLocales )` +/// +/// Compares `requestedLocales`, which must be a `List` as returned by `CanonicalizeLocaleList`, +/// against the locales in `availableLocales` and determines the best available language to +/// meet the request. The algorithm is implementation dependent, but should produce results +/// that a typical user of the requested locales would perceive as at least as good as those +/// produced by the `LookupMatcher` abstract operation. /// /// More information: /// - [ECMAScript reference][spec] @@ -241,9 +250,10 @@ struct UniExtRecord { keywords: Vec, } -/// The `UnicodeExtensionComponents` abstract operation returns the attributes and keywords from -/// `extension`, which must be a String value whose contents are a `Unicode locale extension` -/// sequence. +/// Abstract operation `UnicodeExtensionComponents ( extension )` +/// +/// Returns the attributes and keywords from `extension`, which must be a String +/// value whose contents are a `Unicode locale extension` sequence. /// /// More information: /// - [ECMAScript reference][spec] @@ -345,9 +355,11 @@ fn unicode_extension_components(extension: &JsString) -> UniExtRecord { } } -/// The `InsertUnicodeExtensionAndCanonicalize` abstract operation inserts `extension`, which must -/// be a Unicode locale extension sequence, into `locale`, which must be a String value with a -/// structurally valid and canonicalized Unicode BCP 47 locale identifier. +/// Abstract operation `InsertUnicodeExtensionAndCanonicalize ( locale, extension )` +/// +/// Inserts `extension`, which must be a Unicode locale extension sequence, into +/// `locale`, which must be a String value with a structurally valid and canonicalized +/// Unicode BCP 47 locale identifier. /// /// More information: /// - [ECMAScript reference][spec] @@ -395,8 +407,22 @@ fn insert_unicode_extension_and_canonicalize( new_locale.to_string().into() } +/// Abstract operation `CanonicalizeLocaleList ( locales )` +/// +/// Converts an array of [`JsValue`]s containing structurally valid +/// [Unicode BCP 47 locale identifiers][bcp-47] into their [canonical form][canon]. +/// +/// For efficiency, this returns a [`Vec`] of [`Locale`]s instead of a [`Vec`] of +/// [`String`]s, since [`Locale`] allows us to modify individual parts of the locale +/// without scanning the whole string again. +/// +/// More information: +/// - [ECMAScript reference][spec] +/// +/// [spec]: https://tc39.es/ecma402/#sec-canonicalizelocalelist +/// [bcp-47]: https://unicode.org/reports/tr35/#Unicode_locale_identifier +/// [canon]: https://unicode.org/reports/tr35/#LocaleId_Canonicalization fn canonicalize_locale_list(args: &[JsValue], context: &mut Context) -> JsResult> { - // https://tc39.es/ecma402/#sec-canonicalizelocalelist // 1. If locales is undefined, then let locales = args.get_or_undefined(0); if locales.is_undefined() { @@ -484,10 +510,12 @@ struct ResolveLocaleRecord { pub(crate) data_locale: JsString, } -/// The `ResolveLocale` abstract operation compares a BCP 47 language priority list -/// `requestedLocales` against the locales in `availableLocales` and determines the best -/// available language to meet the request. `availableLocales`, `requestedLocales`, and -/// `relevantExtensionKeys` must be provided as `List` values, options and `localeData` as Records. +/// Abstract operation `ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData )` +/// +/// Compares a BCP 47 language priority list `requestedLocales` against the locales +/// in `availableLocales` and determines the best available language to meet the request. +/// `availableLocales`, `requestedLocales`, and `relevantExtensionKeys` must be provided as +/// `List` values, options and `localeData` as Records. /// /// More information: /// - [ECMAScript reference][spec] @@ -682,9 +710,11 @@ pub(crate) enum GetOptionType { Boolean, } -/// The abstract operation `GetOption` extracts the value of the property named `property` from the -/// provided `options` object, converts it to the required `type`, checks whether it is one of a -/// `List` of allowed `values`, and fills in a `fallback` value if necessary. If `values` is +/// Abstract operation `GetOption ( options, property, type, values, fallback )` +/// +/// Extracts the value of the property named `property` from the provided `options` object, +/// converts it to the required `type`, checks whether it is one of a `List` of allowed +/// `values`, and fills in a `fallback` value if necessary. If `values` is /// undefined, there is no fixed set of values and any is permitted. /// /// More information: @@ -731,9 +761,11 @@ pub(crate) fn get_option( Ok(value) } -/// The abstract operation `GetNumberOption` extracts the value of the property named `property` -/// from the provided `options` object, converts it to a `Number value`, checks whether it is in -/// the allowed range, and fills in a `fallback` value if necessary. +/// Abstract operation `GetNumberOption ( options, property, minimum, maximum, fallback )` +/// +/// Extracts the value of the property named `property` from the provided `options` +/// object, converts it to a `Number value`, checks whether it is in the allowed range, +/// and fills in a `fallback` value if necessary. /// /// More information: /// - [ECMAScript reference][spec] @@ -756,8 +788,10 @@ pub(crate) fn get_number_option( default_number_option(&value, minimum, maximum, fallback, context) } -/// The abstract operation `DefaultNumberOption` converts `value` to a `Number value`, checks -/// whether it is in the allowed range, and fills in a `fallback` value if necessary. +/// Abstract operation `DefaultNumberOption ( value, minimum, maximum, fallback )` +/// +/// Converts `value` to a `Number value`, checks whether it is in the allowed range, +/// and fills in a `fallback` value if necessary. /// /// More information: /// - [ECMAScript reference][spec] @@ -796,7 +830,7 @@ pub(crate) fn default_number_option( /// More information: /// - [ECMAScript reference][spec] /// -/// [spec]: https://402.ecma-international.org/8.0/#sec-canonicalizeunicodelocaleid +/// [spec]: https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid fn canonicalize_unicode_locale_id(locale: &mut Locale, canonicalizer: &LocaleCanonicalizer) { canonicalizer.canonicalize(locale); } diff --git a/boa_engine/src/builtins/map/map_iterator.rs b/boa_engine/src/builtins/map/map_iterator.rs index 7ed7c236c34..d847beb8c81 100644 --- a/boa_engine/src/builtins/map/map_iterator.rs +++ b/boa_engine/src/builtins/map/map_iterator.rs @@ -33,7 +33,7 @@ impl MapIterator { /// More information: /// - [ECMA reference][spec] /// - /// [spec]: https://www.ecma-international.org/ecma-262/11.0/index.html#sec-createmapiterator + /// [spec]: https://tc39.es/ecma262/#sec-createmapiterator pub(crate) fn create_map_iterator( map: &JsValue, kind: PropertyNameKind, diff --git a/boa_engine/src/builtins/map/mod.rs b/boa_engine/src/builtins/map/mod.rs index 673d7f9b386..26bf2075aff 100644 --- a/boa_engine/src/builtins/map/mod.rs +++ b/boa_engine/src/builtins/map/mod.rs @@ -170,7 +170,7 @@ impl Map { /// - [ECMAScript reference][spec] /// - [MDN documentation][mdn] /// - /// [spec]: https://www.ecma-international.org/ecma-262/11.0/index.html#sec-map.prototype.entries + /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.entries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries pub(crate) fn entries( this: &JsValue, diff --git a/boa_engine/src/builtins/set/set_iterator.rs b/boa_engine/src/builtins/set/set_iterator.rs index 07b2f5e2c72..af27d13e306 100644 --- a/boa_engine/src/builtins/set/set_iterator.rs +++ b/boa_engine/src/builtins/set/set_iterator.rs @@ -40,7 +40,7 @@ impl SetIterator { /// More information: /// - [ECMA reference][spec] /// - /// [spec]: https://www.ecma-international.org/ecma-262/11.0/index.html#sec-createsetiterator + /// [spec]: https://tc39.es/ecma262/#sec-createsetiterator pub(crate) fn create_set_iterator( set: JsValue, kind: PropertyNameKind, diff --git a/boa_engine/src/context/icu.rs b/boa_engine/src/context/icu.rs index d0cff263474..880d9d01916 100644 --- a/boa_engine/src/context/icu.rs +++ b/boa_engine/src/context/icu.rs @@ -1,5 +1,3 @@ -use std::rc::Rc; - use icu_datetime::provider::{ calendar::{DatePatternsV1Marker, DateSkeletonPatternsV1Marker, DateSymbolsV1Marker}, week_data::WeekDataV1Marker, @@ -40,7 +38,7 @@ impl BoaProvider for T where /// for the functionality of `Intl`. #[allow(unused)] pub(crate) struct Icu { - provider: Rc, + provider: Box, locale_canonicalizer: LocaleCanonicalizer, } @@ -61,7 +59,7 @@ impl Icu { /// /// This method will return an error if any of the tools /// required cannot be constructed. - pub(crate) fn new(provider: Rc) -> Result { + pub(crate) fn new(provider: Box) -> Result { Ok(Self { locale_canonicalizer: LocaleCanonicalizer::new(&*provider)?, provider, diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 73ac3ee826b..e95bc92e09d 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -763,10 +763,7 @@ impl ContextBuilder { /// /// This function is only available if the `intl` feature is enabled. #[cfg(any(feature = "intl", docs))] - pub fn icu_provider( - mut self, - provider: std::rc::Rc, - ) -> Result { + pub fn icu_provider(mut self, provider: Box) -> Result { self.icu = Some(icu::Icu::new(provider)?); Ok(self) } @@ -795,7 +792,7 @@ impl ContextBuilder { #[cfg(feature = "intl")] icu: self.icu.unwrap_or_else(|| { // TODO: Replace with a more fitting default - icu::Icu::new(std::rc::Rc::new(icu_testdata::get_provider())) + icu::Icu::new(Box::new(icu_testdata::get_provider())) .expect("Failed to initialize default icu data.") }), }; diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index 86831460edb..8f550f5f824 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -8,7 +8,7 @@ //! - **intl** - Enables `boa`'s [ECMA-402 Internationalization API][ecma-402] (`Intl` object) //! //! [whatwg]: https://console.spec.whatwg.org -//! [ecma-402]: https://402.ecma-international.org +//! [ecma-402]: https://tc39.es/ecma402 #![doc( html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", diff --git a/boa_engine/src/syntax/ast/keyword.rs b/boa_engine/src/syntax/ast/keyword.rs index 16389db0fbd..723d0d6172d 100644 --- a/boa_engine/src/syntax/ast/keyword.rs +++ b/boa_engine/src/syntax/ast/keyword.rs @@ -4,7 +4,7 @@ //! - [ECMAScript reference][spec] //! - [MDN documentation][mdn] //! -//! [spec]: https://www.ecma-international.org/ecma-262/#sec-keywords +//! [spec]: https://tc39.es/ecma262/#sec-keywords-and-reserved-words //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords use crate::syntax::ast::op::{BinOp, CompOp}; @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// - [ECMAScript reference][spec] /// - [MDN documentation][mdn] /// -/// [spec]: https://www.ecma-international.org/ecma-262/#sec-keywords +/// [spec]: https://tc39.es/ecma262/#sec-keywords-and-reserved-words /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[derive(Clone, Copy, PartialEq, Debug)] diff --git a/boa_engine/src/syntax/lexer/regex.rs b/boa_engine/src/syntax/lexer/regex.rs index de73c415a94..d18f3922143 100644 --- a/boa_engine/src/syntax/lexer/regex.rs +++ b/boa_engine/src/syntax/lexer/regex.rs @@ -23,7 +23,7 @@ use std::{ /// - [ECMAScript reference][spec] /// - [MDN documentation][mdn] /// -/// [spec]: https://www.ecma-international.org/ecma-262/#sec-literals-regular-expression-literals +/// [spec]: https://tc39.es/ecma262/#sec-literals-regular-expression-literals /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions #[derive(Debug, Clone, Copy)] pub(super) struct RegexLiteral; diff --git a/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs index f01cd523736..951b53b653c 100644 --- a/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs @@ -18,7 +18,7 @@ use std::io::Read; /// - [ECMAScript specification][spec] /// /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function -/// [spec]: https://www.ecma-international.org/ecma-262/11.0/index.html#prod-AsyncFunctionDeclaration +/// [spec]: https://tc39.es/ecma262/#prod-AsyncFunctionDeclaration #[derive(Debug, Clone, Copy)] pub(super) struct AsyncFunctionDeclaration { allow_yield: AllowYield, diff --git a/boa_gc/Cargo.toml b/boa_gc/Cargo.toml index c055eda66d6..519349893e7 100644 --- a/boa_gc/Cargo.toml +++ b/boa_gc/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_gc" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Garbage collector used in Boa." repository = "https://github.com/boa-dev/boa" diff --git a/boa_interner/Cargo.toml b/boa_interner/Cargo.toml index 53633c1f1b4..35aa1b4507f 100644 --- a/boa_interner/Cargo.toml +++ b/boa_interner/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_interner" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "String interner used in Boa." repository = "https://github.com/boa-dev/boa" diff --git a/boa_profiler/Cargo.toml b/boa_profiler/Cargo.toml index 9c0829f9295..fb31e3cb213 100644 --- a/boa_profiler/Cargo.toml +++ b/boa_profiler/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_profiler" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Profiler used in Boa." repository = "https://github.com/boa-dev/boa" diff --git a/boa_tester/Cargo.toml b/boa_tester/Cargo.toml index 9c9a6177b28..ce971546e1e 100644 --- a/boa_tester/Cargo.toml +++ b/boa_tester/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_tester" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Test runner for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa" diff --git a/boa_unicode/Cargo.toml b/boa_unicode/Cargo.toml index 9127836216d..2e5517a7f18 100644 --- a/boa_unicode/Cargo.toml +++ b/boa_unicode/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_unicode" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "Unicode support for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa" diff --git a/boa_wasm/Cargo.toml b/boa_wasm/Cargo.toml index e769ecb1ce9..0f55fa3a26a 100644 --- a/boa_wasm/Cargo.toml +++ b/boa_wasm/Cargo.toml @@ -2,7 +2,7 @@ name = "boa_wasm" version = "0.14.0" edition = "2021" -rust-version = "1.58" +rust-version = "1.60" authors = ["boa-dev"] description = "WASM package for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa"