rust-lang / docs.rs

crates.io documentation generator
https://docs.rs
MIT License
956 stars 193 forks source link

Docs.rs does not compile on nightly since nightly-2024-04-05 #2488

Open dtolnay opened 2 months ago

dtolnay commented 2 months ago

This is to let you know that docs.rs is impacted by https://github.com/rust-lang/rust/pull/119820, which is an upcoming intentional breaking change in Rust 1.79. There will need to be some code changes in docs.rs before updating to Rust 1.79.

$ cargo +nightly-2024-04-05 check

error: lifetime may not live long enough
  --> src/db/types.rs:4:66
   |
4  | #[derive(Debug, Clone, PartialEq, Eq, Serialize, FromSql, ToSql, sqlx::Type)]
   |                                                                  ^^^^^^^^^^
   |                                                                  |
   |                                                                  lifetime `'r` defined here
   |                                                                  requires that `'r` must outlive `'static`
   |
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-postgres-0.7.4/src/types/record.rs:97:12
   |
97 |         T: for<'a> Decode<'a, Postgres> + Type<Postgres>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)

error: implementation of `sqlx::Decode` is not general enough
 --> src/db/types.rs:4:66
  |
4 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, FromSql, ToSql, sqlx::Type)]
  |                                                                  ^^^^^^^^^^ implementation of `sqlx::Decode` is not general enough
  |
  = note: `std::string::String` must implement `sqlx::Decode<'0, Postgres>`, for any lifetime `'0`...
  = note: ...but it actually implements `sqlx::Decode<'1, Postgres>`, for some specific lifetime `'1`
  = note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)

error: implementation of `sqlx::Decode` is not general enough
 --> src/db/types.rs:4:66
  |
4 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, FromSql, ToSql, sqlx::Type)]
  |                                                                  ^^^^^^^^^^ implementation of `sqlx::Decode` is not general enough
  |
  = note: `Vec<std::string::String>` must implement `sqlx::Decode<'0, Postgres>`, for any lifetime `'0`...
  = note: ...but it actually implements `sqlx::Decode<'1, Postgres>`, for some specific lifetime `'1`
  = note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)

https://gist.github.com/lcnr/7c1c652f30567048ea240554a36ed95c#httpsgithubcomlaunchbadgesqlx-some-derives-of-sqlxtype has an analysis of how sqlx is involved.

syphar commented 2 months ago

thanks for the ping!

It sounds like we just have to wait for the sqlx release, which I assume would happen before the new stable release?

dtolnay commented 2 months ago

I'm not sure about that. I tried building docs.rs with this change in Cargo.toml:

@@ -40,7 +40,7 @@ semver = { version = "1.0.4", features = ["serde"] }
 r2d2 = "0.8"
 r2d2_postgres = "0.18"
-sqlx = { version = "0.7", features = [ "runtime-tokio", "postgres", "chrono" ] }
+sqlx = { version = "0.8.0-alpha.0", features = [ "runtime-tokio", "postgres", "chrono" ] }
 url = { version = "2.1.1", features = ["serde"] }
 docsrs-metadata = { path = "crates/metadata" }
@@ -68,7 +68,7 @@ zip = {version = "0.6.2", default-features = false, features = ["bzip2"]}
 getrandom = "0.2.1"
 itertools = { version = "0.12.0", optional = true}
-rusqlite = { version = "0.30.0", features = ["bundled"] }
+rusqlite = { version = "0.31.0", features = ["bundled"] }
 hex = "0.4.3"

@@ -154,3 +154,6 @@ harness = false
 name = "cratesfyi"
 test = false
 doc = false
+
+[patch.crates-io]
+sqlx = { git = "https://github.com/launchbadge/sqlx" }

and while there are a few "mismatched types" errors in unrelated code from various breaking changes in those crates, I am still seeing all 3 of the original errors above related to sqlx::Type. So there may be more digging for you or @lcnr to do.

lcnr commented 2 months ago

I'll look into this 👍

lcnr commented 2 months ago

It sounds like we just have to wait for the sqlx release, which I assume would happen before the new stable release?

actually no, I messed up while looking at the regression. THis still requires a change to sqlx. Will open a PR and potentially delay the breaking change in rustc by one version to give users more time to update

syphar commented 2 weeks ago

@lcnr is there any update to this?

lcnr commented 2 weeks ago

https://github.com/launchbadge/sqlx/issues/3185 has been fixed in sqlx now, so docs.rs should now be fixed once it uses the new version. The breaking change has been delayed by atleast one version, so docs.rs should still only be affected on beta (the new beta) and nightly for now.