PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: rust-lang/rustfmt (rust)

Issue:
buggy formatting on expression attributes with comments
Example code: 
```rs
#![feature(stmt_expr_attributes)]
fn main() {
    let some_function_call = || {};

    let filter = || {
        (
            // comment
            #[allow(clippy::disallowed_methods)]
            some_function_call()
        )
    };
}
```

Everytime you format it it replicates the attribute and doubles it:
```rs
#![feature(stmt_expr_attributes)]
fn main() {
    let some_function_call = || {};

    let filter = || {
        (
            // comment
            #[allow(clippy::disallowed_methods)]
            #[allow(clippy::disallowed_methods)]
            some_function_call()
        )
    };
}
```

Version: rustfmt 1.6.0-nightly (39f42ad9 2023-07-19)

Pull request:
Bugfix/comment duplication
Fixes #5871 

The issue  was in the `rewrite_paren` function.

Since the span on expressions doesn't include attributes and attributes comes before the expression, this caused the attribute to be included in `pre_comment` since the end of the comment span was `subexpr.span.lo()`.
I changed the logic to use the span of the first attribute, if there are any attributes present. If not, default to the expression span.

Patch:
diff --git a/src/expr.rs b/src/expr.rs
index 450f1476..2f230ecc 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1453,7 +1453,7 @@ pub(crate) fn rewrite_paren(
     let remove_nested_parens = context.config.remove_nested_parens();
     loop {
         // 1 = "(" or ")"
-        pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span.lo());
+        pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span().lo());
         post_span = mk_sp(subexpr.span.hi(), span.hi() - BytePos(1));
         pre_comment = rewrite_missing_comment(pre_span, shape, context)?;
         post_comment = rewrite_missing_comment(post_span, shape, context)?;


Test patch:
diff --git a/tests/target/issue-5871.rs b/tests/target/issue-5871.rs
new file mode 100644
index 00000000..3116533b
--- /dev/null
+++ b/tests/target/issue-5871.rs
@@ -0,0 +1,8 @@
+#![feature(stmt_expr_attributes)]
+fn okay() -> u32 {
+    (
+        // Comments in parentheses-expressions caused attributes to be duplicated.
+        #[allow(unused_variables)]
+        0
+    )
+}
Repository: kubernetes-client/javascript (ts)

Issue:
List/Watch fails without error if the list function failse
**Describe the bug**
When listFn returns an error, the ListWatch is broken and no ERROR event is sent

**Client Version**
All

**Server Version**
n/a

**To Reproduce**
Fail the initial list function in a list/watch call.

**Expected behavior**
An error should be emitted to the done handler

See #2217 

Pull request:
Fix a bug where an error on request wouldn't propogate.
Fixes #2222 

Patch:
diff --git a/src/cache.ts b/src/cache.ts
index 8b580d02..2ee8c4f8 100644
--- a/src/cache.ts
+++ b/src/cache.ts
@@ -10,7 +10,7 @@ import {
     ObjectCallback,
     UPDATE,
 } from './informer.js';
-import { KubernetesObject } from './types.js';
+import { KubernetesObject, KubernetesListObject } from './types.js';
 import { ObjectSerializer } from './serializer.js';
 import { Watch } from './watch.js';
 
@@ -143,8 +143,14 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T>, In
         }
         this.callbackCache[CONNECT].forEach((elt: ErrorCallback) => elt(undefined));
         if (!this.resourceVersion) {
-            const promise = this.listFn();
-            const list = await promise;
+            let list: KubernetesListObject<T>;
+            try {
+                const promise = this.listFn();
+                list = await promise;
+            } catch (err) {
+                this.callbackCache[ERROR].forEach((elt: ErrorCallback) => elt(err));
+                return;
+            }
             this.objects = deleteItems(this.objects, list.items, this.callbackCache[DELETE].slice());
             this.addOrUpdateItems(list.items);
             this.resourceVersion = list.metadata!.resourceVersion || '';


Test patch:
diff --git a/src/cache_test.ts b/src/cache_test.ts
index bfcd7114..e2e01238 100644
--- a/src/cache_test.ts
+++ b/src/cache_test.ts
@@ -1460,4 +1460,25 @@ describe('delete items', () => {
 
         strictEqual(await connectPromise, true);
     });
+
+    it('should correctly handle errors in the initial list', async () => {
+        const fake = mock.mock(Watch);
+        const requestErr = Error('request failed');
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                reject(requestErr);
+            });
+        };
+        const lw = new ListWatch('/some/path', fake, listFn);
+        let gotErr: Error | null = null;
+        const errCalled = new Promise<void>((resolve, reject) => {
+            lw.on('error', (err) => {
+                gotErr = err;
+                resolve();
+            });
+        });
+        await lw.start();
+        await errCalled;
+        strictEqual(gotErr, requestErr);
+    });
 });