profile
viewpoint
Aleksey Kladov matklad @ferrous-systems Berlin https://matklad.github.io/ rosalind.info, Stepik.org, IntelliJ Rust, rust-analyzer. Stuck writing parsers.

intellij-rust/intellij-rust 3248

Rust plugin for the IntelliJ Platform

fitzgen/id-arena 54

A simple, id-based arena

ferrous-systems/cargo-review-deps 45

A tool for auditing Cargo dependencies during updates

async-rs/a-chat 37

A simple chat implemented on top of async-std

cuviper/autocfg 27

Automatic cfg for Rust compiler features

eugenyk/hpcourse 15

Repository to store student's practical works on high performance computing course

CAD97/sorbus 12

An experimental reimplementation of rowan, focused on size efficiency

lambda-llama/icfpc2016 2

λ-llama code for ICFP contest 2016

CAD97/str-index 1

A sketch of a general Rust string index newtype

pull request commentrust-analyzer/rust-analyzer

Textmate grammar: prevent unwanted interpolation scopes

I don't have strong opinion here, as long as things outside of string literals are not classified as string literals :-)

dustypomerleau

comment created time in 4 hours

push eventrust-analyzer/metrics

Bot

commit sha 0ccfeccd0106379d64273f07d0dd33fbd96c9ca6

📈

view details

push time in 4 hours

issue commentrust-analyzer/rust-analyzer

Unresolved import for platform specific modules

https://github.com/rust-analyzer/rust-analyzer/pull/6294 papers over this issue

GrayJack

comment created time in 4 hours

create barnchmatklad/rust-analyzer

branch : cfgifhack

created branch time in 4 hours

PR opened rust-analyzer/rust-analyzer

Add a hacky remidy for #6038

bors r+ 🤖

+28 -0

0 comment

2 changed files

pr created time in 4 hours

push eventrust-analyzer/metrics

Bot

commit sha 1483b38156543db378cc8d0778de91d58a3827da

📈

view details

push time in 5 hours

PR opened srijs/rust-crc32fast

Update cfg-if dependency

Would appreciate a release with this one.

+1 -1

0 comment

1 changed file

pr created time in 5 hours

create barnchmatklad/rust-crc32fast

branch : cfgif

created branch time in 5 hours

fork matklad/rust-crc32fast

Fast, SIMD-accelerated CRC32 (IEEE) checksum computation in Rust

https://crates.io/crates/crc32fast

fork in 5 hours

pull request commentrayon-rs/rayon

Update crossbeam dependencies (requires Rust 1.36)

Would appreciate a release :-)

mbrubeck

comment created time in 5 hours

pull request commentrust-analyzer/rust-analyzer

Generate diagnostics docs

bors r+

popzxc

comment created time in 5 hours

pull request commentrust-analyzer/rust-analyzer

Generate diagnostics docs

bosr r+

Thanks!

Regarding refactorings, for smaller ones like this, I prefer them to be in a separate commit at the start PR, but this is a weak preference

popzxc

comment created time in 5 hours

push eventmatklad/config

Aleksey Kladov

commit sha bdbfce748861a95cbda84a72bfb9e99c8a3a21c5

Update Rust template

view details

push time in 19 hours

push eventrust-analyzer/metrics

Bot

commit sha 95dc8de7600221a4599b7b79fc3203fa4f21a31c

📈

view details

push time in a day

Pull request review commentrust-analyzer/rust-analyzer

Generate diagnostics docs

 impl CodegenCmd {         generate_assists_tests(Mode::Overwrite)?;         generate_assists_docs(Mode::Overwrite)?;         generate_feature_docs(Mode::Overwrite)?;+        generate_diagnostic_docs(Mode::Overwrite)?;

Ah, we also need logic in release.rs to copy the file over.

popzxc

comment created time in a day

PullRequestReviewEvent

Pull request review commentrust-analyzer/rust-analyzer

Generate diagnostics docs

+//! Generates `assists.md` documentation.++use std::{fmt, fs, path::PathBuf};++use crate::{+    codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},+    project_root, rust_files, Result,+};++pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> {+    let features = Diagnostic::collect()?;+    let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");+    let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());+    let dst = project_root().join("docs/user/generated_diagnostic.adoc");+    codegen::update(&dst, &contents, mode)?;+    Ok(())+}++#[derive(Debug)]+struct Diagnostic {+    id: String,+    location: Location,+    doc: String,+}++impl Diagnostic {+    fn collect() -> Result<Vec<Diagnostic>> {+        let mut res = Vec::new();+        for path in rust_files(&project_root()) {+            collect_file(&mut res, path)?;+        }+        res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id));+        return Ok(res);++        fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> Result<()> {+            let text = fs::read_to_string(&path)?;
            let text = xshell::read_file(path)?;

that'll get a better error message

popzxc

comment created time in a day

Pull request review commentrust-analyzer/rust-analyzer

Generate diagnostics docs

 impl CodegenCmd {         generate_assists_tests(Mode::Overwrite)?;         generate_assists_docs(Mode::Overwrite)?;         generate_feature_docs(Mode::Overwrite)?;+        generate_diagnostic_docs(Mode::Overwrite)?;

Let's add this to smoke_test_docs_generation as well

popzxc

comment created time in a day

Pull request review commentrust-analyzer/rust-analyzer

Generate diagnostics docs

+//! Generates `assists.md` documentation.++use std::{fmt, fs, path::PathBuf};++use crate::{+    codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},+    project_root, rust_files, Result,+};++pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> {+    let features = Diagnostic::collect()?;

Copy-paste detected :-)

This is fine for such code, though pulling common "traverse the files and colllect magic comments" might be pulled into some helper function somewhere.

popzxc

comment created time in a day

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentrust-analyzer/rust-analyzer

Don't replace entire module and file nodes when inserting imports

Would returning SyntaxRewriter work here? See AssistBuilder::rewrite. As usual, this is "how to compose tree edits?" open probelm.

Veykril

comment created time in a day

PR opened rust-analyzer/rust-analyzer

Fix deprecation warning

bors r+ 🤖

+3 -3

0 comment

1 changed file

pr created time in a day

create barnchmatklad/rust-analyzer

branch : env

created branch time in a day

push eventrust-analyzer/rust-analyzer.github.io

Aleksey Kladov

commit sha 529d392432d9ce4b28b81756c4afff79115aaa7f

missed that one

view details

push time in a day

push eventrust-analyzer/metrics

Bot

commit sha 08c23aaab3e082ab29de2f3901373194264ad8ac

📈

view details

push time in a day

create barnchmatklad/rust-analyzer

branch : tag

created branch time in a day

PR opened rust-analyzer/rust-analyzer

Tag release branch rather than master

bors r+ 🤖

+1 -0

0 comment

1 changed file

pr created time in a day

push eventrust-analyzer/metrics

Bot

commit sha 20e8d8ed5112c6292d7a35888602f39884019013

📈

view details

push time in a day

push eventrust-analyzer/rust-analyzer.github.io

frazar

commit sha 6a4fb63f0683c40be7b480273ef321266ad01477

Fix typo

view details

Aleksey Kladov

commit sha 3a2533fce40bd65bf1214fb06215a8d06550455f

Merge pull request #75 from frazar/patch-1 Fix typo

view details

push time in a day

PR merged rust-analyzer/rust-analyzer.github.io

Fix typo

By the way, thank you for your work.

+1 -1

1 comment

1 changed file

frazar

pr closed time in a day

pull request commentrust-analyzer/rust-analyzer.github.io

Fix typo

bors r+

Thanks!

frazar

comment created time in a day

pull request commentrust-analyzer/rust-analyzer

Check cargoExtraArgs for undefined before using

bors r+

Thanks!

feileacan

comment created time in a day

Pull request review commentDataDog/scipio

Buffered random io

+// Unless explicitly stated otherwise all files in this repository are licensed under the+// MIT/Apache-2.0 License, at your convenience+//+// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2020 Datadog, Inc.+//++use crate::io::scipio_file::ScipioFile;+use crate::parking::Reactor;+use std::io;+use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};+use std::path::Path;++/// Constructs a file that is backed by the operating system page cache+#[derive(Debug)]+pub struct BufferedFile {+    file: ScipioFile,+}++impl AsRawFd for BufferedFile {+    fn as_raw_fd(&self) -> RawFd {+        self.file.as_raw_fd()+    }+}++impl FromRawFd for BufferedFile {+    unsafe fn from_raw_fd(fd: RawFd) -> Self {+        BufferedFile {+            file: ScipioFile::from_raw_fd(fd),+        }+    }+}++impl BufferedFile {+    /// Returns true if the BufferedFile represent the same file on the underlying device.+    ///+    /// Files are considered to be the same if they live in the same file system and+    /// have the same Linux inode. Note that based on this rule a symlink is *not*+    /// considered to be the same file.+    ///+    /// Files will be considered to be the same if:+    /// * A file is opened multiple times (different file descriptors, but same file!)+    /// * they are hard links.+    ///+    /// # Examples+    ///+    /// ```no_run+    /// use scipio::LocalExecutor;+    /// use scipio::io::BufferedFile;+    /// use std::os::unix::io::AsRawFd;+    ///+    /// let ex = LocalExecutor::make_default();+    /// ex.run(async {+    ///     let mut wfile = BufferedFile::create("myfile.txt").await.unwrap();+    ///     let mut rfile = BufferedFile::open("myfile.txt").await.unwrap();+    ///     // Different objects (OS file descriptors), so they will be different...+    ///     assert_ne!(wfile.as_raw_fd(), rfile.as_raw_fd());+    ///     // However they represent the same object.+    ///     assert!(wfile.is_same(&rfile));+    ///     wfile.close().await;+    ///     rfile.close().await;+    /// });+    /// ```+    pub fn is_same(&self, other: &BufferedFile) -> bool {+        self.file.is_same(&other.file)+    }++    /// Similar to [`create`] in the standard library, but returns a BufferedFile+    ///+    /// [`create`]: https://doc.rust-lang.org/std/fs/struct.File.html#method.create+    pub async fn create<P: AsRef<Path>>(path: P) -> io::Result<BufferedFile> {+        let flags = libc::O_CLOEXEC | libc::O_CREAT | libc::O_TRUNC | libc::O_WRONLY;+        Ok(BufferedFile {+            file: enhanced_try!(+                ScipioFile::open_at(-1 as _, path.as_ref(), flags, 0o644).await,+                "Creating",+                Some(path.as_ref()),+                None+            )?,+        })+    }++    /// Similar to [`open`] in the standard library, but returns a BufferedFile+    ///+    /// [`open`]: https://doc.rust-lang.org/std/fs/struct.File.html#method.open+    pub async fn open<P: AsRef<Path>>(path: P) -> io::Result<BufferedFile> {+        let flags = libc::O_CLOEXEC | libc::O_RDONLY;+        Ok(BufferedFile {+            file: enhanced_try!(+                ScipioFile::open_at(-1 as _, path.as_ref(), flags, 0o644).await,+                "Reading",+                Some(path.as_ref()),+                None+            )?,+        })+    }++    /// Write the data in the buffer `buf` to this BufferedFile at the specified position+    pub async fn write_at(&self, buf: &[u8], pos: u64) -> io::Result<usize> {+        let source = Reactor::get().write_buffered(self.as_raw_fd(), buf, pos);+        enhanced_try!(source.collect_rw().await, "Writing", self.file)+    }++    /// Reads data at the specified position into the user-provided buffer `buf`.+    ///+    /// Note that this differs from [`DmaFile`]'s read APIs: that reflects the+    /// fact that buffered reads need no specific alignment and io_uring will not+    /// be able to use its own pre-allocated buffers for it anyway.+    ///+    /// [`DmaFile`]: struct.DmaFile.html+    pub async fn read_at(&self, buf: &mut [u8], pos: u64) -> io::Result<usize> {+        let source = Reactor::get().read_buffered(self.as_raw_fd(), buf, pos);+        enhanced_try!(source.collect_rw().await, "Reading", self.file)+    }

But you are probably right. In which case it would probably better to have an API more similar to the DmaFile, where we allocate our own buffers. They would just be simple buffers instead of the DmaBuffer with their alignment guarantees.

Yeah, agree. I think the simplest possible fix here is to just use the following API

pub async fn read_at(&self, pos: u64, len: usize) -> io::Result<Vec<u8>> {

Long term, we should replace Vec<u8> with some dedicated type, which represents a buffer from a buffer pool owned by scipio.

glommer

comment created time in a day

PullRequestReviewEvent

Pull request review commentsteveklabnik/semver-parser

Improve compile times and number of dependencies by replacing proc-macro with codegen

+//! `pest_derive` crate has large dependency tree, and, as a build dependency,+//! it imposes these deps onto our consumers.+//!+//! To avoid that, let's just dump generated code to string into this+//! repository, and add a test that checks that the code is fresh.+use std::{+    fs,+    io::Write,+    process::{Command, Stdio},+    time::Instant,+};++const PREAMBLE: &str = "\+//! This is @generated code, do not edit by hand.+//! See `semver.pest` and `genpest.rs`.+#![allow(unused_attributes)]+#![rustfmt::skip]+use super::SemverParser;+";++#[test]+fn generated_code_is_fresh() {+    let t = Instant::now();++    let token_stream = {+        let grammar = include_str!("../src/semver.pest");+        let input = format!(+            r###"+#[derive(Parser)]+#[grammar_inline = r#"{}"#]+struct SemverParser;+"###,+            grammar+        )+        .parse::<proc_macro2::TokenStream>()+        .unwrap();++        let ts = pest_generator::derive_parser(input.into(), true);+        eprintln!("Generated code in {:02?}", t.elapsed());+        ts+    };++    let current = {+        let current = fs::read("./src/generated.rs").unwrap_or_default();+        String::from_utf8(current).unwrap()+    };++    let is_up_to_date = {+        let current = normalize(&current[PREAMBLE.len()..]);+        let generated = normalize(&token_stream.to_string());+        current == generated+    };++    // Rustfmt takes ages on this input, so fast-path skip it for unchanged+    // code.+    if is_up_to_date {+        return;+    }++    let code = {+        eprintln!("Reformatting (this will take couple of minutes)");+        let t = Instant::now();+        let code = reformat(&token_stream.to_string());+        let code = format!("{}\n{}", PREAMBLE, code);+        eprintln!("Reformatted in {:02?}", t.elapsed());+        code+    };++    fs::write("./src/generated.rs", code).unwrap();+    panic!("Generated code in the repository is outdated, updating...");

Updated the commit message!

matklad

comment created time in a day

PullRequestReviewEvent

push eventmatklad/semver-parser

Aleksey Kladov

commit sha fdb9eed24043f7ec43c1ff504d61fabbc0cdc7bd

Replace pest_derive with code generation The goal here is to move build-dependencies to dev-dependencies. This is important because build-dependencies are imposed onto our users. Now, when running `cargo test` in this repository, we would just write out the code that would have been generated by a `derive` into the `generated.rs` file. That fill will be committed to the git repo. That way: * We have a test that generated file is always up-to-date, and a way to automatically upgrade it once we change the grammar. * Our users need only to compile the generated file, they won't be compiling pest tooling required to generate the file in the first place! In case you are wondering how many build deps are there... ``` │ ├── semver v0.11.0 │ │ ├── semver-parser v0.10.0 │ │ │ ├── pest v2.1.3 │ │ │ │ └── ucd-trie v0.1.3 │ │ │ └── pest_derive v2.1.0 │ │ │ ├── pest v2.1.3 (*) │ │ │ └── pest_generator v2.1.3 │ │ │ ├── pest v2.1.3 (*) │ │ │ ├── pest_meta v2.1.3 │ │ │ │ ├── maplit v1.0.2 │ │ │ │ └── pest v2.1.3 (*) │ │ │ │ [build-dependencies] │ │ │ │ └── sha-1 v0.8.2 │ │ │ │ ├── block-buffer v0.7.3 │ │ │ │ │ ├── block-padding v0.1.5 │ │ │ │ │ │ └── byte-tools v0.3.1 │ │ │ │ │ ├── byte-tools v0.3.1 │ │ │ │ │ ├── byteorder v1.3.4 │ │ │ │ │ └── generic-array v0.12.3 │ │ │ │ │ └── typenum v1.12.0 │ │ │ │ ├── digest v0.8.1 │ │ │ │ │ └── generic-array v0.12.3 (*) │ │ │ │ ├── fake-simd v0.1.2 │ │ │ │ └── opaque-debug v0.2.3 │ │ │ ├── proc-macro2 v1.0.24 (*) │ │ │ ├── quote v1.0.7 (*) │ │ │ └── syn v1.0.45 (*) │ │ └── serde v1.0.117 (*) ```

view details

Aleksey Kladov

commit sha 9e01cd3a0990ba3057d5a5cd9f70eeb01209fb93

Add generated code

view details

push time in a day

Pull request review commentsteveklabnik/semver-parser

Improve compile times and number of dependencies by replacing proc-macro with codegen

+//! `pest_derive` crate has large dependency tree, and, as a build dependency,+//! it imposes these deps onto our consumers.+//!+//! To avoid that, let's just dump generated code to string into this+//! repository, and add a test that checks that the code is fresh.+use std::{+    fs,+    io::Write,+    process::{Command, Stdio},+    time::Instant,+};++const PREAMBLE: &str = "\+//! This is @generated code, do not edit by hand.+//! See `semver.pest` and `genpest.rs`.+#![allow(unused_attributes)]+#![rustfmt::skip]+use super::SemverParser;+";++#[test]+fn generated_code_is_fresh() {+    let t = Instant::now();++    let token_stream = {+        let grammar = include_str!("../src/semver.pest");+        let input = format!(+            r###"+#[derive(Parser)]+#[grammar_inline = r#"{}"#]+struct SemverParser;+"###,+            grammar+        )+        .parse::<proc_macro2::TokenStream>()+        .unwrap();++        let ts = pest_generator::derive_parser(input.into(), true);+        eprintln!("Generated code in {:02?}", t.elapsed());+        ts+    };++    let current = {+        let current = fs::read("./src/generated.rs").unwrap_or_default();+        String::from_utf8(current).unwrap()+    };++    let is_up_to_date = {+        let current = normalize(&current[PREAMBLE.len()..]);+        let generated = normalize(&token_stream.to_string());+        current == generated+    };++    // Rustfmt takes ages on this input, so fast-path skip it for unchanged+    // code.+    if is_up_to_date {+        return;+    }++    let code = {+        eprintln!("Reformatting (this will take couple of minutes)");+        let t = Instant::now();+        let code = reformat(&token_stream.to_string());+        let code = format!("{}\n{}", PREAMBLE, code);+        eprintln!("Reformatted in {:02?}", t.elapsed());+        code+    };++    fs::write("./src/generated.rs", code).unwrap();+    panic!("Generated code in the repository is outdated, updating...");

Ah, yeah sorry, this part definitelly should have gone into the commit message or PR description

matklad

comment created time in a day

PullRequestReviewEvent

issue commentsteveklabnik/semver-parser

Consider reducing number of dependencies

Yeah, I'll submit cargo metadata patch to revert then. I kind of think that either #50 or yanking semver 0.11might be a good idea.

Sorry for a little to direct tone here -- I was just to unpleasantly surprised by the update to rust-analyzer's lockfile due to what seemed to be an uninteresting dependency upgrade.

matklad

comment created time in a day

pull request commentsteveklabnik/semver-parser

Improve compile times and number of dependencies by replacing proc-macro with codegen

Note that the only bit in need of maintanence is https://github.com/steveklabnik/semver-parser/pull/50/files#diff-445579b80b445f4d46420690a5f77f0f824bfa38dbf51cdaa0429e3146e71aaa, which is basically glue code which shoves strings around.

Other than that, just running cargo test would automatically update generated code from the grammar.

If the short term is to rewrite the parser such that it doesn't have deps, then I am indifferent in this PR. If semverparser 0.10 is to live in crates.io for significant amount of time, I would think its the right call to put some more work into semverparser to didn't add dozen of dependenceis to its users.

matklad

comment created time in a day

pull request commentoli-obk/cargo_metadata

Update semver to v0.11.0

Note that this inflates build-deps of cargo-metadata to unreasonable degree. See

  • https://github.com/steveklabnik/semver-parser/issues/49
  • https://github.com/steveklabnik/semver-parser/pull/50

for upstream discussion.

koushiro

comment created time in a day

issue commentsteveklabnik/semver-parser

Consider reducing number of dependencies

Note that this issue currently blocks updating cargo-metada in rust-analyzer. I have a feeling that rewrite might not be finished too soon, so, in the meantime, merging this and releasing 0.11.1 would help.

Alternatively, I guess I can ask cargo-metadata to revert upgrade to 0.11.

matklad

comment created time in a day

Pull request review commentDataDog/scipio

Buffered random io

+// Unless explicitly stated otherwise all files in this repository are licensed under the+// MIT/Apache-2.0 License, at your convenience+//+// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2020 Datadog, Inc.+//++use crate::io::scipio_file::ScipioFile;+use crate::parking::Reactor;+use std::io;+use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};+use std::path::Path;++/// Constructs a file that is backed by the operating system page cache+#[derive(Debug)]+pub struct BufferedFile {+    file: ScipioFile,+}++impl AsRawFd for BufferedFile {+    fn as_raw_fd(&self) -> RawFd {+        self.file.as_raw_fd()+    }+}++impl FromRawFd for BufferedFile {+    unsafe fn from_raw_fd(fd: RawFd) -> Self {+        BufferedFile {+            file: ScipioFile::from_raw_fd(fd),+        }+    }+}++impl BufferedFile {+    /// Returns true if the BufferedFile represent the same file on the underlying device.+    ///+    /// Files are considered to be the same if they live in the same file system and+    /// have the same Linux inode. Note that based on this rule a symlink is *not*+    /// considered to be the same file.+    ///+    /// Files will be considered to be the same if:+    /// * A file is opened multiple times (different file descriptors, but same file!)+    /// * they are hard links.+    ///+    /// # Examples+    ///+    /// ```no_run+    /// use scipio::LocalExecutor;+    /// use scipio::io::BufferedFile;+    /// use std::os::unix::io::AsRawFd;+    ///+    /// let ex = LocalExecutor::make_default();+    /// ex.run(async {+    ///     let mut wfile = BufferedFile::create("myfile.txt").await.unwrap();+    ///     let mut rfile = BufferedFile::open("myfile.txt").await.unwrap();+    ///     // Different objects (OS file descriptors), so they will be different...+    ///     assert_ne!(wfile.as_raw_fd(), rfile.as_raw_fd());+    ///     // However they represent the same object.+    ///     assert!(wfile.is_same(&rfile));+    ///     wfile.close().await;+    ///     rfile.close().await;+    /// });+    /// ```+    pub fn is_same(&self, other: &BufferedFile) -> bool {+        self.file.is_same(&other.file)+    }++    /// Similar to [`create`] in the standard library, but returns a BufferedFile+    ///+    /// [`create`]: https://doc.rust-lang.org/std/fs/struct.File.html#method.create+    pub async fn create<P: AsRef<Path>>(path: P) -> io::Result<BufferedFile> {+        let flags = libc::O_CLOEXEC | libc::O_CREAT | libc::O_TRUNC | libc::O_WRONLY;+        Ok(BufferedFile {+            file: enhanced_try!(+                ScipioFile::open_at(-1 as _, path.as_ref(), flags, 0o644).await,+                "Creating",+                Some(path.as_ref()),+                None+            )?,+        })+    }++    /// Similar to [`open`] in the standard library, but returns a BufferedFile+    ///+    /// [`open`]: https://doc.rust-lang.org/std/fs/struct.File.html#method.open+    pub async fn open<P: AsRef<Path>>(path: P) -> io::Result<BufferedFile> {+        let flags = libc::O_CLOEXEC | libc::O_RDONLY;+        Ok(BufferedFile {+            file: enhanced_try!(+                ScipioFile::open_at(-1 as _, path.as_ref(), flags, 0o644).await,+                "Reading",+                Some(path.as_ref()),+                None+            )?,+        })+    }++    /// Write the data in the buffer `buf` to this BufferedFile at the specified position+    pub async fn write_at(&self, buf: &[u8], pos: u64) -> io::Result<usize> {+        let source = Reactor::get().write_buffered(self.as_raw_fd(), buf, pos);+        enhanced_try!(source.collect_rw().await, "Writing", self.file)+    }++    /// Reads data at the specified position into the user-provided buffer `buf`.+    ///+    /// Note that this differs from [`DmaFile`]'s read APIs: that reflects the+    /// fact that buffered reads need no specific alignment and io_uring will not+    /// be able to use its own pre-allocated buffers for it anyway.+    ///+    /// [`DmaFile`]: struct.DmaFile.html+    pub async fn read_at(&self, buf: &mut [u8], pos: u64) -> io::Result<usize> {+        let source = Reactor::get().read_buffered(self.as_raw_fd(), buf, pos);+        enhanced_try!(source.collect_rw().await, "Reading", self.file)+    }

Hm....

I think this API is fundamentally unsound. If the user cancells this read_at operation (by dropping the future), wouldn't consider buf mutably borrowed anymore, but the kernel would happily write into it, until we await for cancellation. And we can't await for cancellation in Drop because drop is sync, and because that would be unsound anyway due to mem::forget or rc cycles.

See https://without.boats/blog/io-uring/ and https://without.boats/blog/ringbahn/ for some discussion of this problem.

I think the fix would be to incur a copy -- we should use our owned DMA buffer internally, and copy the data to a user-provided buf when we are done.

(note -- this is cursory glance at the code, maybe I am mistaken here)

glommer

comment created time in a day

PullRequestReviewEvent

issue commentrust-analyzer/rust-analyzer

Make indentation (spaces vs tabs, tab width) configurable

Can I just make the 4 configurable here and here and add some kind of flag to tell it to use tabs instead?

Probably not, editing code should be agnostic about indentation configuration. I think the proper way to fix this is to remove manual indentation entirely in favor of generic indenter: #4182

0x7CFE

comment created time in a day

push eventrust-analyzer/metrics

Bot

commit sha 268071f231b2a15f6b6f66f8ef12d4d8d03d67d7

📈

view details

push time in a day

push eventrust-analyzer/metrics

Bot

commit sha b0a994229d5188df139e8b5e8969dd35906a0f9c

📈

view details

push time in a day

push eventrust-analyzer/rust-analyzer.github.io

Aleksey Kladov

commit sha b89fd86cf35a29a4fc4aefd85193687edaff6dcd

fix link

view details

push time in a day

PR opened rust-analyzer/rust-analyzer

Document logging of project model

bors r+ 🤖

+1 -0

0 comment

1 changed file

pr created time in a day

create barnchmatklad/rust-analyzer

branch : log

created branch time in a day

push eventmatklad/semver-parser

Aleksey Kladov

commit sha 0a52efb31a0eab3d1edf8e269f5ef17856a4dfe8

Replace pest_derive with code generation The goal here is to move build-dependencies to dev-dependencies. This is important because build-dependencies are imposed onto our users. In case you are wondering how many build deps are there... ``` │ ├── semver v0.11.0 │ │ ├── semver-parser v0.10.0 │ │ │ ├── pest v2.1.3 │ │ │ │ └── ucd-trie v0.1.3 │ │ │ └── pest_derive v2.1.0 │ │ │ ├── pest v2.1.3 (*) │ │ │ └── pest_generator v2.1.3 │ │ │ ├── pest v2.1.3 (*) │ │ │ ├── pest_meta v2.1.3 │ │ │ │ ├── maplit v1.0.2 │ │ │ │ └── pest v2.1.3 (*) │ │ │ │ [build-dependencies] │ │ │ │ └── sha-1 v0.8.2 │ │ │ │ ├── block-buffer v0.7.3 │ │ │ │ │ ├── block-padding v0.1.5 │ │ │ │ │ │ └── byte-tools v0.3.1 │ │ │ │ │ ├── byte-tools v0.3.1 │ │ │ │ │ ├── byteorder v1.3.4 │ │ │ │ │ └── generic-array v0.12.3 │ │ │ │ │ └── typenum v1.12.0 │ │ │ │ ├── digest v0.8.1 │ │ │ │ │ └── generic-array v0.12.3 (*) │ │ │ │ ├── fake-simd v0.1.2 │ │ │ │ └── opaque-debug v0.2.3 │ │ │ ├── proc-macro2 v1.0.24 (*) │ │ │ ├── quote v1.0.7 (*) │ │ │ └── syn v1.0.45 (*) │ │ └── serde v1.0.117 (*) ```

view details

Aleksey Kladov

commit sha 64ebeb1841b94fb8a282ffb8471569a910dc867a

Add generated code

view details

push time in a day

create barnchmatklad/rust-analyzer

branch : m

created branch time in a day

PR opened rust-analyzer/rust-analyzer

Minor, rename feature

bors r+ 🤖

+1 -1

0 comment

1 changed file

pr created time in a day

push eventrust-analyzer/rust-analyzer.github.io

Aleksey Kladov

commit sha 5260672395eff158c1d16bd56fffcf767463551c

Link manual

view details

push time in a day

pull request commentrust-analyzer/rust-analyzer

Textmate grammar: prevent unwanted interpolation scopes

Hm, I think I am still seeing this in a more complex case here:

image

https://github.com/steveklabnik/semver-parser/blob/0602220b388198c6e99b328751af7c660de74636/tests/genpest.rs

dustypomerleau

comment created time in a day

push eventrust-analyzer/rust-analyzer.github.io

Aleksey Kladov

commit sha 39615b6e0be2778ecdce4cba1c8c2f980091189c

Changelog #47

view details

push time in a day

issue commentrust-analyzer/rust-analyzer.github.io

gifs

vis

matklad

comment created time in a day

push eventrust-analyzer/metrics

Bot

commit sha 9de4644145e74ba186d9975383537cfd8c810aba

📈

view details

push time in a day

issue commentrust-analyzer/rust-analyzer

Auto-import: invalid type: null, expected struct CodeActionParams

Yeah, we should switch to codeAction/resolve not sure if it'll square with our groups support though....

lnicola

comment created time in a day

PR opened rust-analyzer/rust-analyzer

Try to fix publishing

bors r+ 🤖

+1 -1

0 comment

1 changed file

pr created time in a day

create barnchmatklad/rust-analyzer

branch : stdx

created branch time in a day

issue commentDataDog/scipio

Consider adding a forum/chat?

Aleksey, if you don't mind, why would you prefer the two you singled out ?

There are three orthogonal categories of reasons why I like the two:

Overall Brokenness

  • when I used gitter couple of years ago, it was horribly broken

  • Discord is slowish, logs me out if I hard-close the browser (and I hard-close browsers all the time) and (no, this is not a joke), if you out-out of email notifications, there's not way to enable them back.

  • Slack is oke-ish, but typing a message into the message box laggs horribly

  • Zulip is in "just works" category. The mobile apps are pretty bad though, but I don't use them.

  • Discourse is a beautifully engineered piece of software which works flawlessly and proves that you can build non-broken things with JS. It's one of the things which make me keep faith in the whole software engineering field :-)

Conversation Model

  • Discord and Zulip are chat/room IRC sync mode. I don't really enjoy it, because I like to type longer messages, timezone difference between Europe, America and Aisia make sync communication awkward.

  • Slack is mostly sync, though side-threads are nice.

  • Discourse is basically a mailing list, but with a modern UX (and you can literary use it as a mail-list, I've herd that it's email integration is seamless). It is extremely good for thorough, long-term value async discussion. It works less good for ephemeral sync discussion.

  • Zulip is right in the middle. It has somewhat unusual threading model, which takes some time to get used to, but does fulfill both sync and async modes. I think it is just as good as Discord or Slack for sync discussion, and slightly worse than Discourse for async discussion.

Familiarity

I use three instances of Zulip (Ferrous Systems, Rust lang, Salsa) and a bunch of Discourses (urlo, irlo, nixos, julia, borsng, trio).

I'd rate Slack as better then gitter and Discord, but worse than Zulip and Discourse.

matklad

comment created time in a day

push eventrust-analyzer/rust-analyzer

Zac Pullar-Strecker

commit sha bfda0d25834250a3adbcd0d26953a1cdc6662e7f

WIP: Command to open docs under cursor

view details

Zac Pullar-Strecker

commit sha a06d736b77770e4c1e738086c81b4fd60fcfcb23

Add support for struct & trait methods

view details

Zac Pullar-Strecker

commit sha 8c32bdea3662f4c65810e2d92569b0cb4e3872d9

Rename ide::link_rewrite -> ide::doc_links & tidy imports

view details

Zac Pullar-Strecker

commit sha a14194b428efdb09cc45f9862ec34bef0038cd35

Changes from review

view details

Zac Pullar-Strecker

commit sha 974518fde7975b839ed4ccd4c5ce1d48cd6db3c7

Code reorganisation and field support

view details

Zac Pullar-Strecker

commit sha 62b76e7004bc215a375e41bd204b2eab5acdf9c2

Document the protocol extension

view details

Zac Pullar-Strecker

commit sha c648884397bfdb779c447fa31964dc1fce94bd95

Differentiate method/tymethod by determining 'defaultness' Currently a method only has defaultness if it is a provided trait method, but this will change when specialisation is available and may need to become a concept known to hir. I opted to go for a 'fewest changes' approach given specialisation is still under development.

view details

Zac Pullar-Strecker

commit sha 26086faab2dab6baeaa050f73a7f64b83ead6807

Change Option::Some bug to a fixme note IMO this is too much work to be worth fixing at the moment.

view details

Zac Pullar-Strecker

commit sha f1decfc1106fb25f5d36dfbd789370e5d59f251c

Fix send->sent typo

view details

Zac Pullar-Strecker

commit sha ec75d8bd75b2b54138d6a46d0a800c92ac07cfe5

Update tests for new function field

view details

Zac Pullar-Strecker

commit sha 37a4d060a7709da42a67fe1631d5786f7e106884

Add tests

view details

Zac Pullar-Strecker

commit sha 6cae6b8f3cf284f9f386ea8ce7e347043fe9a040

Fix namespace detection & function test

view details

Zac Pullar-Strecker

commit sha f6759ba3bbc2c17771735327238c4ed936d5cdc9

Add ignored test to demonstrate ImportMap bug

view details

Zac Pullar-Strecker

commit sha e4a787fcbc865cd66921f8052a9cccad33a13b92

Remove outdated part of doc_links module docs

view details

Zac Pullar-Strecker

commit sha d2c68809ea3243ca68811e9b2e0f1592e2dc33fe

Changes from review

view details

Zac Pullar-Strecker

commit sha 8af1dd733760c51abadda8f2bd20139e11ebba04

Rebase fixes

view details

Zac Pullar-Strecker

commit sha 3bd4fe96dce17eb2bff380389b24ea325bf54803

Remove methodowner & fix formatting

view details

Benjamin Coenen

commit sha 3bfa3e8123dd2d652019ad270622025d10b87cc8

when generating new function, focus on return type instead of body Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>

view details

Kirill Bulatov

commit sha 9a72b7bccde54d901f3d89300777e0685790aefd

Add a test

view details

Kirill Bulatov

commit sha 2bb80a4f0350045503258518d354a4e63e4c68fd

Also replace the associated types with iter

view details

push time in a day

push eventrust-analyzer/metrics

Bot

commit sha 9e6e6af5f0fb5aec894730542539f4b29beaa4eb

📈

view details

push time in a day

delete branch matklad/lsp-server

delete branch : lessdeps

delete time in a day

pull request commentrust-analyzer/lsp-server

prune deps

bors r+

matklad

comment created time in a day

push eventmatklad/lsp-server

Aleksey Kladov

commit sha d29a74dcdb4a1d173c3d9f273e5b5e94cc754bbe

prune deps

view details

push time in a day

pull request commentrust-analyzer/rust-analyzer

:arrow_up: crates

bors r+

matklad

comment created time in a day

push eventmatklad/rust-analyzer

Aleksey Kladov

commit sha c4699819d072dc679f67827d317b8f3268034fec

:arrow_up: crates

view details

push time in a day

push eventmatklad/rust-analyzer

Zac Pullar-Strecker

commit sha 2023af53f09ed9466c6d7442d6830276eba19b45

Hover doc link rewriting

view details

Zac Pullar-Strecker

commit sha 68ee0337622f4025202687ccfac79c04d2046de8

URL doc outputs in hover

view details

Zac Pullar-Strecker

commit sha f497f6b4e048614094a9b38efe98cbb098013d18

Tidy up

view details

Zac Pullar-Strecker

commit sha 8f56e7c3b1220ed0b065e97a9061e59284ac1df1

Generate correct symbol filename for relative links

view details

Zac Pullar-Strecker

commit sha 5f52a516dedeab16ede8c26807c4ff79b3d308d3

Working intra-doc-links

view details

Zac Pullar-Strecker

commit sha 108b953254e46851130e427b41cd143eee07fd02

Remove local documentation link rewriting

view details

Zac Pullar-Strecker

commit sha 1d6f291335c58aac95c1124f55d7fb0834baff2a

Move resolver into impls, work on tests

view details

Zac Pullar-Strecker

commit sha 6bba4158cb8938af6e9b128c2c01b15415d502ad

Switch to pulldown-cmark, tidy imports

view details

Zac Pullar-Strecker

commit sha 73d5a31450e648698ad31531f21ac5659cc271ac

Update missed heavy test

view details

Zac Pullar-Strecker

commit sha f9893d370c4c3b015698169d27d2833742441560

Remove old comment, remove unecessary local

view details

Zac Pullar-Strecker

commit sha 10c50b140aa67f74a135e7a48ff6d954cc757cb8

Format & replace todos with 'fixme'

view details

Zac Pullar-Strecker

commit sha f98e311617f66654b7799a966fc16b272438ed00

Return a resolver for Definition::Local

view details

Zac Pullar-Strecker

commit sha 1833036daf6d2278df99f7b66aca24b2a66d8d2a

Fix doc attr parsing, fixes links from std/core/alloc

view details

Zac Pullar-Strecker

commit sha 48d858f54d5b5a1a2808c8621c5d570d12874b88

Don't strip affixes from path links

view details

Zac Pullar-Strecker

commit sha 3e22f80f443469f470561bceb2d84427ebab677f

Switch to Path::parse and add tests

view details

Zac Pullar-Strecker

commit sha dc32f756e0958368648ac151aab1bde40102a506

Format

view details

Zac Pullar-Strecker

commit sha d6f9e8806a26c5998a691974ba8e3655a2186766

Remove unintentional changes

view details

Zac Pullar-Strecker

commit sha 73ff610e41959e3e7c78a2b4b25b086883132956

Use From instead of Into in resolver method

view details

Zac Pullar-Strecker

commit sha f05d7b41a719d848844b054a16477b29d0f063c6

Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links Hasn't fixed tests yet.

view details

Zac Pullar-Strecker

commit sha 9522a06fd444c670202fd64c91d1ba62e332ff70

Update test calls to 'expect'

view details

push time in a day

PR opened rust-analyzer/rust-analyzer

:arrow_up: crates

bors r+ 🤖

+6 -6

0 comment

1 changed file

pr created time in a day

PR opened rust-analyzer/lsp-server

prune deps

bors r+ 🤖

+9 -12

0 comment

2 changed files

pr created time in a day

create barnchmatklad/lsp-server

branch : lessdeps

created branch time in a day

create barnchmatklad/lsp-server

branch : newci

created branch time in a day

PR opened rust-analyzer/lsp-server

bors

bors r+ 🤖

+134 -77

0 comment

9 changed files

pr created time in a day

push eventmatklad/xaction

Aleksey Kladov

commit sha 01305f03e886ecd0087181233fb12b90dab98458

Better errors

view details

push time in a day

issue commentbodil/vscode-file-browser

requires too many keystrokes for the standard use-case

Uhu, as a new user of the extension, I also find the the create action being default confusing:

image

I'd love to have an option to put the "Crete.." option to the bottom, or maybe remove it altogether in favor of something like "pressing ! or ctrl+enter creates the file"

grozan

comment created time in a day

push eventmatklad/xaction

Aleksey Kladov

commit sha 7daef78ffbae50578509cbd880272033ab154854

initial

view details

push time in a day

create barnchmatklad/xaction

branch : master

created branch time in a day

created repositorymatklad/xaction

created time in a day

push eventmatklad/xshell

Aleksey Kladov

commit sha e5b146615ecb60977dd11602aa08be0c38a162d6

publish v0.1.6

view details

push time in a day

push eventmatklad/xshell

Aleksey Kladov

commit sha a5e16e5d76921ce4cdd08b4ccc5223b46e649167

Better spans for compile errors

view details

push time in a day

issue closedmatklad/once_cell

how to get Mutex inner variable in CONFIG in once_cell

how to get reference Ext in CONFIG

use once_cell::sync::Lazy;
use std::sync::Mutex;
use std::collections::HashMap;
use std::fmt::Debug;

trait IExt: Debug + Send + Sync {
    fn get_key(&self);
}

#[derive(Debug)]
struct Ext;

impl IExt for Ext {
    fn get_key(&self) {}
}


static CONFIG: Lazy<Mutex<HashMap<String, Box<dyn IExt>>>> = Lazy::new(|| Mutex::new(Default::default()));

fn add() {
    CONFIG.lock().unwrap().insert("1".to_string(), Box::new(Ext));
}

fn get_key<'a>() -> &'a Box<dyn IExt> {
    CONFIG.lock().unwrap().get("1").unwrap()
}


fn main() {
    add();
    let key = get_key();
    println!("{:?}", key);
}

compile error:

error[E0515]: cannot return value referencing temporary value
  --> src/main.rs:27:5
   |
27 |     CONFIG.lock().unwrap().get("1").unwrap()
   |     ----------------------^^^^^^^^^^^^^^^^^^
   |     |
   |     returns a value referencing data owned by the current function
   |     temporary value created here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0515`.
error: could not compile `rustls-example`.

To learn more, run the command again with --verbose.

Process finished with exit code 101

closed time in a day

baoyachi

issue commentmatklad/once_cell

how to get Mutex inner variable in CONFIG in once_cell

That's not possible, because that would be unsfae.You are trying to return a pointer inside the value, protected by the mutex, but the pointer is not protected by a lock guard. That means that some other thread could sucesfully lock the mutext and mutate the protected data, invalidating the pointer. You need to either clone the data (using Arc<dyn IExt> would help) or use something like map from parking lot: https://docs.rs/lock_api/0.4.0/lock_api/struct.MutexGuard.html#method.map

baoyachi

comment created time in a day

issue openedDataDog/scipio

Consider adding a forum/chat?

If we intend to grow community around scipo, we would nee some community-space chat-like thing eventually. If we'll need it eventually, we might want to setup it sooner rather than later, because why not? Besides, I already have a couple of questions/thoughts that are ill-fitted for github issues.

Common choices in this area are:

  • Gitter (actix web https://github.com/actix/actix-web)
  • Discord (tokio https://github.com/tokio-rs/tokio)
  • Discourse (bors-ng https://github.com/bors-ng/bors-ng)
  • Zullip (druid https://github.com/linebender/druid)

I personally have a strong preference towards Zulip or Discourse

created time in a day

Pull request review commentDataDog/scipio

run linkchecker on the doc to validate hyperlinks

 jobs:       - image: circleci/rust:1.46.0     steps:       - checkout+      - run:+          name: Install linkchecker dependency+          command: pip3 install --user git+https://github.com/linkchecker/linkchecker.git

There's also https://github.com/deadlinks/cargo-deadlinks

HippoBaro

comment created time in a day

PullRequestReviewEvent

issue commentrust-analyzer/smol_str

1.46 requirement is problematic

Hm, but cant‘ you just pin SmolStr to earlier version? I am firmly in the „MSRV is not semver breaking“ camp and think that, if you need older compilers, it’s in you to curate the relevant Cargo.lock.

kornelski

comment created time in a day

issue commentrust-analyzer/smol_str

1.46 requirement is problematic

Heh, apparently SmolStr is seeing more usage than I‘d expect. It isn’t really intended to be a dependable 3rd party crate, and explicitly requires the latest stable Rust. It is not production ready enough to justify yanking,

I am not sure if I will be willing to „production-ready“-ify this crate: to do this, I’d need to remove the whitespace hack, but it is rather important for rust-analyzer. The API is also wrong, the crate should support mutation.

I am almost ready to say „just use https://docs.rs/smartstring/0.2.5/smartstring/ instead of smol_str“, but not quite. That crate is really advanced, and probably a bit too advanced (unsafe, a lot of knobs rather than a single type, MPL license).

kornelski

comment created time in a day

Pull request review commentDataDog/scipio

fix memory leak on executor creation.

 impl LocalExecutor {     fn init(&mut self) -> io::Result<()> {         let queues = self.queues.clone();         let index = 0;+        let queues_weak = Rc::downgrade(&queues);

The clone above seems superfluous

glommer

comment created time in 2 days

PullRequestReviewEvent

issue commentDataDog/scipio

executor::test::test_ping_pong_yield is flaky

It surely is, but almost every test needs to create an executor anyway, so we already have some common-to-all tests boilerplate, so I don't think it would be more annoying in practice than what we have today. Locking can be hidden in the already existing macros.

But, surely, making the tests more robust to threading would be a cleaner option :0)

On Sun, 18 Oct 2020 at 22:34, Glauber Costa notifications@github.com wrote:

Right, but that would require every test that we always write to take that lock, no ? I thought of that but sounded quite heavy-handed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DataDog/scipio/issues/120#issuecomment-711418549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANB3M4WHAHEHU3DDTIAYP3SLNGPBANCNFSM4SVIY4SQ .

matklad

comment created time in 2 days

issue commentDataDog/scipio

executor::test::test_ping_pong_yield is flaky

What we need is just a handful of executor tests to execute undisturbed and the rest can go wild.

we can lock a reader-write lock at the start of the test. undisturbable tests would w, and the rest would r.

On Sun, 18 Oct 2020 at 22:32, Glauber Costa notifications@github.com wrote:

It would be really nice to be able to say that some tests should run alone, btw. I found some crates to do serial testing, but that's not really what we need: they'd require marking pretty much all tests are serial. What we need is just a handful of executor tests to execute undisturbed and the rest can go wild.

But trying to make them more robust is a good exercise too =)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DataDog/scipio/issues/120#issuecomment-711418163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANB3MZ4FMPL2NV4UYT557LSLNGETANCNFSM4SVIY4SQ .

matklad

comment created time in 2 days

pull request commentDataDog/scipio

WIP: remove UnsafeCell from Source

If I understand correctly, you are just moving the interior mutability pattern to the fields that really need it, and as SourceMap will translate between id and the rc pointer and that can be made safe.

Indeed, this is just mechanical leveraging of interior mutability. Though, i use Cells somewhat more actively then RefCells, as they have a better API.

matklad

comment created time in 2 days

issue commentmatklad/xshell

Single quotes prevent interpolation

cmd!(“notify-send 'Hello from '{PWD}“)

Adjacent tokens are concated into a single arg. But I do agree that this is kinda silly. I think I need to bite the bullet and implement proper escapensequences and double quoted strings, so that your example just works.

ngirard

comment created time in 2 days

push eventmatklad/config

Aleksey Kladov

commit sha 635eed0d5a9306fa25b69c275d8881b18eba7818

.

view details

push time in 2 days

issue commentmatklad/xshell

Single quotes prevent interpolation

I wouldn't say that this is an explicitly designed behavior, but I think it is reasonable. The shell works that way, there's no interpolation in single quotes.

let pwd = env::var("PWD").unwrap();
cmd!("echo 'Hello from '{pwd}").run()?;

will do what you want

ngirard

comment created time in 2 days

more