Skip to content

Commit

Permalink
chore: Update rust-toolchain to nightly-2023-10-04 (dudykr#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbuchan authored and sunrabbit123 committed Oct 10, 2023
1 parent 0488618 commit fcec481
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["crates/stc", "crates/binding_wasm"]
resolver = "2"

[profile.release]
lto = "off"
Expand Down
10 changes: 5 additions & 5 deletions crates/stc_ts_builtin_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
#[macro_use]
extern crate pmutil;

use std::{collections::HashMap, fs::read_dir, path::Path, sync::Arc};
use std::{collections::HashMap, env, fs::read_dir, path::Path};

use inflector::Inflector;
use pmutil::Quote;
use proc_macro2::Span;
use swc_common::{comments::SingleThreadedComments, FilePathMapping, SourceMap};
use swc_common::{comments::SingleThreadedComments, sync::Lrc, FilePathMapping, SourceMap};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax, TsConfig};
use swc_macros_common::{call_site, print};
use syn::{punctuated::Punctuated, Token};

#[proc_macro]
pub fn builtin(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
swc_common::GLOBALS.set(&swc_common::Globals::new(), || {
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));

let mut deps = HashMap::<String, Vec<String>>::default();

Expand All @@ -37,11 +37,11 @@ pub fn builtin(_: proc_macro::TokenStream) -> proc_macro::TokenStream {

let mut contents = HashMap::<String, String>::default();

let dir_str = ::std::env::var("CARGO_MANIFEST_DIR").expect("failed to read CARGO_MANIFEST_DIR");
let dir_str = env::var("CARGO_MANIFEST_DIR").expect("failed to read CARGO_MANIFEST_DIR");
let dir = Path::new(&dir_str).join("lib");
let mut tokens = q();

let mut files = read_dir(&dir)
let mut files = read_dir(dir)
.expect("failed to read $CARGO_MANIFEST_DIR/lib")
.filter_map(|entry| {
let entry = entry.expect("failed to read file of directory");
Expand Down
2 changes: 1 addition & 1 deletion crates/stc_ts_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl From<ErrorKind> for Error {
impl Error {
#[track_caller]
pub fn context(self, context: impl Display) -> Error {
return self.context_impl(Location::caller(), context);
self.context_impl(Location::caller(), context)
}

#[cfg_attr(not(debug_assertions), inline(always))]
Expand Down
4 changes: 1 addition & 3 deletions crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,7 @@ impl Analyzer<'_, '_> {
let l = li.next();
let r = ri.next();

let (Some(l), Some(r)) = (l, r) else {
break
};
let (Some(l), Some(r)) = (l, r) else { break };

// TODO(kdy1): What should we do?
if opts.allow_assignment_to_param {
Expand Down
1 change: 1 addition & 0 deletions crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl Analyzer<'_, '_> {
/// orders.
///
/// After splitting, we can check if each element is assignable.
#[allow(clippy::needless_pass_by_ref_mut)]
pub(crate) fn assign_to_tpl(&mut self, data: &mut AssignData, l: &TplType, r_ty: &Type, opts: AssignOpts) -> VResult<()> {
let span = opts.span;
let r_ty = r_ty.normalize();
Expand Down
3 changes: 2 additions & 1 deletion crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ impl Analyzer<'_, '_> {
let types = u
.types
.iter()
.cloned()
.filter(|callee| !matches!(callee.normalize(), Type::Module(..) | Type::Namespace(..)))
.cloned()
.collect::<Vec<_>>();

match types.len() {
Expand Down Expand Up @@ -3458,6 +3458,7 @@ impl Analyzer<'_, '_> {
///
/// should make type of `subscriber` `SafeSubscriber`, not `Subscriber`.
/// I (kdy1) don't know why.
#[allow(clippy::needless_pass_by_ref_mut)]
fn add_call_facts(&mut self, params: &[FnParam], args: &[RExprOrSpread], ret_ty: &mut Type) {
if !self.ctx.in_cond {
return;
Expand Down
6 changes: 1 addition & 5 deletions crates/stc_ts_file_analyzer/src/analyzer/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,7 @@ impl Analyzer<'_, '_> {
// true,
// // Allow overriding
// true,
// ) {
// Ok(()) => {}
// Err(err) => {
// self.storage.report(err);
// }
// ) { Ok(()) => {} Err(err) => { self.storage.report(err); }
// }
// }

Expand Down
10 changes: 5 additions & 5 deletions crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ pub(crate) struct InferTypeOpts {
}

bitflags! {
#[derive(Default)]
pub struct InferencePriority: i32 {
const None = 0;
/// Naked type variable in union or intersection type
const NakedTypeVariable = 1 << 0;
/// Speculative tuple inference
Expand Down Expand Up @@ -153,10 +153,10 @@ bitflags! {
}
}

impl Default for InferencePriority {
fn default() -> Self {
Self::None
}
impl InferencePriority {
// Defining outside bitflags! to avoid clippy::bad_bit_mask lint in generated
// code.
pub const None: Self = Self::empty();
}

impl Analyzer<'_, '_> {
Expand Down
5 changes: 1 addition & 4 deletions crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ impl Analyzer<'_, '_> {
#[cfg(debug_assertions)]
let _tracing = dev_span!("infer_arg_types");

warn!(
"infer_arg_types: {:?}",
type_params.iter().map(|p| format!("{}, ", p.name)).collect::<String>()
);
warn!("infer_arg_types: {:?}", type_params.iter().map(|p| &p.name).join(", "));

let timer = PerfTimer::noop();

Expand Down
1 change: 1 addition & 0 deletions crates/stc_ts_file_analyzer/src/analyzer/relation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Analyzer<'_, '_> {
self.is_type_related_to_inner(&mut data, source, target, relation)
}

#[allow(clippy::needless_pass_by_ref_mut)]
fn is_type_related_to_inner(&mut self, data: &mut IsRelatedData, source: &Type, target: &Type, relation: Relation) -> bool {
if source.type_eq(target) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl Analyzer<'_, '_> {
}
}
Type::EnumVariant(e) => {
if matches!(e.name, None) && (e.def.has_num || e.def.has_str) {
if e.name.is_none() && (e.def.has_num || e.def.has_str) {
return self.keyof(
span,
&if e.def.has_num && e.def.has_str {
Expand Down
10 changes: 5 additions & 5 deletions crates/stc_ts_file_analyzer/src/type_facts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
use bitflags::bitflags;
use swc_common::add_bitflags;

impl Default for TypeFacts {
fn default() -> Self {
Self::None
}
impl TypeFacts {
// Defining outside bitflags! to avoid clippy::bad_bit_mask lint in generated
// code.
pub const None: Self = Self::empty();
}

bitflags! {
#[derive(Default)]
pub struct TypeFacts: u32 {
const None = 0;
/// typeof x === "string"
const TypeofEQString = 1 << 0;
/// typeof x === "number"
Expand Down
4 changes: 2 additions & 2 deletions crates/stc_ts_file_analyzer/src/util/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) struct NodeId<T>(usize, PhantomData<T>);

impl<T> Clone for NodeId<T> {
fn clone(&self) -> Self {
NodeId(self.0, self.1)
*self
}
}

Expand All @@ -57,7 +57,7 @@ impl<T> Eq for NodeId<T> {}

impl<T> PartialOrd for NodeId<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/stc_ts_type_checker/tests/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ fn do_test(file_name: &Path, spec: TestSpec, use_target: bool) -> Result<(), Std
if is_file_similar(err.file.as_deref(), Some(last)) {
// If this is the last file, we have to shift the errors.
err.line += err_shift_n;
} else {
}
} else {
// If sub files is empty, it means that it's a single-file test, and
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-05-25
nightly-2023-10-04

0 comments on commit fcec481

Please sign in to comment.