Skip to content

Commit

Permalink
Bump MSRV and improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed May 29, 2022
1 parent f2856ec commit 4b60c63
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Explain what you expected to happen, and what is happening instead.
<!-- E.g.:
Running this code, `a` should be set to `10` and printed, but `a` is instead set to `20`. The expected behaviour can be found in the [ECMAScript specification][spec].
[spec]: https://www.ecma-international.org/ecma-262/10.0/index.html#sec-variable-statement-runtime-semantics-evaluation
[spec]: https://tc39.es/ecma262/#sec-variable-statement-runtime-semantics-evaluation
-->

**Build environment (please complete the following information):**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Explain the ECMAScript feature that you'd like to see implemented.
<!-- E.g.:
I would like to see `switch` statement parsing and execution implemented. [ECMAScript specification][spec].
[spec]: https://www.ecma-international.org/ecma-262/10.0/index.html#sec-switch-statement
[spec]: https://tc39.es/ecma262/#sec-switch-statement
-->

**Example code**
Expand Down
2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
106 changes: 70 additions & 36 deletions boa_engine/src/builtins/intl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ impl BuiltIn for Intl {
}

impl Intl {
/// `Intl.getCanonicalLocales ( locales )`
///
/// Returns an array containing the canonical locale names.
///
/// More information:
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -241,9 +250,10 @@ struct UniExtRecord {
keywords: Vec<Keyword>,
}

/// 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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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<Vec<Locale>> {
// https://tc39.es/ecma402/#sec-canonicalizelocalelist
// 1. If locales is undefined, then
let locales = args.get_or_undefined(0);
if locales.is_undefined() {
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/map/map_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/set/set_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions boa_engine/src/context/icu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::rc::Rc;

use icu_datetime::provider::{
calendar::{DatePatternsV1Marker, DateSkeletonPatternsV1Marker, DateSymbolsV1Marker},
week_data::WeekDataV1Marker,
Expand Down Expand Up @@ -40,7 +38,7 @@ impl<T> BoaProvider for T where
/// for the functionality of `Intl`.
#[allow(unused)]
pub(crate) struct Icu {
provider: Rc<dyn BoaProvider>,
provider: Box<dyn BoaProvider>,
locale_canonicalizer: LocaleCanonicalizer,
}

Expand All @@ -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<dyn BoaProvider>) -> Result<Self, DataError> {
pub(crate) fn new(provider: Box<dyn BoaProvider>) -> Result<Self, DataError> {
Ok(Self {
locale_canonicalizer: LocaleCanonicalizer::new(&*provider)?,
provider,
Expand Down
7 changes: 2 additions & 5 deletions boa_engine/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn icu::BoaProvider>,
) -> Result<Self, DataError> {
pub fn icu_provider(mut self, provider: Box<dyn icu::BoaProvider>) -> Result<Self, DataError> {
self.icu = Some(icu::Icu::new(provider)?);
Ok(self)
}
Expand Down Expand Up @@ -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.")
}),
};
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/syntax/ast/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/syntax/lexer/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion boa_gc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion boa_interner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion boa_profiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion boa_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion boa_unicode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 4b60c63

Please sign in to comment.