`mismatched_lifetime_syntaxes` suggests a machine-applicable edit that breaks shared macro invocations
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 43/100
Hướng nghiên cứu
Start by reading the mismatched_lifetime_syntaxes lint implementation and its diagnostic tests; the issue does not name specific files. Reproduce the provided macro example and inspect how suggestions are emitted for multiple invocations. Done means the lint still warns but no longer marks an edit as machine-applicable when applying it breaks another invocation.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue description
I found bug in Rust’s mismatched_lifetime_syntaxes lint. When 2 functions use the same macro in their return types, one with 'a and the other with 'b, the compiler suggests adding each lifetime at the same place in the macro definition and marks both edits MachineApplicable. Applying either automatic edit makes the other function fail with E0261 because the inserted lifetime name is out of scope there. I reproduced this on Rust 1.100.0 and Rust 1.102.0-nightly (6c709eb42), and cannot find a matching issue or PR yet.
Code
#![allow(dead_code)]
struct Wrap<'a>(&'a u8);
macro_rules! out {
() => {
Wrap
};
}
fn first<'a>(x: &'a u8) -> out!() {
Wrap(x)
}
fn second<'b>(x: &'b u8) -> out!() {
Wrap(x)
}
Current output
Compiler output from Rust 1.102.0-nightly:
warning: hiding a lifetime that's named elsewhere is confusing
help: consistently use `'a`
7 | Wrap<'a>
| ++++
warning: hiding a lifetime that's named elsewhere is confusing
help: consistently use `'b`
7 | Wrap<'b>
| ++++
error[E0261]: use of undeclared lifetime name `'a`
7 | Wrap<'a>
| ^^ undeclared lifetime
...
15 | fn second<'b>(x: &'b u8) -> out!() {
| ------ in this macro invocation
Test observation: Applying the 'a suggestion at line 7, column 13 (MachineApplicable) produces the E0261 error shown above.
Rust Version
rustc 1.102.0-nightly (6c709eb42 2026-11-25)
binary: rustc
commit-hash: 6c709eb428d472a3c3d93681c1ba37d44a1c27cf
commit-date: 2026-11-25
host: aarch64-apple-darwin
release: 1.102.0-nightly
LLVM version: 23.1.6
Desired output
The lint should continue warning about the inconsistent lifetime syntax, but avoid suggesting an automatic edit that breaks another macro invocation.
AI assistance
I used AI assistance to help discover and verify this bug. I independently reproduced it on the listed Rust versions before filing.
- Ngôn ngữ chính
- Rust
- Star
- 123k
- Fork
- 16.6k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 532
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rust
-
strictly_dominates missing a `=`Đang mởC-bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rust-lang/rust#166722 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-run-make C-bug T-bootstrap
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Đang mởrelnotes relnotes-tracking-issue T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rust
Issue tương tự
-
bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows microphone listing treats words in a device name as DirectShow labelsCó thể đã có người làm @Sujal-chaudhary đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clipy-recorder/clipy#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
nightly-cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
max-sixty/worktrunk#4939 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Flaky Test] tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occursĐang mởflaky
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
stacks-network/stacks-core#7918 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày