about summary refs log tree commit diff
path: root/tests/ui/impl-trait/precise-capturing/external-macro.rs
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2024-11-15 10:06:53 -0800
committerEric Huss <eric@huss.org>2024-11-15 10:06:53 -0800
commit03e2828e8876e9c2d2ec9238d9cdce82e7b93798 (patch)
tree8cce42e5ac8e5c3e37207e9c497acf25fcd4ed0e /tests/ui/impl-trait/precise-capturing/external-macro.rs
parentd163541022248c12f166a2606cb3295986540318 (diff)
downloadrust-03e2828e8876e9c2d2ec9238d9cdce82e7b93798.tar.gz
rust-03e2828e8876e9c2d2ec9238d9cdce82e7b93798.zip
Fix span edition for 2024 RPIT coming from an external macro
This fixes a problem where code generated by an external macro with an
RPIT would end up using the call-site edition instead of the macro's
edition for the RPIT. When used from a 2024 crate, this caused the code
to change behavior to the 2024 capturing rules, which we don't want.

This was caused by the impl-trait lowering code would replace the span
with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it
was also overriding the edition of the span with the edition of the
local crate. Instead it should be using the edition of the span itself.

Fixes https://github.com/rust-lang/rust/issues/132917
Diffstat (limited to 'tests/ui/impl-trait/precise-capturing/external-macro.rs')
-rw-r--r--tests/ui/impl-trait/precise-capturing/external-macro.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/ui/impl-trait/precise-capturing/external-macro.rs b/tests/ui/impl-trait/precise-capturing/external-macro.rs
index 72f72bc7b05..492e8036461 100644
--- a/tests/ui/impl-trait/precise-capturing/external-macro.rs
+++ b/tests/ui/impl-trait/precise-capturing/external-macro.rs
@@ -6,12 +6,11 @@
 //@ aux-crate: no_use_macro=no-use-macro.rs
 //@ edition: 2024
 //@ compile-flags:-Z unstable-options
+//@ check-pass
 
 no_use_pm::pm_rpit!{}
-//~^ ERROR: cannot borrow `x` as mutable
 
 no_use_macro::macro_rpit!{}
-//~^ ERROR: cannot borrow `x` as mutable
 
 fn main() {
     let mut x = vec![];
@@ -19,11 +18,9 @@ fn main() {
 
     let element = test_pm(&x);
     x.push(2);
-    //~^ ERROR: cannot borrow `x` as mutable
     println!("{element}");
 
     let element = test_mbe(&x);
     x.push(2);
-    //~^ ERROR: cannot borrow `x` as mutable
     println!("{element}");
 }