ernie-research/MEnvData-SWE huggingface dataset:
Repository: dtolnay/async-trait (Rust)

Issue:
Unable to call `Self` in blanket implementation
I think this is a bug, sorry if it's not.

### Problem

When creating a blanket impl, e.g. `impl<T: A> B for T`, if you trying to call a `fn` on `Self` it doesn't work:

```rs
use async_trait::async_trait;

#[async_trait]
trait A {
    async fn a();
}

trait B {
    fn b();
}

#[async_trait]
impl<T: B> A for T {
    async fn a() {
        Self::b();
    }
}
```

```
error[E0276]: impl has stricter requirements than trait
  --> src/lib.rs:12:1
   |
5  |     async fn a();
   |     ------------- definition of `a` from trait
...
12 | #[async_trait]
   | ^^^^^^^^^^^^^^ impl has extra requirement `T: 'async_trait`
   |
   = note: this error originates in the attribute macro `async_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Same problem even if `B` has `#[async_trait]` (with or without `B::b()` being `async`).

### Expected

I feel like this should work because it works when not using `async`:

```rs
trait A {
    fn a();
}

trait B {
    fn b();
}

impl<T: B> A for T {
    fn a() {
        Self::b();
    }
}
```

### Workaround

I did figure out a workaround (halfway through writing this :sweat_smile:), which is to use `T` instead of `Self`, so I don't think this issue is high priority, but I figured I should still report it (and share the workaround).

```rs
use async_trait::async_trait;

#[async_trait]
trait A {
    async fn a();
}

trait B {
    fn b();
}

#[async_trait]
impl<T: B> A for T {
    async fn a() {
        T::b();
    }
}
```


Discussion:

Patch:
diff --git a/src/expand.rs b/src/expand.rs
index df02106..6546769 100644
--- a/src/expand.rs
+++ b/src/expand.rs
@@ -99,7 +99,7 @@ pub fn expand(input: &mut Item, is_local: bool) {
                     ImplItem::Fn(method) if method.sig.asyncness.is_some() => {
                         let sig = &mut method.sig;
                         let block = &mut method.block;
-                        let has_self = has_self_in_sig(sig) || has_self_in_block(block);
+                        let has_self = has_self_in_sig(sig);
                         transform_block(context, sig, block);
                         transform_sig(context, sig, has_self, false, is_local);
                         method.attrs.push(lint_suppress_with_body());


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 5d1c549..89c848b 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1683,3 +1683,23 @@ pub mod issue281 {
         }
     }
 }
+
+pub mod issue283 {
+    use async_trait::async_trait;
+
+    #[async_trait]
+    pub trait Trait {
+        async fn a();
+    }
+
+    pub trait Bound {
+        fn b();
+    }
+
+    #[async_trait]
+    impl<T: Bound> Trait for T {
+        async fn a() {
+            Self::b();
+        }
+    }
+}
Repository: dtolnay/async-trait (Rust)

Issue:
Failed to resolve `self` in path
Macro doesn't handle when `self` is used as path.
```rust
use async_trait::async_trait; // 0.1.48

fn bar() {}

#[async_trait]
trait Foo {
    async fn bar(&self) {
        self::bar()
    }
}
```
```rust
error[E0433]: failed to resolve: use of undeclared crate or module `__self`
 --> src/lib.rs:8:9
  |
8 |         self::bar()
  |         ^^^^ use of undeclared crate or module `__self`
```
[Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9567f3a7c893e1eb8da5256043246c9b)


Discussion:
Good catch -- I've published a fix in 0.1.49.



Patch:
diff --git a/src/receiver.rs b/src/receiver.rs
index 64ab65e..7f837f4 100644
--- a/src/receiver.rs
+++ b/src/receiver.rs
@@ -2,7 +2,7 @@ use proc_macro2::{Group, Span, TokenStream, TokenTree};
 use std::iter::FromIterator;
 use syn::visit_mut::{self, VisitMut};
 use syn::{
-    Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, PatPath, Receiver, Signature, Token,
+    Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, PatPath, Path, Receiver, Signature, Token,
     TypePath,
 };
 
@@ -139,6 +139,16 @@ impl VisitMut for ReplaceSelf {
         self.prepend_underscore_to_self(i);
     }
 
+    fn visit_path_mut(&mut self, p: &mut Path) {
+        if p.segments.len() == 1 {
+            // Replace `self`, but not `self::function`.
+            self.visit_ident_mut(&mut p.segments[0].ident);
+        }
+        for segment in &mut p.segments {
+            self.visit_path_arguments_mut(&mut segment.arguments);
+        }
+    }
+
     fn visit_item_mut(&mut self, i: &mut Item) {
         // Visit `macro_rules!` because locally defined macros can refer to
         // `self`. Otherwise, do not recurse into nested items.


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index af33b14..5af9f6d 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1321,3 +1321,17 @@ pub mod issue154 {
         }
     }
 }
+
+// https://github.com/dtolnay/async-trait/issues/158
+pub mod issue158 {
+    use async_trait::async_trait;
+
+    fn f() {}
+
+    #[async_trait]
+    pub trait Trait {
+        async fn f(&self) {
+            self::f()
+        }
+    }
+}
Repository: crate-ci/typos (Rust)

Issue:
False positive: add-ons -> add-owns
One false positive that I'm hitting fairly regularly is typos suggesting changing "add-ons" to "add-owns". This happens only for the plural form, no problems with the singular "add-on".

Would be nice if this could be fixed :)


Discussion:

Patch:
diff --git a/crates/typos-dict/assets/words.csv b/crates/typos-dict/assets/words.csv
index 9ea43d646..b8b725390 100644
--- a/crates/typos-dict/assets/words.csv
+++ b/crates/typos-dict/assets/words.csv
@@ -33765,7 +33765,6 @@ onmipotent,omnipotent
 onmiscient,omniscient
 onoly,only
 onot,note,not
-ons,owns
 onsalught,onslaught
 onself,oneself
 onservation,conservation,observation
diff --git a/crates/typos-dict/src/dict_codegen.rs b/crates/typos-dict/src/dict_codegen.rs
index 37b1815e6..7b3bbe969 100644
--- a/crates/typos-dict/src/dict_codegen.rs
+++ b/crates/typos-dict/src/dict_codegen.rs
@@ -66466,7 +66466,6 @@ pub static WORD_ON_CHILDREN: dictgen::DictTable<&'static [&'static str]> = dictg
         dictgen::InsensitiveStr::Ascii("miscient"),
         dictgen::InsensitiveStr::Ascii("oly"),
         dictgen::InsensitiveStr::Ascii("ot"),
-        dictgen::InsensitiveStr::Ascii("s"),
         dictgen::InsensitiveStr::Ascii("salught"),
         dictgen::InsensitiveStr::Ascii("self"),
         dictgen::InsensitiveStr::Ascii("servation"),
@@ -66511,7 +66510,6 @@ pub static WORD_ON_CHILDREN: dictgen::DictTable<&'static [&'static str]> = dictg
         &["omniscient"],
         &["only"],
         &["note", "not"],
-        &["owns"],
         &["onslaught"],
         &["oneself"],
         &["conservation", "observation"],


Test patch:
diff --git a/crates/typos-cli/tests/cmd/false-positives.in/README.md b/crates/typos-cli/tests/cmd/false-positives.in/README.md
new file mode 100644
index 000000000..58717231a
--- /dev/null
+++ b/crates/typos-cli/tests/cmd/false-positives.in/README.md
@@ -0,0 +1,7 @@
+add-ons should not be corrected to add-owns
+
+git glossary has both commitish and committish, so don't correct them
+
+HTTP_REFERER is a valid HTTP header field
+
+It should be reasonable to talk about `<thead>`
diff --git a/crates/typos-cli/tests/cmd/false-positives.in/sample.py b/crates/typos-cli/tests/cmd/false-positives.in/sample.py
new file mode 100644
index 000000000..dcf674dd5
--- /dev/null
+++ b/crates/typos-cli/tests/cmd/false-positives.in/sample.py
@@ -0,0 +1,1 @@
+from numpy.typing import NDArray  # should work
diff --git a/crates/typos-cli/tests/cmd/false-positives.in/sample.rs b/crates/typos-cli/tests/cmd/false-positives.in/sample.rs
new file mode 100644
index 000000000..de110f9e0
--- /dev/null
+++ b/crates/typos-cli/tests/cmd/false-positives.in/sample.rs
@@ -0,0 +1,3 @@
+use serde::ser;
+
+use flate2::*;
diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml
new file mode 100644
index 000000000..324f41d7f
--- /dev/null
+++ b/crates/typos-cli/tests/cmd/false-positives.toml
@@ -0,0 +1,4 @@
+bin.name = "typos"
+stdin = ""
+stdout = ""
+stderr = ""
Repository: toml-rs/toml-rs (Rust)

Issue:
Float parsing ignores everything after parsing decimal part
Example:

`println!("{:?}", "a = 0.0abcde".parse::<Value>());`

prints:

`Ok(Table({"a": Float(0.0)}))`


Discussion:

Patch:
diff --git a/src/de.rs b/src/de.rs
index 6b7c43b0..b23f03f8 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -1396,6 +1396,8 @@ impl<'a> Deserializer<'a> {
                 return Err(self.error(start, ErrorKind::NumberInvalid));
             }
             exponent = Some(a);
+        } else if !suffix.is_empty() {
+            return Err(self.error(start, ErrorKind::NumberInvalid));
         }
 
         let mut number = integral


Test patch:
diff --git a/test-suite/tests/invalid.rs b/test-suite/tests/invalid.rs
index 9f36e2c0..820c48ba 100644
--- a/test-suite/tests/invalid.rs
+++ b/test-suite/tests/invalid.rs
@@ -38,6 +38,8 @@ test!(empty_table,
       include_str!("invalid/empty-table.toml"));
 test!(float_no_leading_zero,
       include_str!("invalid/float-no-leading-zero.toml"));
+test!(float_no_suffix,
+      include_str!("invalid/float-no-suffix.toml"));
 test!(float_no_trailing_digits,
       include_str!("invalid/float-no-trailing-digits.toml"));
 test!(key_after_array,
diff --git a/test-suite/tests/invalid/float-no-suffix.toml b/test-suite/tests/invalid/float-no-suffix.toml
new file mode 100644
index 00000000..76106de7
--- /dev/null
+++ b/test-suite/tests/invalid/float-no-suffix.toml
@@ -0,0 +1,1 @@
+a = 1.2f
Repository: Aleph-Alpha/ts-rs (Rust)

Issue:
`rename_all = "camelCase"` fails if fields are already in camelCase
```rust
#[derive(Serialize, Deserialize, TS, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CamelCase {
    alreadyCamelCase: u32
}
```
serde_json would serialize this into 
```json
{"alreadyCamelCase":0}
```
but we generate
```ts
interface CamelCase { alreadycamelcase: number, }
```


Discussion:
This is due to a mistake I made in #184 [this line](https://github.com/Aleph-Alpha/ts-rs/blob/7402826ff25723096790e4fb65cefe61e961c9b5/macros/src/attr/mod.rs#L52) should just be `s.push(c)`

I will submit a PR to fix it ASAP



Patch:
diff --git a/macros/src/attr/mod.rs b/macros/src/attr/mod.rs
index b9575c10..6bb7b34f 100644
--- a/macros/src/attr/mod.rs
+++ b/macros/src/attr/mod.rs
@@ -49,7 +49,7 @@ impl Inflection {
                         s.push(c.to_ascii_uppercase());
                         capitalize = false;
                     } else {
-                        s.push(c.to_ascii_lowercase())
+                        s.push(c)
                     }
                 }
 


Test patch:
diff --git a/ts-rs/tests/struct_rename.rs b/ts-rs/tests/struct_rename.rs
index e242c5b2..aa7d78d9 100644
--- a/ts-rs/tests/struct_rename.rs
+++ b/ts-rs/tests/struct_rename.rs
@@ -18,12 +18,14 @@ fn rename_all() {
 fn rename_all_camel_case() {
     #[derive(TS)]
     #[ts(rename_all = "camelCase")]
+    #[allow(non_snake_case)]
     struct Rename {
         crc32c_hash: i32,
         b: i32,
+        alreadyCamelCase: i32,
     }
 
-    assert_eq!(Rename::inline(), "{ crc32cHash: number, b: number, }");
+    assert_eq!(Rename::inline(), "{ crc32cHash: number, b: number, alreadyCamelCase: number, }");
 }
 
 #[test]
Repository: dtolnay/async-trait (Rust)

Issue:
Use parentheses to disambiguate impl Trait
```rust
use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    async fn f(arg: &impl Trait);
}
```

currently fails with:

```console
error: ambiguous `+` in a type
 --> src/main.rs:5:22
  |
5 |     async fn f(arg: &impl Trait);
  |                      ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl 'async_trait + Trait)`
```


Discussion:

Patch:
diff --git a/src/lifetime.rs b/src/lifetime.rs
index d8e8d88..7ceda4f 100644
--- a/src/lifetime.rs
+++ b/src/lifetime.rs
@@ -1,7 +1,9 @@
-use proc_macro2::Span;
+use proc_macro2::{Span, TokenStream};
+use std::mem;
 use syn::visit_mut::{self, VisitMut};
 use syn::{
-    parse_quote_spanned, Expr, GenericArgument, Lifetime, Receiver, TypeImplTrait, TypeReference,
+    parse_quote_spanned, token, Expr, GenericArgument, Lifetime, Receiver, Type, TypeImplTrait,
+    TypeParen, TypeReference,
 };
 
 pub struct CollectLifetimes {
@@ -78,6 +80,17 @@ impl VisitMut for AddLifetimeToImplTrait {
         visit_mut::visit_type_impl_trait_mut(self, ty);
     }
 
+    fn visit_type_reference_mut(&mut self, ty: &mut TypeReference) {
+        if let Type::ImplTrait(_) = *ty.elem {
+            let elem = mem::replace(&mut *ty.elem, Type::Verbatim(TokenStream::new()));
+            *ty.elem = Type::Paren(TypeParen {
+                paren_token: token::Paren(ty.and_token.span),
+                elem: Box::new(elem),
+            });
+        }
+        visit_mut::visit_type_reference_mut(self, ty);
+    }
+
     fn visit_expr_mut(&mut self, _e: &mut Expr) {
         // Do not recurse into impl Traits inside of an array length expression.
         //


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 87897b1..6859639 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1439,3 +1439,13 @@ pub mod issue199 {
         assert_eq!(counter.get(), 1);
     }
 }
+
+// https://github.com/dtolnay/async-trait/issues/204
+pub mod issue204 {
+    use async_trait::async_trait;
+
+    #[async_trait]
+    pub trait Trait {
+        async fn f(arg: &impl Trait);
+    }
+}
Repository: ron-rs/ron (Rust)

Issue:
Parser doesn't handle whitespace ...
between `(` and `[` of a `newtype_struct` wrapping a `seq`:

```rust

#[derive(Debug, Deserialize)]
struct Newtype(Vec<String>);

fn main() {
    let serialized = stringify!(
        Newtype([
            "a",
            "b",
            "c",
        ])
    );
    println!("{}", serialized);
    let deserialized: Result<Newtype, _> = ron::de::from_str(serialized);
    println!("{:#?}", deserialized);


    let serialized = r#"
        Newtype([
            "a",
            "b",
            "c",
        ])
    "#;
    println!("{}", serialized);
    let deserialized: Result<Newtype, _> = ron::de::from_str(serialized);
    println!("{:#?}", deserialized);
}
```

```
Newtype ( [ "a" , "b" , "c" , ] )
Err(
    Parser(
        ExpectedArray,
        Position {
            col: 10,
            line: 1
        }
    )
)

        Newtype([
            "a",
            "b",
            "c",
        ])
    
Ok(
    Newtype(
        [
            "a",
            "b",
            "c"
        ]
    )
)
```

(This is what I actually came here to report when I got sidetracked by the linguist+ronn history dive 😆)


Discussion:

Patch:
diff --git a/src/de/mod.rs b/src/de/mod.rs
index 355851bb3..161ae5f18 100644
--- a/src/de/mod.rs
+++ b/src/de/mod.rs
@@ -313,6 +313,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
         self.bytes.skip_ws()?;
 
         if self.bytes.consume("(") {
+            self.bytes.skip_ws()?;
             let value = visitor.visit_newtype_struct(&mut *self)?;
             self.bytes.comma()?;
 


Test patch:
diff --git a/tests/big_struct.rs b/tests/big_struct.rs
index 2497bd63d..bd512194d 100644
--- a/tests/big_struct.rs
+++ b/tests/big_struct.rs
@@ -39,8 +39,12 @@ pub struct ImGuiStyleSave {
     pub anti_aliased_shapes: bool,
     pub curve_tessellation_tol: f32,
     pub colors: ImColorsSave,
+    pub new_type: NewType,
 }
 
+#[derive(Serialize, Deserialize)]
+pub struct NewType(i32);
+
 const CONFIG: &str = "(
     alpha: 1.0,
     window_padding: (x: 8, y: 8),
@@ -66,6 +70,7 @@ const CONFIG: &str = "(
     anti_aliased_shapes: true,
     curve_tessellation_tol: 1.25,
     colors: (text: 4),
+    new_type: NewType(     1  ),
 
     ignored_field: \"Totally ignored, not causing a panic. Hopefully.\",
 )";
Repository: marc2332/freya (Rust)

Issue:
enhancement: Support 3 chars hex colors
The main thread panics when a `hex` value containing three characters (e.g. ´#000´) is put as the color of a component. 

## Reproduction

```rust
use freya::prelude::*;

fn main() {
    launch(app);
}

fn app() -> Element {
    rsx! {
        rect {
            width: "100%",
            height: "100%",
            background: "#000",
        }
    }
}

```


Discussion:
It is not bug but a missing feature
https://github.com/marc2332/freya/blob/4af8278d51e8bde6229ab8569c4a1a49c873390d/crates/core/src/values/color.rs#L195
Ok, I can work on a PR for it :)
Would it be better if the hex value is not correct, the function would return a default value instead of crashing the main thread?
> Would it be better if the hex value is not correct, the function would return a default value instead of crashing the main thread?

The crash is on purpose so that the developer knows its wrong, using a default value would have made you believe it wasn't wrong.

The crash only happens in debug mode btw, in release it just does nothing
OK



Patch:
diff --git a/crates/core/src/values/color.rs b/crates/core/src/values/color.rs
index caa9f608d..c95725b96 100644
--- a/crates/core/src/values/color.rs
+++ b/crates/core/src/values/color.rs
@@ -193,7 +193,12 @@ fn parse_hsl(color: &str) -> Result<Color, ParseError> {
 }
 
 fn parse_hex_color(color: &str) -> Result<Color, ParseError> {
-    if color.len() == 7 {
+    if color.len() == 4 {
+        let r = u8::from_str_radix(&color[1..2].repeat(2), 16).map_err(|_| ParseError)?;
+        let g = u8::from_str_radix(&color[2..3].repeat(2), 16).map_err(|_| ParseError)?;
+        let b = u8::from_str_radix(&color[3..4].repeat(2), 16).map_err(|_| ParseError)?;
+        Ok(Color::from_rgb(r, g, b))
+    } else if color.len() == 7 {
         let r = u8::from_str_radix(&color[1..3], 16).map_err(|_| ParseError)?;
         let g = u8::from_str_radix(&color[3..5], 16).map_err(|_| ParseError)?;
         let b = u8::from_str_radix(&color[5..7], 16).map_err(|_| ParseError)?;


Test patch:
diff --git a/crates/core/tests/parse_color.rs b/crates/core/tests/parse_color.rs
index 0aae05453..ab30f2543 100644
--- a/crates/core/tests/parse_color.rs
+++ b/crates/core/tests/parse_color.rs
@@ -36,6 +36,12 @@ fn parse_hex_color() {
     assert_eq!(color, Ok(Color::from_rgb(255, 165, 0)));
 }
 
+#[test]
+fn parse_3_char_hex_color() {
+    let color = Color::parse("#F42");
+    assert_eq!(color, Ok(Color::from_rgb(255, 68, 34)));
+}
+
 #[test]
 fn invalid_colors() {
     let incorrect_name = Color::parse("wow(0, 0, 0)");
Repository: Aleph-Alpha/ts-rs (Rust)

Issue:
bug: Feature `"chrono-impl"` emits incorrect type for `chrono::TimeDelta`
**Describe the bug**
ts-rs incorrectly emits a `string` for `chrono::TimeDelta` when it should be `Array<number>` (or even better, `[number, number]` since serde_json creates a length 2 array of integers which you can verify in the implementation https://docs.rs/chrono/latest/src/chrono/time_delta.rs.html#669-673)

**To Reproduce**
main.rs:
```rs
use chrono::TimeDelta;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(TS, Serialize, Deserialize)]
#[ts(export)]
pub struct Video {
    pub duration: TimeDelta,
}

fn main() {
    println!(
        "{}",
        serde_json::to_string_pretty(&Video {
            duration: TimeDelta::from_std(std::time::Duration::from_secs(60)).unwrap(),
        })
        .unwrap(),
    );
}
```

cargo.toml (package section)
```toml
[dependencies]
serde_json = "1.0.141"

[dependencies.chrono]
version = "0.4.41"
features = ["serde"]

[dependencies.serde]
version = "1.0.219"
features = ["derive"]

[dependencies.ts-rs]
version = "11.0.1"
features = ["chrono-impl"]
```

1) Execute
```bash
cargo test export_bindings
```
2) Read `bindings/Video.ts`

(Current output of `bindings/Video.ts`)
```ts
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Video = { duration: string, };
```

**Expected behavior**
The emitted type should be `[number, number]` but it is `string` instead

**Screenshots**
N/A

**Version**
(See `cargo.toml` for all versions)



Discussion:

Patch:
diff --git a/ts-rs/src/chrono.rs b/ts-rs/src/chrono.rs
index 9e0d1087..a6212207 100644
--- a/ts-rs/src/chrono.rs
+++ b/ts-rs/src/chrono.rs
@@ -23,7 +23,8 @@ macro_rules! impl_dummy {
     )*};
 }
 
-impl_primitives!(NaiveDateTime, NaiveDate, NaiveTime, Month, Weekday, Duration => "string");
+impl_primitives!(NaiveDateTime, NaiveDate, NaiveTime, Month, Weekday => "string");
+impl_primitives!(Duration => "[number, number]");
 impl_dummy!(Utc, Local, FixedOffset);
 
 impl<T: TimeZone + 'static> TS for DateTime<T> {


Test patch:
diff --git a/ts-rs/tests/integration/chrono.rs b/ts-rs/tests/integration/chrono.rs
index 7ad3ce74..898fb03b 100644
--- a/ts-rs/tests/integration/chrono.rs
+++ b/ts-rs/tests/integration/chrono.rs
@@ -27,6 +27,6 @@ struct Chrono {
 fn chrono() {
     assert_eq!(
         Chrono::decl(),
-        "type Chrono = { date: [string, string, string, string], time: string, date_time: [string, string, string, string], duration: string, month: string, weekday: string, };"
-    )
+        "type Chrono = { date: [string, string, string, string], time: string, date_time: [string, string, string, string], duration: [number, number], month: string, weekday: string, };"
+    );
 }
Repository: jrmuizel/raqote (Rust)

Issue:
Panics when stroke width is std::f32::MIN
```rust
use raqote::*;

fn main() {
    let mut dt = DrawTarget::new(400, 400);

    let mut pb = PathBuilder::new();
    pb.move_to(200., 200.);
    pb.line_to(300., 300.);
    pb.line_to(200., 300.);

    let path = pb.finish();
    dt.stroke(
        &path,
        &Source::Solid(SolidSource::from_unpremultiplied_argb(0xFF, 0, 0x80, 0)),
        &StrokeStyle {
            width: std::f32::MIN, // <--
            ..StrokeStyle::default()
        },
        &DrawOptions::new(),
    );

    dt.write_png("out.png").unwrap();
}
```

```
thread 'main' panicked at 'attempt to subtract with overflow', src/rasterizer.rs:361:26
```

Somewhat related to #135


Discussion:

Patch:
diff --git a/src/stroke.rs b/src/stroke.rs
index 3c44d74..590aac6 100644
--- a/src/stroke.rs
+++ b/src/stroke.rs
@@ -275,8 +275,13 @@ fn join_line(
 }
 
 pub fn stroke_to_path(path: &Path, style: &StrokeStyle) -> Path {
-    let mut cur_pt = None;
     let mut stroked_path = PathBuilder::new();
+
+    if style.width <= 0. {
+        return stroked_path.finish();
+    }
+
+    let mut cur_pt = None;
     let mut last_normal = Vector::zero();
     let half_width = style.width / 2.;
     let mut start_point = None;


Test patch:
diff --git a/src/tests.rs b/src/tests.rs
index 6a196e6..8791cbf 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -274,6 +274,57 @@ mod tests {
         );
     }
 
+    #[test]
+    fn zero_width_stroke() {
+        let mut dt = DrawTarget::new(3, 3);
+        let mut pb = PathBuilder::new();
+        pb.move_to(2., 2.);
+        pb.line_to(200., 300.);
+        dt.stroke(
+            &pb.finish(),
+            &WHITE_SOURCE,
+            &StrokeStyle {
+                width: 0.,
+                ..Default::default()
+            },
+            &DrawOptions::new(),
+        );
+    }
+
+    #[test]
+    fn negative_width_stroke() {
+        let mut dt = DrawTarget::new(3, 3);
+        let mut pb = PathBuilder::new();
+        pb.move_to(2., 2.);
+        pb.line_to(200., 300.);
+        dt.stroke(
+            &pb.finish(),
+            &WHITE_SOURCE,
+            &StrokeStyle {
+                width: std::f32::MIN,
+                ..Default::default()
+            },
+            &DrawOptions::new(),
+        );
+    }
+
+    #[test]
+    fn tiny_negative_width_stroke() {
+        let mut dt = DrawTarget::new(3, 3);
+        let mut pb = PathBuilder::new();
+        pb.move_to(2., 2.);
+        pb.line_to(200., 300.);
+        dt.stroke(
+            &pb.finish(),
+            &WHITE_SOURCE,
+            &StrokeStyle {
+                width: -core::f32::MIN_POSITIVE,
+                ..Default::default()
+            },
+            &DrawOptions::new(),
+        );
+    }
+
     #[test]
     fn dashing() {
         let mut dt = DrawTarget::new(3, 3);
Repository: tweag/nickel (Rust)

Issue:
Wrong handling of `#` character in multiline strings
**Describe the bug**
A `#` or a sequence of `#` in a multiline string causes a parse error.

**To Reproduce**
 ```
% nickel <<< 'm#"Hel#lo"#m'
error: Unexpected token
  ┌─ <stdin>:1:7
  │
1│ m#"Hel#lo"#m
  │       ^
```

**Expected behavior**
The program evaluates without error:
```
% nickel <<< 'm#"Hel#lo"#m'
Done: Str("Hel#lo")
```


Discussion:

Patch:
diff --git a/src/parser/lexer.rs b/src/parser/lexer.rs
index 43b65e0116..ca098a799b 100644
--- a/src/parser/lexer.rs
+++ b/src/parser/lexer.rs
@@ -278,7 +278,7 @@ pub enum MultiStringToken<'input> {
     #[regex("\"#+m")]
     CandidateEnd(&'input str),
     // Same as `FalseEnd` and `CandidateEnd` but for an interpolation sequence.
-    #[token("#+")]
+    #[regex("#+")]
     FalseInterpolation(&'input str),
     #[regex("#+\\{")]
     CandidateInterpolation(&'input str),


Test patch:
diff --git a/src/parser/tests.rs b/src/parser/tests.rs
index 048c52612e..6bcb6a40f7 100644
--- a/src/parser/tests.rs
+++ b/src/parser/tests.rs
@@ -281,3 +281,16 @@ fn str_escape() {
         mk_single_chunk("#a#b#c#{d#"),
     );
 }
+
+/// Regression test for [#230](https://github.com/tweag/nickel/issues/230).
+#[test]
+fn multiline_str_escape() {
+    assert_eq!(
+        parse_without_pos(r##"m#"#Hel##lo###"#m"##),
+        mk_single_chunk("#Hel##lo###"),
+    );
+    assert_eq!(
+        parse_without_pos(r##"m#"#Hel##{lo###{"#m"##),
+        mk_single_chunk("#Hel##{lo###{"),
+    );
+}
Repository: mitsuhiko/minijinja (Rust)

Issue:
Distinguish between `Value`s containing integers and floats
Hi, I would like to be able to distinguish between a Value representing integers (`ValueRepr::U64`, `ValueRepr::I64` etc.) and a Value representing a float (`ValueRepr::F64`).

Right now, there isn't a way to know whether a `Value` contains a float or int because
- The `ValueRepr` (`Value.0`) is private 
- `ValueKind` considers ints and floats all to be a `ValueKind::Number`
- Converting a `Value` doesn't reveal this information either, it just converts floats to ints and vice versa:

```rs
assert_eq!(Value::from(0.0).as_i64().unwrap(), 0);
assert_eq!(f64::try_from(Value::from(0)).unwrap(), 0.0);
```

This distinction can be quite useful if you want to format a value differently based on whether it's an int or float for example.

I'm happy to create a PR for this if that helps but I'm not sure what the best approach is.


Discussion:
Thanks a lot!



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32e5d07eb..fa71603c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,8 @@ All notable changes to MiniJinja are documented here.
   values.  #571
 - Changed sort order of `Ord` to avoid accidentally non total order
   that could cause panics on Rust 1.81.  #579
+- Added a `Value::is_integer` method to allow a user to tell floats
+  and true integers apart.  #580
 
 ## 2.2.0
 
diff --git a/minijinja/src/value/mod.rs b/minijinja/src/value/mod.rs
index 4fdac4454..8fc43acfb 100644
--- a/minijinja/src/value/mod.rs
+++ b/minijinja/src/value/mod.rs
@@ -979,6 +979,17 @@ impl Value {
         )
     }
 
+    /// Returns true if the number is a real integer.
+    ///
+    /// This can be used to distinguish `42` from `42.0`.  For the most part
+    /// the engine keeps these the same.
+    pub fn is_integer(&self) -> bool {
+        matches!(
+            self.0,
+            ValueRepr::U64(_) | ValueRepr::I64(_) | ValueRepr::I128(_) | ValueRepr::U128(_)
+        )
+    }
+
     /// Returns `true` if the map represents keyword arguments.
     pub fn is_kwargs(&self) -> bool {
         Kwargs::extract(self).is_some()


Test patch:
diff --git a/minijinja/src/tests.rs b/minijinja/src/tests.rs
index 0a648535d..f3528a821 100644
--- a/minijinja/src/tests.rs
+++ b/minijinja/src/tests.rs
@@ -307,13 +307,7 @@ mod builtins {
     /// ```
     #[cfg_attr(docsrs, doc(cfg(feature = "builtins")))]
     pub fn is_integer(v: Value) -> bool {
-        matches!(
-            v.0,
-            crate::value::ValueRepr::U64(_)
-                | crate::value::ValueRepr::I64(_)
-                | crate::value::ValueRepr::U128(_)
-                | crate::value::ValueRepr::I128(_)
-        )
+        v.is_integer()
     }
 
     /// Checks if this value is a float
Repository: dtolnay/async-trait (Rust)

Issue:
Longhand method receivers emit the wrong bound
```rust
use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    async fn f(&self) {} // works
    async fn g(self: &Self) {} // does not work
}
```

```console
error[E0277]: `Self` cannot be shared between threads safely
   --> tests/test.rs:564:33
    |
564 |         async fn g(self: &Self) {}
    |                                 ^^ `Self` cannot be shared between threads safely
    |
    = help: the trait `std::marker::Sync` is not implemented for `Self`
    = note: required because of the requirements on the impl of `std::marker::Send` for `&Self`
    = note: required because it appears within the type `[static generator@tests/test.rs:564:33: 564:35 _self:&Self {}]`
    = note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@tests/test.rs:564:33: 564:35 _self:&Self {}]>`
    = note: required because it appears within the type `impl std::future::Future`
    = note: required because it appears within the type `impl std::future::Future`
    = note: required for the cast to the object type `dyn std::future::Future<Output = ()> + std::marker::Send`
```


Discussion:

Patch:
diff --git a/src/expand.rs b/src/expand.rs
index 317ab82..6357b10 100644
--- a/src/expand.rs
+++ b/src/expand.rs
@@ -179,6 +179,16 @@ fn transform_sig(
                 mutability: None,
                 ..
             })) => parse_quote!(Sync),
+            Some(FnArg::Typed(arg))
+                if match (arg.pat.as_ref(), arg.ty.as_ref()) {
+                    (Pat::Ident(pat), Type::Reference(ty)) => {
+                        pat.ident == "self" && ty.mutability.is_none()
+                    }
+                    _ => false,
+                } =>
+            {
+                parse_quote!(Sync)
+            }
             _ => parse_quote!(Send),
         };
         let assume_bound = match context {


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 4d81aec..6f65e91 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -554,3 +554,14 @@ pub mod issue81 {
         }
     }
 }
+
+// https://github.com/dtolnay/async-trait/issues/83
+pub mod issue83 {
+    use async_trait::async_trait;
+
+    #[async_trait]
+    pub trait Trait {
+        async fn f(&self) {}
+        async fn g(self: &Self) {}
+    }
+}
Repository: gfx-rs/naga (Rust)

Issue:
The else if statement is not supported
Naga does not allow an if_statement inside an else_statement, but the [spec](https://www.w3.org/TR/WGSL/#if-statement) allows for it.

```
if (true) {} else if (false) {}
```

```
Parse Error: expected '{', found 'if'
```



Discussion:

Patch:
diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs
index 0e39ee176b..1bfc2fd8d5 100644
--- a/src/front/wgsl/mod.rs
+++ b/src/front/wgsl/mod.rs
@@ -3470,9 +3470,20 @@ impl Parser {
                         lexer.expect(Token::Paren(')'))?;
 
                         let accept = self.parse_block(lexer, context.reborrow(), false)?;
+
                         let mut elsif_stack = Vec::new();
                         let mut elseif_span_start = lexer.current_byte_offset();
-                        while lexer.skip(Token::Word("elseif")) {
+                        let mut reject = loop {
+                            if !lexer.skip(Token::Word("else")) {
+                                break crate::Block::new();
+                            }
+
+                            if !lexer.skip(Token::Word("if")) {
+                                // ... else { ... }
+                                break self.parse_block(lexer, context.reborrow(), false)?;
+                            }
+
+                            // ... else if (...) { ... }
                             let mut sub_emitter = super::Emitter::default();
 
                             lexer.expect(Token::Paren('('))?;
@@ -3491,12 +3502,8 @@ impl Parser {
                                 other_block,
                             ));
                             elseif_span_start = lexer.current_byte_offset();
-                        }
-                        let mut reject = if lexer.skip(Token::Word("else")) {
-                            self.parse_block(lexer, context.reborrow(), false)?
-                        } else {
-                            crate::Block::new()
                         };
+
                         let span_end = lexer.current_byte_offset();
                         // reverse-fold the else-if blocks
                         //Note: we may consider uplifting this to the IR


Test patch:
diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs
index f64ac30369..60c02c4e6d 100644
--- a/src/front/wgsl/tests.rs
+++ b/src/front/wgsl/tests.rs
@@ -215,7 +215,7 @@ fn parse_if() {
             if (0 != 1) {}
             if (false) {
                 return;
-            } elseif (true) {
+            } else if (true) {
                 return;
             } else {}
         }
Repository: dtolnay/async-trait (Rust)

Issue:
Linting on non_snake_case is inconsistent with ordinary trait impls
Normally Rust only triggers non_snake_case on the one place that decides the name of a thing, for example the trait definition rather than the impl.

```rust
#![deny(non_snake_case)]

pub trait Trait {
    #[allow(non_snake_case)]
    fn camelCase();
}

pub struct Struct;

impl Trait for Struct {
    fn camelCase() {}
}
```

But async_trait hits it on the impl as well, which is not right.

```rust
#![deny(non_snake_case)]

use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    #[allow(non_snake_case)]
    async fn camelCase();
}

pub struct Struct;

#[async_trait]
impl Trait for Struct {
    async fn camelCase() {}
}
```

```console
error: function `__camelCase` should have a snake case name
   --> tests/test.rs:584:18
    |
584 |         async fn camelCase() {}
    |                  ^^^^^^^^^ help: convert the identifier to snake case: `__camel_case`
    |
note: the lint level is defined here
   --> tests/test.rs:570:13
    |
570 |     #![deny(non_snake_case)]
    |             ^^^^^^^^^^^^^^
```


Discussion:

Patch:
diff --git a/src/expand.rs b/src/expand.rs
index 6357b10..5d51263 100644
--- a/src/expand.rs
+++ b/src/expand.rs
@@ -429,9 +429,16 @@ fn transform_block(
         .map(|param| param.ident.clone());
     generics.extend(consts);
 
+    let allow_non_snake_case = if sig.ident != sig.ident.to_string().to_lowercase() {
+        Some(quote!(non_snake_case,))
+    } else {
+        None
+    };
+
     let brace = block.brace_token;
     let box_pin = quote_spanned!(brace.span=> {
         #[allow(
+            #allow_non_snake_case
             clippy::missing_docs_in_private_items,
             clippy::type_repetition_in_bounds,
             clippy::used_underscore_binding,


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 6f65e91..c10fd43 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -565,3 +565,23 @@ pub mod issue83 {
         async fn g(self: &Self) {}
     }
 }
+
+// https://github.com/dtolnay/async-trait/issues/85
+pub mod issue85 {
+    #![deny(non_snake_case)]
+
+    use async_trait::async_trait;
+
+    #[async_trait]
+    pub trait Trait {
+        #[allow(non_snake_case)]
+        async fn camelCase();
+    }
+
+    pub struct Struct;
+
+    #[async_trait]
+    impl Trait for Struct {
+        async fn camelCase() {}
+    }
+}
Repository: qmonnet/rbpf (Rust)

Issue:
rbpf incorrectly rejects last instruction is not an exit
The rbpf runtime incorrectly rejects programs where the last instruction is not an exit instruction.

See https://github.com/Alan-Jowett/bpf_conformance/blob/main/tests/exit-not-last.data as an example.

This test passes the Linux verifier.



Discussion:

Patch:
diff --git a/src/verifier.rs b/src/verifier.rs
index 0749721cc..6aeed1514 100644
--- a/src/verifier.rs
+++ b/src/verifier.rs
@@ -40,8 +40,8 @@ fn check_prog_len(prog: &[u8]) -> Result<(), Error> {
     if prog.is_empty() {
         reject("no program set, call set_program() to load one")?;
     }
-    let last_insn = ebpf::get_insn(prog, (prog.len() / ebpf::INSN_SIZE) - 1);
-    if last_insn.opc != ebpf::EXIT {
+    let last_opc = ebpf::get_insn(prog, (prog.len() / ebpf::INSN_SIZE) - 1).opc;
+    if last_opc & ebpf::BPF_CLS_MASK != ebpf::BPF_JMP {
         reject("program does not end with “EXIT” instruction")?;
     }
 


Test patch:
diff --git a/tests/ubpf_verifier.rs b/tests/ubpf_verifier.rs
index 92c7af517..d1707fabd 100644
--- a/tests/ubpf_verifier.rs
+++ b/tests/ubpf_verifier.rs
@@ -115,6 +115,16 @@ fn test_verifier_err_no_exit() {
     vm.execute_program().unwrap();
 }
 
+#[test]
+fn test_verifier_err_no_exit_backward_jump() {
+    let prog = assemble("
+        ja +1
+        exit
+        ja -2").unwrap();
+    let vm = rbpf::EbpfVmNoData::new(Some(&prog)).unwrap();
+    vm.execute_program().unwrap();
+}
+
 #[test]
 #[should_panic(expected = "[Verifier] Error: eBPF program length limited to 4096, here 4097")]
 fn test_verifier_err_too_many_instructions() {
Repository: slog-rs/slog (Rust)

Issue:
Implement `Clone` for `Never`
I totally understand that `Never` is just a stand-in for `!`. However, `!` implements `Clone`: https://doc.rust-lang.org/std/primitive.never.html#implementations

I would like this because currently I have an `slog_atomic::AtomicSwitchCtrl` which has the impl:
```
impl<O: Clone, E: Clone> Clone for AtomicSwitchCtrl<O, E>
```

Another possible fix would be to provide 
```
impl<O: Clone> Clone for AtomicSwitchCtrl<O, Never>
```
but this feels worse to special case something which will go away soon anyway.

Yet another possible fix would be to wrap the `AtomicSwitchCtrl` in an `Arc` but that is just `
Arc<Arc<...>>` which I'd also rather avoid.

I'm happy to make the PR if nobody has any objects, it should just be 1 line.



Discussion:
PR please. :)



Patch:
diff --git a/src/lib.rs b/src/lib.rs
index 042887996..5e486451c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3564,7 +3564,7 @@ pub type Never = private::NeverStruct;
 
 mod private {
     #[doc(hidden)]
-    #[derive(Debug)]
+    #[derive(Clone, Debug)]
     pub struct NeverStruct(());
 }
 


Test patch:
diff --git a/src/tests.rs b/src/tests.rs
index fcabd1248..a4e5f4aef 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -1,4 +1,5 @@
 use {Discard, Logger};
+use Never;
 
 // Separate module to test lack of imports
 mod no_imports {
@@ -257,3 +258,12 @@ fn logger_by_ref() {
     info!(&log, "message"; "f" => %f, "d" => ?d);
 }
 
+#[test]
+fn test_never_type_clone() {
+    // We just want to make sure that this compiles
+    fn _do_not_run() {
+        let x: Never = panic!("Can't actually construct a Never type here!");
+        let y = x.clone();
+    }
+    // Always pass if we compiled
+}
Repository: kivikakk/comrak (Rust)

Issue:
Lines wrap incorrectly when followed by a non-wrappable line
Hello! I believe I've found a bug. I have a markdown file `untitled.md`:

```md
item that doesn't need wrapping

a-long-line-that-won't-be-wrapped-because-there-is-no-character-it-can-break-on
```

When running this through the cli with the `--to commonmark` and `--width 72` options:

```sh
comrak --to commonmark --width 72 untitled.md
```

It outputs the following:

```md
item that doesn't need
wrapping

a-long-line-that-won't-be-wrapped-because-there-is-no-character-it-can-break-on
```

I think the list item is not supposed to wrap there. If the last line is short enough to not need wrapping, this doesn't occur. If the last line is wrappable (e.g. remove all the `-` characters), this also doesn't occur.


Discussion:
Thanks for this report — verified. Will look into a fix in a little bit.

Also, if you felt like giving it a go yourself and had the time, please feel free! Should be a nice easy one to just compare the wrapping behaviour of comrak's CommonMark formatter and cmark-gfm's.
Cool. I made an attempt at a fix in #228



Patch:
diff --git a/src/cm.rs b/src/cm.rs
index db1cb277..9e71dda0 100644
--- a/src/cm.rs
+++ b/src/cm.rs
@@ -108,6 +108,7 @@ impl<'a, 'o> CommonMarkFormatter<'a, 'o> {
                 }
             }
             self.column = 0;
+            self.last_breakable = 0;
             self.begin_line = true;
             self.begin_content = true;
             self.need_cr -= 1;


Test patch:
diff --git a/src/tests.rs b/src/tests.rs
index 7a7d6099..d9ab37b8 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -61,6 +61,18 @@ fn compare_strs(output: &str, expected: &str, kind: &str) {
     assert_eq!(output, expected);
 }
 
+#[track_caller]
+fn commonmark(input: &str, expected: &str) {
+    let arena = ::Arena::new();
+    let mut options = ::ComrakOptions::default();
+    options.render.width = 72;
+
+    let root = ::parse_document(&arena, input, &options);
+    let mut output = vec![];
+    cm::format_document(root, &options, &mut output).unwrap();
+    compare_strs(&String::from_utf8(output).unwrap(), expected, "regular");
+}
+
 #[track_caller]
 fn html(input: &str, expected: &str) {
     html_opts(input, expected, |_| ());
@@ -249,6 +261,27 @@ fn thematic_breaks() {
     );
 }
 
+#[test]
+fn width_breaks() {
+    let input = concat!(
+        "this should break because it has breakable characters. break right here newline\n",
+        "\n",
+        "don't break\n",
+        "\n",
+        "a-long-line-that-won't-break-because-there-is-no-character-it-can-break-on\n"
+    );
+    let output = concat!(
+        "this should break because it has breakable characters. break right here\n",
+        "newline\n",
+        "\n",
+        "don't break\n",
+        "\n",
+        "a-long-line-that-won't-break-because-there-is-no-character-it-can-break-on\n"
+    );
+
+    commonmark(input, output);
+}
+
 #[test]
 fn setext_heading() {
     html(
Repository: sharkdp/numbat (Rust)

Issue:
where clauses in function definitions leak out and impact global definitions
Consider this function:

```
fn foo(x: Scalar) -> Scalar = x + something where something = 1
```

Ideally we'd like and expect that `something` is locally scoped to this function definition.  But it's name leaks out and prevents the name `something` from being used in some contexts (like unit definitions):

```
>>> unit something
error: identifier clash in definition
  ┌─ <input:2>:1:51
  │
1 │ fn foo(x: Scalar) -> Scalar = x + something where something = 1
  │                                                   --------- Previously defined here
  │
  ┌─ <input:4>:1:6
  │
1 │ unit something
  │      ^^^^^^^^^ identifier is already in use

```


Discussion:
Looking at https://github.com/sharkdp/numbat/blob/01b2a7cb4f2068d4c1ef78a79abc34355a3412fc/numbat/src/prefix_transformer.rs#L199-L205

Should those `self`s be `fn_body_transformer`s?



Patch:
diff --git a/numbat/src/prefix_transformer.rs b/numbat/src/prefix_transformer.rs
index 6b34d04e..3f1a5fac 100644
--- a/numbat/src/prefix_transformer.rs
+++ b/numbat/src/prefix_transformer.rs
@@ -197,11 +197,11 @@ impl Transformer {
                 }
 
                 if let Some(expr) = body {
-                    self.transform_expression(expr);
+                    fn_body_transformer.transform_expression(expr);
                 }
 
                 for def in local_variables {
-                    self.transform_define_variable(def)?;
+                    fn_body_transformer.transform_define_variable(def)?;
                 }
             }
             Statement::DefineDimension(_, name, _) => {


Test patch:
diff --git a/numbat/tests/interpreter.rs b/numbat/tests/interpreter.rs
index 926217d1..d079470e 100644
--- a/numbat/tests/interpreter.rs
+++ b/numbat/tests/interpreter.rs
@@ -12,14 +12,14 @@ use numbat::{pretty_print::PrettyPrint, Context, InterpreterResult};
 #[track_caller]
 fn expect_output_with_context(ctx: &mut Context, code: &str, expected_output: impl AsRef<str>) {
     let expected_output = expected_output.as_ref();
-    println!("Expecting output '{expected_output}' for code '{code}'");
+    println!("Expecting output {expected_output:?} for code\n{code}");
     if let InterpreterResult::Value(val) = ctx.interpret(code, CodeSource::Internal).unwrap().1 {
         let fmt = PlainTextFormatter {};
 
         let actual_output = fmt.format(&val.pretty_print(), false);
         assert_eq!(actual_output.trim(), expected_output);
     } else {
-        panic!();
+        panic!("Did not receive an interpreter result. Did you try to print the values?");
     }
 }
 
@@ -756,6 +756,20 @@ fn test_overwrite_inner_function() {
     );
 }
 
+#[test]
+fn test_676_where_clause_does_not_leak() {
+    // https://github.com/sharkdp/numbat/issues/676
+    expect_output(
+        "
+        fn foo(x: Scalar) -> Scalar = x + something where something = 1
+        unit something
+
+        1 something
+        ",
+        "1 something",
+    );
+}
+
 #[test]
 fn test_override_constants() {
     expect_output("let x = 1\nlet x = 2\nx", "2");
Repository: latex-lsp/texlab (Rust)

Issue:
Support "Go to References" for starred variants of commands
Similar as #1197, but for "Go to References".

Invoking "Go to References" on the definition of command `\foo` should find both normal `\foo` calls and starred calls `\foo*`.
Also invoking "Go to References" on either `\foo` or `\foo*` should find both types of calls.


Discussion:

Patch:
diff --git a/crates/references/src/command.rs b/crates/references/src/command.rs
index f4504641f..cf5849a13 100644
--- a/crates/references/src/command.rs
+++ b/crates/references/src/command.rs
@@ -32,7 +32,9 @@ pub(super) fn find_all(context: &mut ReferenceContext) -> Option<()> {
                 .collect();
 
             for command in &data.semantics.commands {
-                if command.text == token.text()[1..] {
+                let command_text = command.text.trim_end_matches('*');
+                let token_text = token.text()[1..].trim_end_matches('*');
+                if command_text == token_text {
                     let kind = if defs.contains(command) {
                         ReferenceKind::Definition
                     } else {


Test patch:
diff --git a/crates/references/src/tests.rs b/crates/references/src/tests.rs
index 845282afb..713148069 100644
--- a/crates/references/src/tests.rs
+++ b/crates/references/src/tests.rs
@@ -260,3 +260,43 @@ fn test_new_command_definition_include_decl() {
         true,
     );
 }
+
+#[test]
+fn test_new_command_definition_starred() {
+    check(
+        r#"
+%! main.tex
+\foo
+ ^^^
+\foo*
+  |
+ ^^^^
+
+\NewDocumentCommand{\foo}{s m}{%
+    \IfBooleanTF{#1}{\textbf{#2}}{#2}%
+}
+"#,
+        false,
+    );
+}
+
+#[test]
+fn test_new_command_definition_starred_include_decl() {
+    check(
+        r#"
+%! main.tex
+\foo
+ ^^^
+\foo*
+  |
+ ^^^^
+
+\NewDocumentCommand{\foo}{s m}{%
+                     ^^^
+    \IfBooleanTF{#1}{\textbf{#2}}{#2}%
+}
+
+"#,
+        true,
+    );
+}