Fix diesel_derives compilation with syn 2.0 #4777
Open
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
diesel_derivescrate fails to compile with newer versions ofsyndue to missing theparsingfeature. Therequire_ident()method is gated behind theparsingfeature flag insyn2.0, butdiesel_deriveswas not enabling this feature.Root Cause Analysis
The issue occurs because:
Diesel enables
with-deprecatedby default: Indiesel/Cargo.toml, the default features includewith-deprecated:with-deprecatedenablessql_functioncode: Thesql_function_proc_innerfunction (which usesrequire_ident()) is gated behind thewith-deprecatedfeature:Any crate depending on Diesel triggers the issue: When
diesel-derive-enumor other crates depend on Diesel, they automatically get thewith-deprecatedfeature enabled, which triggers compilation of thesql_functioncode.Why Tests Weren't Failing
The
diesel_derivestests weren't failing because:diesel_derivesdoesn't enablewith-deprecatedby default (itsCargo.tomlshowsdefault = [])sql_functioncode is only compiled whenwith-deprecatedis explicitly enabledsql_functionfunctionality unless that feature is enabledSolution
Add the
parsingfeature to thesyndependency indiesel_derives/Cargo.toml.Changes
syndependency features from["derive", "fold", "full"]to["derive", "fold", "full", "parsing"]Testing
This fix resolves compilation errors when using
diesel_deriveswith the latest version ofsynand enables the use of the latest Diesel version (2.3.2) withdiesel-derive-enumand other crates that depend ondiesel_derives.Verification
diesel-derive-enumnow compiles successfully with Diesel 2.3.2diesel-derive-enumcontinues to work as beforeFixes compatibility issues with:
diesel-derive-enumdiesel_derivessynanddieselImpact
This is a low-risk change that:
synsynversion