Deref coercion doesn't happen in this particular case when using `?` operator.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Problem
In the following line, set_not_after function expects a &openssl::asn1::Asn1TimeRef, and openssl::asn1::Asn1Time implements Deref<Target = Asn1TimeRef>.
x509.set_not_after(&openssl::asn1::Asn1Time::days_from_now(10)?)?;
But the line results in the following error.
error[E0308]: `?` operator has incompatible types
--> src\main.rs:119:25
|
119 | x509.set_not_after(&openssl::asn1::Asn1Time::days_from_now(10)?)?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Asn1TimeRef`, found `Asn1Time`
|
= note: `?` operator cannot convert from `Asn1Time` to `Asn1TimeRef`
Whereas the following lines work perfectly fine.
x509.set_not_after(&*openssl::asn1::Asn1Time::days_from_now(10)?)?;
x509.set_not_after(&&openssl::asn1::Asn1Time::days_from_now(10)?)?;
x509.set_not_after(&openssl::asn1::Asn1Time::days_from_now(10)?.deref())?;
x509.set_not_after(&openssl::asn1::Asn1Time::days_from_now(10).unwrap())?;
Steps
- Add
opensslcrate to your package. - Try to create an instance of
openssl::x509::X509Builder. - Use any of its functions (e.g.
set_not_after). - Run the command
cargo check.
This issue should be replicable without openssl crate too but I could not find a way.
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.90.0 (840b83a10 2025-07-30)
release: 1.90.0
commit-hash: 840b83a10fb0e039a83f4d70ad032892c287570a
commit-date: 2025-07-30
host: x86_64-pc-windows-msvc
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.14.1-DEV (sys:0.4.82+curl-8.14.1 vendored ssl:Schannel)
os: Windows 10.0.26100 (Windows 11 CoreSingleLanguage) [64-bit]
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 with the minimal reproduction using the openssl example and run cargo check, comparing the four expression forms shown in the report. Read the compiler behavior around the ? operator and deref coercion, then establish whether the result is expected or identify the compiler change and regression test needed.
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
- 35/100