mongodb / mongo-rust-driver

The official MongoDB Rust Driver
https://www.mongodb.com/docs/drivers/rust/current/
Apache License 2.0
1.44k stars 164 forks source link

[Bug] Fail to compile due to upstream `trust_dns_proto` crate. #1182

Closed Embers-of-the-Fire closed 3 months ago

Embers-of-the-Fire commented 3 months ago

Versions/Environment

  1. What version of Rust are you using? Tested with stable, nightly(yesterday, 5/8/2024) and 1.78.0
  2. What operating system are you using? x86_64 MSVC Windows11
  3. What versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson) mongodb: registry+https://github.com/rust-lang/crates.io-index#mongodb@3.0.1 bson: registry+https://github.com/rust-lang/crates.io-index#bson@2.11.0
  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version()) 7.0.12
  5. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)? standalone

Describe the bug

This seems like some weird upstream crate related bug.

❯ cargo build
   Compiling tokio-rustls v0.24.1
   Compiling trust-dns-proto v0.21.2
   Compiling bson v2.11.0
error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
  --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:18:1
   |
18 | / lazy_static! {
19 | |     /// Default Name usage, everything is normal...
20 | |     pub static ref DEFAULT: ZoneUsage = ZoneUsage::default();
21 | | }
   | |_^ lifetimes do not match type in trait
   |
   = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
  --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:23:1
   |
23 | / lazy_static! {
24 | |     static ref ARPA: Name = Name::from_ascii("arpa.").unwrap();
25 | |     /// zone for ipv4 reverse addresses
26 | |     pub static ref IN_ADDR_ARPA: Name = Name::from_ascii("in-addr").unwrap().append_domain(&*ARPA).unwrap();
27 | |     /// zone for ipv6 reverse addresses
28 | |     pub static ref IP6_ARPA: Name = Name::from_ascii("ip6").unwrap().append_domain(&*ARPA).unwrap();
29 | | }
   | |_^ lifetimes do not match type in trait
   |
   = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
  --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:31:1
   |
31 | / lazy_static! {
32 | |     /// localhost.
33 | |     ///
34 | |     /// [Special-Use Domain Names](https://tools.ietf.org/html/rfc6761), RFC 6761 February, 2013
...  |
50 | |     pub static ref IP6_ARPA_1: ZoneUsage = ZoneUsage::localhost(Name::from_ascii("1.0.0.0.0.0.0.0.0.0.0.0.0.0...
51 | | }
   | |_^ lifetimes do not match type in trait
   |
   = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
  --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:53:1
   |
53 | / lazy_static! {
54 | |     /// .local.
55 | |     ///
56 | |     /// [Multicast DNS](https://tools.ietf.org/html/rfc6762), RFC 6762  February 2013
...  |
94 | |     pub static ref IP6_ARPA_FE_B: ZoneUsage = ZoneUsage::local(Name::from_ascii("b.e.f").unwrap().append_doma...
95 | | }
   | |_^ lifetimes do not match type in trait
   |
   = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
   --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:97:1
    |
97  | / lazy_static! {
98  | |     /// invalid.
99  | |     ///
100 | |     /// [Special-Use Domain Names](https://tools.ietf.org/html/rfc6761), RFC 6761 February, 2013
...   |
112 | |     pub static ref INVALID: ZoneUsage = ZoneUsage::invalid(Name::from_ascii("invalid.").unwrap());
113 | | }
    | |_^ lifetimes do not match type in trait
    |
    = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
   --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:115:1
    |
115 | / lazy_static! {
116 | |     /// invalid.
117 | |     ///
118 | |     /// [The ".onion" Special-Use Domain Name](https://tools.ietf.org/html/rfc7686), RFC 7686 October, 2015
...   |
136 | |     };
137 | | }
    | |_^ lifetimes do not match type in trait
    |
    = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0195]: lifetime parameters or bounds on type `Target` do not match the trait declaration
  --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\rdata\sshfp.rs:20:1
   |
20 | / lazy_static! {
21 | |     /// HEX formatting specific to TLSA and SSHFP encodings
22 | |     pub static ref HEX: Encoding = {
23 | |         let mut spec = Specification::new();
...  |
29 | |     };
30 | | }
   | |_^ lifetimes do not match type in trait
   |
   = note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `zone_of` found for struct `LOCALHOST` in the current scope
   --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\name.rs:829:25
    |
829 |           LOCALHOST_usage.zone_of(self)
    |                           ^^^^^^^ method not found in `LOCALHOST`
    |
   ::: D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\domain\usage.rs:31:1
    |
31  | / lazy_static! {
32  | |     /// localhost.
33  | |     ///
34  | |     /// [Special-Use Domain Names](https://tools.ietf.org/html/rfc6761), RFC 6761 February, 2013
...   |
50  | |     pub static ref IP6_ARPA_1: ZoneUsage = ZoneUsage::localhost(Name::from_ascii("1.0.0.0.0.0.0.0.0.0.0.0.0....
51  | | }
    | |_- method `zone_of` not found for this struct

error[E0599]: no method named `encode` found for struct `HEX` in the current scope
   --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\rdata\sshfp.rs:273:31
    |
20  | / lazy_static! {
21  | |     /// HEX formatting specific to TLSA and SSHFP encodings
22  | |     pub static ref HEX: Encoding = {
23  | |         let mut spec = Specification::new();
...   |
29  | |     };
30  | | }
    | |_- method `encode` not found for this struct
...
273 |               fingerprint = HEX.encode(&self.fingerprint),
    |                                 ^^^^^^ method not found in `HEX`

error[E0599]: no method named `encode` found for struct `HEX` in the current scope
   --> D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\rdata\tlsa.rs:439:31
    |
439 |               cert = sshfp::HEX.encode(&self.cert_data),
    |                                 ^^^^^^ method not found in `HEX`
    |
   ::: D:\Rust\.cargo\registry\src\mirrors.ustc.edu.cn-4affec411d11e50f\trust-dns-proto-0.21.2\src\rr\rdata\sshfp.rs:20:1
    |
20  | / lazy_static! {
21  | |     /// HEX formatting specific to TLSA and SSHFP encodings
22  | |     pub static ref HEX: Encoding = {
23  | |         let mut spec = Specification::new();
...   |
29  | |     };
30  | | }
    | |_- method `encode` not found for this struct

Some errors have detailed explanations: E0195, E0599.
For more information about an error, try `rustc --explain E0195`.
error: could not compile `trust-dns-proto` (lib) due to 18 previous errors
warning: build failed, waiting for other jobs to finish...

Note: this is not because of mirror registry, i have tested it with registry=crates-io.

However, when compiling trust-dns-proto = "~0.21.2" then no error is reported.

To Reproduce

  1. Add mongodb = "3.0.1" to your dependencies.
  2. Run cargo build
Embers-of-the-Fire commented 3 months ago

Update: It cannot be ruled out that it is an issue with lazy_static library. I will temporarily close it until I confirm that it is a problem with MongoDB.