suggest broken template code
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
pub type AM<T> = Arc<Mutex<T>>;
pub trait ArcMutexTrait<T> {
fn n(t: T) -> AM<T> { Arc::new(Mutex::new(t)) }
fn get(&self) -> T { self.clone().lock().unwrap() }
}
impl<T> ArcMutexTrait<T> for AM<T> {}
Current output
error[E0599]: no method named `lock` found for reference `&Self` in the current scope
--> src/common.rs:8:39
|
8 | fn get(&self) -> T { self.clone().lock().unwrap() }
| ^^^^ method not found in `&Self`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `lock`, perhaps you need to add a supertrait for it:
|
6 | pub trait ArcMutexTrait: lock_api::mutex::RawMutex<T> {
| +++++++++++++++++++++++++++
Desired output
something compilable.
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: aarch64-apple-darwin
release: 1.84.0
LLVM version: 19.1.5
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Rust snippet with rustc 1.84.0 and inspect the compiler's suggested fix for the missing lock method. Determine what compilable suggestion is expected; done means the diagnostic no longer recommends invalid template code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100