nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: fluxcd/notification-controller
Pull request #80 (2020-11-16 19:56:15)

Change code to use subgroup in gitlab
When I use the subgroup of gitlab I get an error "Incorrectly formatted git address"
the id on gitlab can use more than two block
I changed the code to be able to handle two or more blocks in the ID
Can you tell me if this is right for you?

stefanprodan: @Joda89 please run `make test` and commit changes, then squash your commits into a single one. Thanks!
Joda89: @stefanprodan It's done 
phillebaba: @Joda89 could you also add a test in `util_test.go` for a GitLab url with a subgroup. You should be able to just copy one of the existing tests.
Joda89: @phillebaba it's done
phillebaba: Sorry for not thinking about subgroups in GitLab, there are always small detail differences between the different GitHub providers. Thank you for taking the time and fixing it. :rose: 

Now when I think about it I don't really remember why I thought it was a good idea to split the path into components.
Could you change the code to just clean up the id value and return it?
```golang
func parseGitAddress(s string) (string, string, error) {
	u, err := giturls.Parse(s)
	if err != nil {
		return "", "", nil
	}

	id := strings.TrimLeft(u.Path, "/")
	id = strings.TrimSuffix(id, ".git")
	host := fmt.Sprintf("https://%s", u.Host)
	return host, id, nil
}
```

Each provider should be responsible for verifying the repo id they get so that it matches their client. GitHub needs to split it while GitLab does not. I can add that validation tonight to the different providers if you make my suggested changes so we merge this PR.

Patch:
diff --git a/internal/notifier/util.go b/internal/notifier/util.go
index f31e8ec..c6c60dc 100644
--- a/internal/notifier/util.go
+++ b/internal/notifier/util.go
@@ -32,14 +32,9 @@ func parseGitAddress(s string) (string, string, error) {
 		return "", "", nil
 	}
 
-	path := strings.TrimLeft(u.Path, "/")
-	comp := strings.Split(path, "/")
-	if len(comp) != 2 {
-		return "", "", fmt.Errorf("Incorrectly formatted git address: %v", s)
-	}
-
+	id := strings.TrimLeft(u.Path, "/")
+	id = strings.TrimSuffix(id, ".git")
 	host := fmt.Sprintf("https://%s", u.Host)
-	id := comp[0] + "/" + strings.TrimSuffix(comp[1], ".git")
 	return host, id, nil
 }
 


Test patch:
diff --git a/internal/notifier/util_test.go b/internal/notifier/util_test.go
index fb426dc..d65be75 100644
--- a/internal/notifier/util_test.go
+++ b/internal/notifier/util_test.go
@@ -95,3 +95,11 @@ func TestUtil_ParseGitSshWithProtocol(t *testing.T) {
 	require.Equal(t, "https://github.com", host)
 	require.Equal(t, "stefanprodan/podinfo", id)
 }
+
+func TestUtil_ParseGitHttpWithSubgroup(t *testing.T) {
+	addr := "https://gitlab.com/foo/bar/foo.git"
+	host, id, err := parseGitAddress(addr)
+	require.NoError(t, err)
+	require.Equal(t, "https://gitlab.com", host)
+	require.Equal(t, "foo/bar/foo", id)
+}
Repository: fluxcd/notification-controller
Pull request #223 (2021-07-26 13:55:17)

providers/sentry: add environment support
use channel configuration for sentry environment to re-use the same DSN for multiple clusters

created this as a separate PR to not clash with the other sentry PR


Patch:
diff --git a/docs/spec/v1beta1/provider.md b/docs/spec/v1beta1/provider.md
index ce68c32..62505c5 100644
--- a/docs/spec/v1beta1/provider.md
+++ b/docs/spec/v1beta1/provider.md
@@ -224,6 +224,23 @@ kubectl create secret generic $SECRET_NAME \
   --from-file=caFile=ca.crt
 ```
 
+### Sentry
+
+The sentry provider uses the `channel` field to specify which environment the messages are sent for:
+
+```yaml
+apiVersion: notification.toolkit.fluxcd.io/v1beta1
+kind: Provider
+metadata:
+  name: sentry
+  namespace: default
+spec:
+  type: sentry
+  channel: my-cluster-name
+  # webhook address (ignored if secretRef is specified)
+  address: https://....@sentry.io/12341234
+```
+
 ### Azure Event Hub
 
 The Azure Event Hub supports two authentication methods, [JWT](https://docs.microsoft.com/en-us/azure/event-hubs/authenticate-application) and [SAS](https://docs.microsoft.com/en-us/azure/event-hubs/authorize-access-shared-access-signature) based.
diff --git a/internal/notifier/factory.go b/internal/notifier/factory.go
index 19f7bf7..8659177 100644
--- a/internal/notifier/factory.go
+++ b/internal/notifier/factory.go
@@ -74,7 +74,7 @@ func (f Factory) Notifier(provider string) (Interface, error) {
 	case v1beta1.WebexProvider:
 		n, err = NewWebex(f.URL, f.ProxyURL, f.CertPool)
 	case v1beta1.SentryProvider:
-		n, err = NewSentry(f.CertPool, f.URL)
+		n, err = NewSentry(f.CertPool, f.URL, f.Channel)
 	case v1beta1.AzureEventHubProvider:
 		n, err = NewAzureEventHub(f.URL, f.Token, f.Channel)
 	default:
diff --git a/internal/notifier/sentry.go b/internal/notifier/sentry.go
index 09931cf..b44dcb2 100644
--- a/internal/notifier/sentry.go
+++ b/internal/notifier/sentry.go
@@ -32,7 +32,7 @@ type Sentry struct {
 }
 
 // NewSentry creates a Sentry client from the provided Data Source Name (DSN)
-func NewSentry(certPool *x509.CertPool, dsn string) (*Sentry, error) {
+func NewSentry(certPool *x509.CertPool, dsn string, environment string) (*Sentry, error) {
 	tr := &http.Transport{}
 	if certPool != nil {
 		tr = &http.Transport{
@@ -43,6 +43,7 @@ func NewSentry(certPool *x509.CertPool, dsn string) (*Sentry, error) {
 	}
 	client, err := sentry.NewClient(sentry.ClientOptions{
 		Dsn:           dsn,
+		Environment:   environment,
 		HTTPTransport: tr,
 	})
 	if err != nil {


Test patch:
diff --git a/internal/notifier/sentry_test.go b/internal/notifier/sentry_test.go
index 4d89f28..8496c36 100644
--- a/internal/notifier/sentry_test.go
+++ b/internal/notifier/sentry_test.go
@@ -30,9 +30,10 @@ import (
 )
 
 func TestNewSentry(t *testing.T) {
-	s, err := NewSentry(nil, "https://test@localhost/1")
+	s, err := NewSentry(nil, "https://test@localhost/1", "foo")
 	require.NoError(t, err)
 	assert.Equal(t, s.Client.Options().Dsn, "https://test@localhost/1")
+	assert.Equal(t, s.Client.Options().Environment, "foo")
 }
 
 func TestToSentryEvent(t *testing.T) {
Repository: fluxcd/notification-controller
Pull request #384 (2022-06-18 08:43:37)

Update Azure DevOps Go API
Updates the Azure DevOps API to the latest version. No real feature changes, just keeping things up to date.

Signed-off-by: Philip Laine <philip.laine@gmail.com>


Patch:
diff --git a/go.mod b/go.mod
index 297b5e8..f28a7a3 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
 	github.com/google/go-github/v41 v41.0.0
 	github.com/hashicorp/go-retryablehttp v0.7.1
 	github.com/ktrysmt/go-bitbucket v0.9.46
-	github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
+	github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.0
 	github.com/mitchellh/mapstructure v1.4.3 // indirect
 	github.com/onsi/ginkgo v1.16.5 // indirect
 	github.com/onsi/gomega v1.19.0
diff --git a/go.sum b/go.sum
index 1e29226..0506abc 100644
--- a/go.sum
+++ b/go.sum
@@ -470,8 +470,8 @@ github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
-github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5 h1:YH424zrwLTlyHSH/GzLMJeu5zhYVZSx5RQxGKm1h96s=
-github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5/go.mod h1:PoGiBqKSQK1vIfQ+yVaFcGjDySHvym6FM1cNYnwzbrY=
+github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.0 h1:HJlMLFJkpQVK1FfczP8mYMQT+EYiJba5TtsX7qL7ORI=
+github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.0/go.mod h1:1bdoUWt0f/xMYxDzy6FwSvDBxBzJmw99HV//P7b4cyE=
 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
 github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
 github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
diff --git a/internal/notifier/azure_devops.go b/internal/notifier/azure_devops.go
index aa4d72e..4df4127 100644
--- a/internal/notifier/azure_devops.go
+++ b/internal/notifier/azure_devops.go
@@ -27,8 +27,8 @@ import (
 
 	"github.com/fluxcd/pkg/runtime/events"
 
-	"github.com/microsoft/azure-devops-go-api/azuredevops"
-	"github.com/microsoft/azure-devops-go-api/azuredevops/git"
+	"github.com/microsoft/azure-devops-go-api/azuredevops/v6"
+	"github.com/microsoft/azure-devops-go-api/azuredevops/v6/git"
 )
 
 const genre string = "fluxcd"


Test patch:
diff --git a/internal/notifier/azure_devops_test.go b/internal/notifier/azure_devops_test.go
index 6e8e8de..75c49f0 100644
--- a/internal/notifier/azure_devops_test.go
+++ b/internal/notifier/azure_devops_test.go
@@ -19,7 +19,7 @@ package notifier
 import (
 	"testing"
 
-	"github.com/microsoft/azure-devops-go-api/azuredevops/git"
+	"github.com/microsoft/azure-devops-go-api/azuredevops/v6/git"
 	"github.com/stretchr/testify/assert"
 )
Repository: dtolnay/cxx
Pull request #490 (2020-11-20 03:12:43)

Skip ExternType::Kind check if type is known trivial
This fixes an error when an extern struct or enum is used as a struct field or function argument. Previously that would fail:

```console
error[cxxbridge]: needs a cxx::ExternType impl in order to be used as a field of `Second`
    ┌─ lib.rs:222:9
    │
222 │         type COwnedEnum;
    │         ^^^^^^^^^^^^^^^ needs a cxx::ExternType impl in order to be used as a field of `Second`
```

which is wrong because the bridge should know it itself is producing a compatible ExternType impl for the struct/enum.


Patch:
diff --git a/syntax/types.rs b/syntax/types.rs
index 92c9a75a..f57b61bb 100644
--- a/syntax/types.rs
+++ b/syntax/types.rs
@@ -170,7 +170,10 @@ impl<'a> Types<'a> {
         let mut required_trivial = Map::new();
         let mut insist_alias_types_are_trivial = |ty: &'a Type, reason| {
             if let Type::Ident(ident) = ty {
-                if cxx.contains(&ident.rust) {
+                if cxx.contains(&ident.rust)
+                    && !structs.contains_key(&ident.rust)
+                    && !enums.contains_key(&ident.rust)
+                {
                     required_trivial.entry(&ident.rust).or_insert(reason);
                 }
             }


Test patch:
diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs
index c408fb00..032adc47 100644
--- a/tests/ffi/lib.rs
+++ b/tests/ffi/lib.rs
@@ -113,6 +113,7 @@ pub mod ffi {
     #[namespace = "second"]
     struct Second {
         i: i32,
+        e: COwnedEnum,
     }
 
     unsafe extern "C++" {
Repository: dtolnay/anyhow
Pull request #3 (2019-10-07 20:16:54)

Accept string literal in bail macro


Patch:
diff --git a/src/lib.rs b/src/lib.rs
index 15eaecc..b92bed8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -283,6 +283,9 @@ pub type Result<T> = std::result::Result<T, Error>;
 /// ```
 #[macro_export]
 macro_rules! bail {
+    ($msg:literal $(,)?) => {
+        return std::result::Result::Err($crate::anyhow!($msg));
+    };
     ($err:expr $(,)?) => {
         return std::result::Result::Err(std::convert::From::from($err));
     };


Test patch:
diff --git a/tests/macros.rs b/tests/macros.rs
new file mode 100644
index 0000000..e670ef1
--- /dev/null
+++ b/tests/macros.rs
@@ -0,0 +1,28 @@
+use anyhow::{bail, Result};
+use std::io;
+
+fn bail_literal() -> Result<()> {
+    bail!("oh no!");
+}
+
+fn bail_fmt() -> Result<()> {
+    bail!("{} {}!", "oh", "no");
+}
+
+fn bail_error() -> Result<()> {
+    bail!(io::Error::new(io::ErrorKind::Other, "oh no!"));
+}
+
+#[test]
+fn test_messages() {
+    assert_eq!("oh no!", bail_literal().unwrap_err().to_string());
+    assert_eq!("oh no!", bail_fmt().unwrap_err().to_string());
+    assert_eq!("oh no!", bail_error().unwrap_err().to_string());
+}
+
+#[test]
+fn test_downcast() {
+    assert_eq!("oh no!", bail_literal().unwrap_err().downcast::<&str>().unwrap());
+    assert_eq!("oh no!", bail_fmt().unwrap_err().downcast::<String>().unwrap());
+    assert_eq!("oh no!", bail_error().unwrap_err().downcast::<io::Error>().unwrap().to_string());
+}
Repository: dtolnay/anyhow
Pull request #132 (2020-12-18 20:24:34)

Support round tripping anyhow::Error over C FFI as void*
Relevant to https://github.com/dtolnay/cxx/issues/290.


Patch:
diff --git a/src/lib.rs b/src/lib.rs
index a211b22..d124b1e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -361,6 +361,7 @@ pub use anyhow as format_err;
 ///     # Ok(())
 /// }
 /// ```
+#[repr(transparent)]
 pub struct Error {
     inner: ManuallyDrop<Box<ErrorImpl<()>>>,
 }


Test patch:
diff --git a/tests/test_ffi.rs b/tests/test_ffi.rs
new file mode 100644
index 0000000..0321fc1
--- /dev/null
+++ b/tests/test_ffi.rs
@@ -0,0 +1,18 @@
+#![deny(improper_ctypes, improper_ctypes_definitions)]
+
+use anyhow::anyhow;
+
+#[no_mangle]
+pub extern "C" fn anyhow1(err: anyhow::Error) {
+    println!("{:?}", err);
+}
+
+#[no_mangle]
+pub extern "C" fn anyhow2(err: &mut Option<anyhow::Error>) {
+    *err = Some(anyhow!("ffi error"));
+}
+
+#[no_mangle]
+pub extern "C" fn anyhow3() -> Option<anyhow::Error> {
+    Some(anyhow!("ffi error"))
+}
Repository: dtolnay/anyhow
Pull request #184 (2021-11-04 11:40:12)

Use the format_args processed string instead of original literal
Addresses https://github.com/dtolnay/anyhow/pull/180#issuecomment-959706570.


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9f43306..03b17e0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,7 +12,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        rust: [nightly, beta, stable, 1.51.0, 1.50.0]
+        rust: [nightly, beta, stable, 1.52.0]
     steps:
       - uses: actions/checkout@v2
       - uses: dtolnay/rust-toolchain@master
@@ -22,6 +22,21 @@ jobs:
       - run: cargo test
       - run: cargo check --no-default-features
       - run: cargo check --features backtrace
+
+  build:
+    name: Rust ${{matrix.rust}}
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        rust: [1.51.0, 1.50.0]
+    steps:
+      - uses: actions/checkout@v2
+      - uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: ${{matrix.rust}}
+      - run: cargo check --no-default-features
+      - run: cargo check --features backtrace
         if: matrix.rust != '1.50.0'
 
   backtrace:
diff --git a/src/lib.rs b/src/lib.rs
index b227eef..9be302b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -622,21 +622,21 @@ pub mod private {
 
     #[doc(hidden)]
     #[cold]
-    pub fn format_err<M>(message: M, args: Arguments) -> Error
+    pub fn format_err<M>(_message: M, args: Arguments) -> Error
     where
         M: Display + Debug + Send + Sync + 'static,
     {
         #[cfg(anyhow_no_fmt_arguments_as_str)]
-        let has_interpolated_format_args = false;
+        let fmt_arguments_as_str = Some(_message);
         #[cfg(not(anyhow_no_fmt_arguments_as_str))]
-        let has_interpolated_format_args = args.as_str().is_none();
+        let fmt_arguments_as_str = args.as_str();
 
-        if has_interpolated_format_args {
-            // anyhow!("interpolate {var}"), can downcast to String
-            Error::msg(fmt::format(args))
-        } else {
+        if let Some(message) = fmt_arguments_as_str {
             // anyhow!("literal"), can downcast to &'static str
             Error::msg(message)
+        } else {
+            // anyhow!("interpolate {var}"), can downcast to String
+            Error::msg(fmt::format(args))
         }
     }
 }


Test patch:
diff --git a/tests/test_macros.rs b/tests/test_macros.rs
index b08db97..4cbb580 100644
--- a/tests/test_macros.rs
+++ b/tests/test_macros.rs
@@ -56,3 +56,9 @@ fn test_temporaries() {
         future::ready(anyhow!("...")).await;
     });
 }
+
+#[test]
+fn test_brace_escape() {
+    let err = anyhow!("unterminated ${{..}} expression");
+    assert_eq!("unterminated ${..} expression", err.to_string());
+}
Repository: dtolnay/anyhow
Pull request #390 (2024-11-01 05:34:31)

Add support for raw addr syntax
https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#native-syntax-for-creating-a-raw-pointer


Patch:
diff --git a/src/ensure.rs b/src/ensure.rs
index 9d0a676..795757d 100644
--- a/src/ensure.rs
+++ b/src/ensure.rs
@@ -155,6 +155,14 @@ macro_rules! __parse_ensure {
         $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and $mut) $($parse)*} ($($rest)*) $($rest)*)
     };
 
+    (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $raw:tt $mut:tt $($dup:tt)*) &raw mut $($rest:tt)*) => {
+        $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and $raw $mut) $($parse)*} ($($rest)*) $($rest)*)
+    };
+
+    (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $raw:tt $const:tt $($dup:tt)*) &raw const $($rest:tt)*) => {
+        $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and $raw $const) $($parse)*} ($($rest)*) $($rest)*)
+    };
+
     (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) & $($rest:tt)*) => {
         $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*)
     };
@@ -163,6 +171,14 @@ macro_rules! __parse_ensure {
         $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand $mut) $($parse)*} ($($rest)*) $($rest)*)
     };
 
+    (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $raw:tt $mut:tt $($dup:tt)*) &&raw mut $($rest:tt)*) => {
+        $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand $raw $mut) $($parse)*} ($($rest)*) $($rest)*)
+    };
+
+    (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $raw:tt $const:tt $($dup:tt)*) &&raw const $($rest:tt)*) => {
+        $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand $raw $const) $($parse)*} ($($rest)*) $($rest)*)
+    };
+
     (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $($dup:tt)*) && $($rest:tt)*) => {
         $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand) $($parse)*} ($($rest)*) $($rest)*)
     };


Test patch:
diff --git a/tests/test_ensure.rs b/tests/test_ensure.rs
index f41ad37..b43490a 100644
--- a/tests/test_ensure.rs
+++ b/tests/test_ensure.rs
@@ -186,6 +186,17 @@ fn test_unary() {
     assert_err(test, "Condition failed: `&mut x == *&&mut &2` (1 vs 2)");
 }
 
+#[rustversion::since(1.82)]
+#[test]
+fn test_raw_addr() {
+    let mut x = 1;
+    let test = || Ok(ensure!(S + &raw const x != S + &raw mut x));
+    assert_err(
+        test,
+        "Condition failed: `S + &raw const x != S + &raw mut x` (false vs false)",
+    );
+}
+
 #[test]
 fn test_if() {
     #[rustfmt::skip]
Repository: dtolnay/async-trait
Pull request #124 (2020-08-30 04:01:04)

Fix HasSelf visitor to visit Self keyword inside macro invocations
Addresses https://github.com/dtolnay/async-trait/issues/92#issuecomment-683370136, see https://github.com/dtolnay/async-trait/issues/92#issuecomment-683372182 for details.


Patch:
diff --git a/src/receiver.rs b/src/receiver.rs
index 1e9e397..4273359 100644
--- a/src/receiver.rs
+++ b/src/receiver.rs
@@ -29,6 +29,14 @@ pub fn has_self_in_block(block: &mut Block) -> bool {
     visitor.0
 }
 
+fn has_self_in_token_stream(tokens: TokenStream) -> bool {
+    tokens.into_iter().any(|tt| match tt {
+        TokenTree::Ident(ident) => ident == "Self",
+        TokenTree::Group(group) => has_self_in_token_stream(group.stream()),
+        _ => false,
+    })
+}
+
 struct HasSelf(bool);
 
 impl VisitMut for HasSelf {
@@ -54,6 +62,12 @@ impl VisitMut for HasSelf {
     fn visit_item_mut(&mut self, _: &mut Item) {
         // Do not recurse into nested items.
     }
+
+    fn visit_macro_mut(&mut self, mac: &mut Macro) {
+        if !contains_fn(mac.tokens.clone()) {
+            self.0 |= has_self_in_token_stream(mac.tokens.clone());
+        }
+    }
 }
 
 pub struct ReplaceReceiver {
@@ -278,14 +292,14 @@ impl VisitMut for ReplaceReceiver {
         }
     }
 
-    fn visit_macro_mut(&mut self, i: &mut Macro) {
+    fn visit_macro_mut(&mut self, mac: &mut Macro) {
         // We can't tell in general whether `self` inside a macro invocation
         // refers to the self in the argument list or a different self
         // introduced within the macro. Heuristic: if the macro input contains
         // `fn`, then `self` is more likely to refer to something other than the
         // outer function's self argument.
-        if !contains_fn(i.tokens.clone()) {
-            self.visit_token_stream(&mut i.tokens);
+        if !contains_fn(mac.tokens.clone()) {
+            self.visit_token_stream(&mut mac.tokens);
         }
     }
 }


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 5225c51..2d8b75b 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -883,6 +883,35 @@ pub mod issue92 {
     }
 }
 
+// https://github.com/dtolnay/async-trait/issues/92#issuecomment-683370136
+pub mod issue92_2 {
+    use async_trait::async_trait;
+
+    macro_rules! mac {
+        ($($tt:tt)*) => {
+            $($tt)*
+        };
+    }
+
+    pub trait Trait1 {
+        fn func1();
+    }
+
+    #[async_trait]
+    pub trait Trait2: Trait1 {
+        async fn func2() {
+            mac!(Self::func1());
+
+            macro_rules! mac2 {
+                ($($tt:tt)*) => {
+                    Self::func1();
+                };
+            }
+            mac2!();
+        }
+    }
+}
+
 // https://github.com/dtolnay/async-trait/issues/104
 pub mod issue104 {
     use async_trait::async_trait;