Skip to content

Commit

Permalink
Merge branch 'master' into xunilrj/better-error-array-numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
IGI-111 authored Aug 23, 2024
2 parents e88eea6 + 34f8515 commit b9d0c55
Show file tree
Hide file tree
Showing 13 changed files with 2,380 additions and 2,161 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
- name: Run sway-lsp tests sequentially
env:
RUST_BACKTRACE: full
run: cargo test --locked --release -p sway-lsp -- --nocapture --test-threads=1
cargo-test-workspace:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions forc-plugins/forc-doc/src/render/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub(crate) fn generate_searchbar(module_info: &ModuleInfo) -> Box<dyn RenderBox>
const searchbar = document.getElementById("search-input");
const searchForm = document.getElementById("search-form");
searchbar.addEventListener("keyup", function(event) {{
searchForm.dispatchEvent(new Event('submit'));
onSearchFormSubmit(event);
}});
searchbar.addEventListener("search", function(event) {{
searchForm.dispatchEvent(new Event('submit'));
onSearchFormSubmit(event);
}});
function onQueryParamsChange() {{
Expand Down
9 changes: 4 additions & 5 deletions forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,22 +831,28 @@ fn type_check_trait_implementation(
None,
),
};
trait_type_mapping.extend(&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info1,
type_decl.name.span().source_id(),
)],
vec![type_decl.ty.clone().unwrap().type_id],
));
trait_type_mapping.extend(&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info2,
type_decl.name.span().source_id(),
)],
vec![type_decl.ty.clone().unwrap().type_id],
));
if let Some(type_arg) = type_decl.ty.clone() {
trait_type_mapping.extend(
&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info1,
type_decl.name.span().source_id(),
)],
vec![type_arg.type_id],
),
);
trait_type_mapping.extend(
&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info2,
type_decl.name.span().source_id(),
)],
vec![type_arg.type_id],
),
);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions sway-lib-std/src/auth.sw
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ pub fn msg_sender() -> Result<Identity, AuthError> {
/// }
/// ```
pub fn caller_address() -> Result<Address, AuthError> {
// Note: `input_count()` is guaranteed to be at least 1 for any valid tx.
let inputs = input_count().as_u64();
let mut candidate = None;
let mut iter = 0;

// Note: `inputs_count` is guaranteed to be at least 1 for any valid tx.
while iter < inputs {
let type_of_input = input_type(iter);
match type_of_input {
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn caller_address() -> Result<Address, AuthError> {
}

// Compare current input owner to candidate.
// `candidate` and `input_coin_owner` must be `Some`.
// `candidate` and `owner_of_input` must be `Some`.
// at this point, so we can unwrap safely.
if owner_of_input.unwrap() == candidate.unwrap() {
// Owners are a match, continue looping.
Expand Down
39 changes: 25 additions & 14 deletions sway-lsp/src/server_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct ServerState {
pub(crate) cb_rx: Arc<Receiver<TaskMessage>>,
pub(crate) finished_compilation: Arc<Notify>,
pub(crate) pid_locked_files: PidLockedFiles,
manifest_cache: DashMap<Url, Arc<PathBuf>>,
last_compilation_state: Arc<RwLock<LastCompilationState>>,
}

Expand All @@ -68,6 +69,7 @@ impl Default for ServerState {
cb_rx: Arc::new(cb_rx),
finished_compilation: Arc::new(Notify::new()),
pid_locked_files: PidLockedFiles::new(),
manifest_cache: DashMap::new(),
last_compilation_state: Arc::new(RwLock::new(LastCompilationState::Uninitialized)),
};
// Spawn a new thread dedicated to handling compilation tasks
Expand Down Expand Up @@ -351,19 +353,27 @@ impl ServerState {
}

async fn url_to_session(&self, uri: &Url) -> Result<Arc<Session>, LanguageServerError> {
let path = PathBuf::from(uri.path());
let manifest = PackageManifestFile::from_dir(&path).map_err(|_| {
DocumentError::ManifestFileNotFound {
dir: path.to_string_lossy().to_string(),
}
})?;

// strip Forc.toml from the path to get the manifest directory
let manifest_dir = manifest
.path()
.parent()
.ok_or(DirectoryError::ManifestDirNotFound)?
.to_path_buf();
// Try to get the manifest directory from the cache
let manifest_dir = if let Some(cached_dir) = self.manifest_cache.get(uri) {
cached_dir.clone()
} else {
// Otherwise, find the manifest directory from the uri and cache it
let path = PathBuf::from(uri.path());
let manifest = PackageManifestFile::from_dir(&path).map_err(|_| {
DocumentError::ManifestFileNotFound {
dir: path.to_string_lossy().to_string(),
}
})?;
let dir = Arc::new(
manifest
.path()
.parent()
.ok_or(DirectoryError::ManifestDirNotFound)?
.to_path_buf(),
);
self.manifest_cache.insert(uri.clone(), dir.clone());
dir
};

// If the session is already in the cache, return it
if let Some(session) = self.sessions.get(&manifest_dir) {
Expand All @@ -373,7 +383,8 @@ impl ServerState {
// If no session can be found, then we need to call init and insert a new session into the map
let session = Arc::new(Session::new());
session.init(uri, &self.documents).await?;
self.sessions.insert(manifest_dir.clone(), session.clone());
self.sessions
.insert((*manifest_dir).clone(), session.clone());

Ok(session)
}
Expand Down
1 change: 1 addition & 0 deletions swayfmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository.workspace = true
[dependencies]
anyhow = "1"
forc-tracing = { version = "0.63.1", path = "../forc-tracing" }
indoc = "2.0"
ropey = "1.5"
serde = { version = "1.0", features = ["derive"] }
serde_ignored = "0.1.9"
Expand Down
Loading

0 comments on commit b9d0c55

Please sign in to comment.