Skip to content

Commit

Permalink
Update nightly toolchain (#5376)
Browse files Browse the repository at this point in the history
### Description

This updates the nightly toolchain from nightly-2023-03-09 to
nightly-2023-07-03.

This PR includes Clippy fixes and rustfmt fixes (let else formatting,
finally!)

Next.js PR: vercel/next.js#51757


### Testing Instructions

CI
  • Loading branch information
alexkirsz committed Jul 7, 2023
1 parent 9d5a094 commit 96254ce
Show file tree
Hide file tree
Showing 51 changed files with 215 additions and 158 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.

2 changes: 1 addition & 1 deletion cli/internal/ffi/ffi.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package ffi
// #cgo linux,amd64,staticbinary LDFLAGS: -L${SRCDIR} -lturborepo_ffi_linux_amd64 -lunwind
// #cgo linux,arm64,!staticbinary LDFLAGS: -L${SRCDIR} -lturborepo_ffi_linux_arm64 -lz
// #cgo linux,amd64,!staticbinary LDFLAGS: -L${SRCDIR} -lturborepo_ffi_linux_amd64 -lz
// #cgo windows,amd64 LDFLAGS: -L${SRCDIR} -lturborepo_ffi_windows_amd64 -lole32 -lbcrypt -lws2_32 -luserenv
// #cgo windows,amd64 LDFLAGS: -L${SRCDIR} -lturborepo_ffi_windows_amd64 -lole32 -lbcrypt -lws2_32 -luserenv -lntdll
import "C"

import (
Expand Down
22 changes: 11 additions & 11 deletions crates/turbo-tasks-bytes/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// writer (which can be sent to another thread). As new values are written, any
/// pending readers will be woken up to receive the new value.
#[derive(Clone, Debug)]
pub struct Stream<T: Clone> {
pub struct Stream<T: Clone + Send> {
inner: Arc<Mutex<StreamState<T>>>,
}

Expand All @@ -25,7 +25,7 @@ struct StreamState<T> {
pulled: Vec<T>,
}

impl<T: Clone> Stream<T> {
impl<T: Clone + Send> Stream<T> {
/// Constructs a new Stream, and immediately closes it with only the passed
/// values.
pub fn new_closed(pulled: Vec<T>) -> Self {
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<T: Clone> Stream<T> {
}
}

impl<T: Clone, E: Clone> Stream<Result<T, E>> {
impl<T: Clone + Send, E: Clone + Send> Stream<Result<T, E>> {
/// Converts a TryStream into a single value when possible.
pub async fn try_into_single(&self) -> Result<SingleValue<T>, E> {
let mut stream = self.read();
Expand All @@ -99,19 +99,19 @@ pub enum SingleValue<T> {
Single(T),
}

impl<T: Clone, S: StreamTrait<Item = T> + Send + Unpin + 'static> From<S> for Stream<T> {
impl<T: Clone + Send, S: StreamTrait<Item = T> + Send + Unpin + 'static> From<S> for Stream<T> {
fn from(source: S) -> Self {
Self::new_open(vec![], Box::new(source))
}
}

impl<T: Clone> Default for Stream<T> {
impl<T: Clone + Send> Default for Stream<T> {
fn default() -> Self {
Self::new_closed(vec![])
}
}

impl<T: Clone + PartialEq> PartialEq for Stream<T> {
impl<T: Clone + PartialEq + Send> PartialEq for Stream<T> {
// A Stream is equal if it's the same internal pointer, or both streams are
// closed with equivalent values.
fn eq(&self, other: &Self) -> bool {
Expand All @@ -135,9 +135,9 @@ impl<T: Clone + PartialEq> PartialEq for Stream<T> {
}
}
}
impl<T: Clone + Eq> Eq for Stream<T> {}
impl<T: Clone + Eq + Send> Eq for Stream<T> {}

impl<T: Clone + Serialize> Serialize for Stream<T> {
impl<T: Clone + Serialize + Send> Serialize for Stream<T> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::Error;
let lock = self.inner.lock().map_err(Error::custom)?;
Expand All @@ -151,7 +151,7 @@ impl<T: Clone + Serialize> Serialize for Stream<T> {
}
}

impl<'de, T: Clone + Deserialize<'de>> Deserialize<'de> for Stream<T> {
impl<'de, T: Clone + Send + Deserialize<'de>> Deserialize<'de> for Stream<T> {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let data = <Vec<T>>::deserialize(deserializer)?;
Ok(Stream::new_closed(data))
Expand All @@ -168,12 +168,12 @@ impl<T: Clone + fmt::Debug> fmt::Debug for StreamState<T> {

/// Implements [StreamTrait] over our Stream.
#[derive(Debug)]
pub struct StreamRead<T: Clone> {
pub struct StreamRead<T: Clone + Send> {
index: usize,
source: Stream<T>,
}

impl<T: Clone> StreamTrait for StreamRead<T> {
impl<T: Clone + Send> StreamTrait for StreamRead<T> {
type Item = T;

fn poll_next(self: Pin<&mut Self>, cx: &mut TaskContext<'_>) -> Poll<Option<Self::Item>> {
Expand Down
1 change: 0 additions & 1 deletion crates/turbo-tasks-fs/examples/hash_directory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(trivial_bounds)]
#![feature(once_cell)]
#![feature(min_specialization)]

use std::{
Expand Down
1 change: 0 additions & 1 deletion crates/turbo-tasks-fs/examples/hash_glob.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(trivial_bounds)]
#![feature(once_cell)]
#![feature(min_specialization)]

use std::{
Expand Down
20 changes: 12 additions & 8 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(trivial_bounds)]
#![feature(hash_drain_filter)]
#![feature(hash_extract_if)]
#![feature(min_specialization)]
#![feature(iter_advance_by)]
#![feature(io_error_more)]
Expand Down Expand Up @@ -137,7 +137,11 @@ impl DiskWatcher {
));
}
let Some(parent_path) = path.parent() else {
return Err(err).context(format!("Unable to watch {} (tried up to {})", dir_path.display(), path.display()));
return Err(err).context(format!(
"Unable to watch {} (tried up to {})",
dir_path.display(),
path.display()
));
};
path = parent_path;
}
Expand Down Expand Up @@ -408,7 +412,7 @@ impl DiskFileSystem {
for path in paths {
let path_key = path_to_key(&path);
for (_, invalidators) in
invalidator_map.drain_filter(|key, _| key.starts_with(&path_key))
invalidator_map.extract_if(|key, _| key.starts_with(&path_key))
{
invalidators
.into_iter()
Expand Down Expand Up @@ -667,7 +671,7 @@ impl FileSystem for DiskFileSystem {
Ok(LinkContent::Link {
target,
link_type: {
let mut link_type = LinkType::UNSET;
let mut link_type = Default::default();
if link_path.is_absolute() {
link_type |= LinkType::ABSOLUTE;
}
Expand Down Expand Up @@ -1501,8 +1505,9 @@ impl FileContent {

let old_meta = extract_disk_access(retry_future(|| old_file.metadata()).await, &path)?;
let Some(old_meta) = old_meta else {
// If we failed to get meta, then the old file has been deleted between the handle open.
// In which case, we just pretend the file never existed.
// If we failed to get meta, then the old file has been deleted between the
// handle open. In which case, we just pretend the file never
// existed.
return Ok(FileComparison::Create);
};
// If the meta is different, we need to rewrite the file to update it.
Expand Down Expand Up @@ -1540,9 +1545,8 @@ impl FileContent {
}

bitflags! {
#[derive(Serialize, Deserialize, TraceRawVcs)]
#[derive(Default, Serialize, Deserialize, TraceRawVcs)]
pub struct LinkType: u8 {
const UNSET = 0;
const DIRECTORY = 0b00000001;
const ABSOLUTE = 0b00000010;
}
Expand Down
8 changes: 5 additions & 3 deletions crates/turbo-tasks-memory/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ impl Cell {
dependent_tasks, ..
} => {
let dependent_tasks = take(dependent_tasks);
let Cell::Value { content, .. } = replace(self, Cell::TrackedValueless {
dependent_tasks,
}) else { unreachable!() };
let Cell::Value { content, .. } =
replace(self, Cell::TrackedValueless { dependent_tasks })
else {
unreachable!()
};
Some(content)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks-memory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(hash_drain_filter)]
#![feature(hash_extract_if)]
#![feature(option_get_or_insert_default)]
#![feature(type_alias_impl_trait)]
#![feature(lint_reasons)]
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks-memory/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Stats {
pub fn merge(&mut self, mut select: impl FnMut(&StatsTaskType, &ExportedTaskStats) -> bool) {
let merged: HashMap<_, _> = self
.tasks
.drain_filter(|ty, stats| select(ty, stats))
.extract_if(|ty, stats| select(ty, stats))
.collect();

for stats in self.tasks.values_mut() {
Expand Down
6 changes: 5 additions & 1 deletion crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,11 @@ impl Task {
let TaskMetaStateWriteGuard::Full(mut state) = self.state_mut() else {
return;
};
let TaskStateType::InProgress { ref mut count_as_finished, .. } = state.state_type else {
let TaskStateType::InProgress {
ref mut count_as_finished,
..
} = state.state_type
else {
return;
};
if *count_as_finished {
Expand Down
14 changes: 8 additions & 6 deletions crates/turbo-tasks-memory/src/task/meta_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ impl TaskMetaState {

// These need to be impl types since there is no way to reference the zero-sized
// function item type
type TaskMetaStateAsFull = impl Fn(&TaskMetaState) -> Option<&TaskState>;
type TaskMetaStateAsPartial = impl Fn(&TaskMetaState) -> Option<&PartialTaskState>;
type TaskMetaStateAsUnloaded = impl Fn(&TaskMetaState) -> Option<&UnloadedTaskState>;
type TaskMetaStateAsFullMut = impl Fn(&mut TaskMetaState) -> Option<&mut TaskState>;
type TaskMetaStateAsPartialMut = impl Fn(&mut TaskMetaState) -> Option<&mut PartialTaskState>;
type TaskMetaStateAsUnloadedMut = impl Fn(&mut TaskMetaState) -> Option<&mut UnloadedTaskState>;
pub(super) type TaskMetaStateAsFull = impl Fn(&TaskMetaState) -> Option<&TaskState>;
pub(super) type TaskMetaStateAsPartial = impl Fn(&TaskMetaState) -> Option<&PartialTaskState>;
pub(super) type TaskMetaStateAsUnloaded = impl Fn(&TaskMetaState) -> Option<&UnloadedTaskState>;
pub(super) type TaskMetaStateAsFullMut = impl Fn(&mut TaskMetaState) -> Option<&mut TaskState>;
pub(super) type TaskMetaStateAsPartialMut =
impl Fn(&mut TaskMetaState) -> Option<&mut PartialTaskState>;
pub(super) type TaskMetaStateAsUnloadedMut =
impl Fn(&mut TaskMetaState) -> Option<&mut UnloadedTaskState>;

pub(super) enum TaskMetaStateReadGuard<'a> {
Full(ReadGuard<'a, TaskMetaState, TaskState, TaskMetaStateAsFull>),
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks-memory/src/viz/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn wrap_html(table_html: &str) -> String {
script = r#"// https://github.com/tofsjonas/sortable
document.addEventListener("click",function(b){try{var p=function(a){return v&&a.getAttribute("data-sort-alt")||a.getAttribute("data-sort")||a.innerText},q=function(a,c){a.className=a.className.replace(w,"")+c},e=function(a,c){return a.nodeName===c?a:e(a.parentNode,c)},w=/ dir-(u|d) /,v=b.shiftKey||b.altKey,f=e(b.target,"TH"),r=e(f,"TR"),g=e(r,"TABLE");if(/\bsortable\b/.test(g.className)){var h,d=r.cells;for(b=0;b<d.length;b++)d[b]===f?h=b:q(d[b],"");d=" dir-d ";-1!==f.className.indexOf(" dir-d ")&&
(d=" dir-u ");q(f,d);var k=g.tBodies[0],l=[].slice.call(k.rows,0),t=" dir-u "===d;l.sort(function(a,c){var m=p((t?a:c).cells[h]),n=p((t?c:a).cells[h]);return isNaN(m-n)?m.localeCompare(n):m-n});for(var u=k.cloneNode();l.length;)u.appendChild(l.splice(0,1)[0]);g.replaceChild(u,k)}}catch(a){}});"#,
style = r#"body{margin:0;font-family:monospace;}.sortable thead{position:sticky;top:0}.sortable{border-spacing:0}.sortable td,.sortable th{padding:10px}.sortable th{background:gray;color:#fff;cursor:pointer;font-weight:normal;text-align:left;text-transform:capitalize;vertical-align:baseline;white-space:nowrap}.sortable th:hover{color:#000}.sortable th:hover::after{color:inherit;font-size:1.2em;content:' \025B8'}.sortable th::after{font-size:1.2em;color:transparent;content:' \025B8'}.sortable th.dir-d{color:#000}.sortable th.dir-d::after{color:inherit;content:' \025BE'}.sortable th.dir-u{color:#000}.sortable th.dir-u::after{color:inherit;content:' \025B4'}"#
style = r"body{margin:0;font-family:monospace;}.sortable thead{position:sticky;top:0}.sortable{border-spacing:0}.sortable td,.sortable th{padding:10px}.sortable th{background:gray;color:#fff;cursor:pointer;font-weight:normal;text-align:left;text-transform:capitalize;vertical-align:baseline;white-space:nowrap}.sortable th:hover{color:#000}.sortable th:hover::after{color:inherit;font-size:1.2em;content:' \025B8'}.sortable th::after{font-size:1.2em;color:transparent;content:' \025B8'}.sortable th.dir-d{color:#000}.sortable th.dir-d::after{color:inherit;content:' \025BE'}.sortable th.dir-u{color:#000}.sortable th.dir-u::after{color:inherit;content:' \025B4'}"
)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ where

pub fn without_task_id_mapping<T>(func: impl FnOnce() -> T) -> T {
TASK_ID_MAPPING.with(|cell| {
let old = std::mem::replace(&mut *cell.borrow_mut(), None);
let old = cell.borrow_mut().take();
let _swap_guard = TemporarySwapGuard(cell, ManuallyDrop::new(old));
func()
})
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#![feature(trivial_bounds)]
#![feature(min_specialization)]
#![feature(try_trait_v2)]
#![feature(hash_drain_filter)]
#![feature(hash_extract_if)]
#![deny(unsafe_op_in_unsafe_fn)]
#![feature(result_flattening)]
#![feature(error_generic_member_access)]
Expand Down
4 changes: 1 addition & 3 deletions crates/turbo-tasks/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
} else {
drop(start_listener);
}
if timeout.is_zero()
|| matches!(tokio::time::timeout(timeout, listener).await, Err(_))
{
if timeout.is_zero() || tokio::time::timeout(timeout, listener).await.is_err() {
// Timeout
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-cli-utils/src/runtime_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl RuntimeEntriesVc {

for reference in &self.await? {
let resolved_entries = reference.resolve_entry(context).await?;
runtime_entries.extend(resolved_entries.into_iter());
runtime_entries.extend(&resolved_entries);
}

Ok(EvaluatableAssetsVc::cell(runtime_entries))
Expand Down
17 changes: 10 additions & 7 deletions crates/turbopack-core/src/chunk/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ impl ChunkDataVc {
let path = path.to_string();

let Some(output_chunk) = OutputChunkVc::resolve_from(chunk).await? else {
return Ok(ChunkDataOptionVc::cell(Some(ChunkData {
path,
included: Vec::new(),
excluded: Vec::new(),
module_chunks: Vec::new(),
references: AssetReferencesVc::empty(),
}.cell())));
return Ok(ChunkDataOptionVc::cell(Some(
ChunkData {
path,
included: Vec::new(),
excluded: Vec::new(),
module_chunks: Vec::new(),
references: AssetReferencesVc::empty(),
}
.cell(),
)));
};

let runtime_info = output_chunk.runtime_info().await?;
Expand Down
5 changes: 4 additions & 1 deletion crates/turbopack-core/src/chunk/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ impl EvaluatableAssetVc {
Value::new(ReferenceType::Entry(EntryReferenceSubType::Runtime)),
);
let Some(entry) = EvaluatableAssetVc::resolve_from(asset).await? else {
bail!("{} is not a valid evaluated entry", asset.ident().to_string().await?)
bail!(
"{} is not a valid evaluated entry",
asset.ident().to_string().await?
)
};
Ok(entry)
}
Expand Down
18 changes: 14 additions & 4 deletions crates/turbopack-core/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,20 @@ async fn reference_to_graph_nodes<I>(
where
I: FromChunkableAsset + Eq + std::hash::Hash + Clone,
{
let Some(chunkable_asset_reference) = ChunkableAssetReferenceVc::resolve_from(reference).await? else {
return Ok(vec![(None, ChunkContentGraphNode::ExternalAssetReference(reference))]);
let Some(chunkable_asset_reference) =
ChunkableAssetReferenceVc::resolve_from(reference).await?
else {
return Ok(vec![(
None,
ChunkContentGraphNode::ExternalAssetReference(reference),
)]);
};

let Some(chunking_type) = *chunkable_asset_reference.chunking_type().await? else {
return Ok(vec![(None, ChunkContentGraphNode::ExternalAssetReference(reference))]);
return Ok(vec![(
None,
ChunkContentGraphNode::ExternalAssetReference(reference),
)]);
};

let result = reference.resolve_reference().await?;
Expand Down Expand Up @@ -574,7 +582,9 @@ where
_phantom: PhantomData,
};

let GraphTraversalResult::Completed(traversal_result) = AdjacencyMap::new().visit(root_edges, visit).await else {
let GraphTraversalResult::Completed(traversal_result) =
AdjacencyMap::new().visit(root_edges, visit).await
else {
return Ok(None);
};

Expand Down
3 changes: 2 additions & 1 deletion crates/turbopack-core/src/source_map/source_map_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ impl Asset for SourceMapAsset {

#[turbo_tasks::function]
async fn content(&self) -> Result<AssetContentVc> {
let Some(generate_source_map) = GenerateSourceMapVc::resolve_from(&self.asset).await? else {
let Some(generate_source_map) = GenerateSourceMapVc::resolve_from(&self.asset).await?
else {
bail!("asset does not support generating source maps")
};
let sm = if let Some(sm) = &*generate_source_map.generate_source_map().await? {
Expand Down
4 changes: 3 additions & 1 deletion crates/turbopack-css/src/module_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ impl EcmascriptChunkItem for ModuleChunkItem {
continue;
};

let Some(css_module) = ModuleCssAssetVc::resolve_from(resolved_module).await? else {
let Some(css_module) =
ModuleCssAssetVc::resolve_from(resolved_module).await?
else {
CssModuleComposesIssue {
severity: IssueSeverity::Error.cell(),
source: self.module.ident(),
Expand Down

0 comments on commit 96254ce

Please sign in to comment.