Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update rust-toolchain to nightly-2023-10-04 #1095

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
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()));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was complaining about Arc on a non-Send/Sync type, interestingly. I think that's probably a clippy bug? Strictly, you don't even need an rc at all, but the docs for SourceMap suggest using this alias, which suppresses the lint.


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)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complaining about data not being mutably used here (though it's not even actually used, there's an allow(unused))

I didn't want to change APIs here, but that's probably more correct.

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); }
kdy1 marked this conversation as resolved.
Show resolved Hide resolved
// }
// }

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(", "));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically a different format (no trailing , ), but it was complaining about the inefficient format, and this is much clearer.


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
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
Loading