Repository: diesel-rs/diesel (language: rust)

Issue:
Macro define_sql_function imposes diesel as direct dependency
<!--
If you want to report a bug, we added some points below which help us track down the problem faster.
-->

## Setup

### Versions

- **Rust:**
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7
- **Diesel:** b170af753c
- **Database:** N/A
- **Operating System** N/A

### Feature Flags

- **diesel:** N/A

## Problem Description
Use of `::diesel` in procedural macro `define_sql_function` forces to diesel as direct dependency instead of simply in scope, which is bothersome when diesel is re-exported.

### What are you trying to accomplish?
Use macro `define_sql_function` without having diesel as direct dependency

### What is the expected output?
Code compiles

### What is the actual output?
```
error[E0433]: failed to resolve: could not find `diesel` in the list of imported crates
  --> /home/elrendio/Stockly/Main/operations/Service/src/supply/Suppliers/src/auto_block/high_at_submission_price_changes.rs:95:4
   |
95 | /             diesel::define_sql_function! {
96 | |                 fn greatest(a: Nullable<Timestamptz>, b: Nullable<Timestamptz>, c: Timestamptz) -> Timestamptz;
97 | |             }
   | |_____________^ could not find `diesel` in the list of imported crates
   |
   = note: this error originates in the macro `diesel::define_sql_function` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module

```

### Are you seeing any additional errors?
 /

### Steps to reproduce

1. Create a crate that re-exports diesel, let's call it diesel_helpers
2. Create a second crate with dependency `diesel_helpers`, let's call it diesel_consumer
3. In crate diesel_consumer, use diesel_helpers::diesel::define_sql_function

## Checklist

- [x] I have already looked over the [issue tracker](https://github.com/diesel-rs/diesel/issues) and the [discussion forum](https://github.com/diesel-rs/diesel/discussions) for similar possible closed issues.
- [x] This issue can be reproduced on Rust's stable channel. (Your issue will be
  closed if this is not the case)
- [x] This issue can be reproduced without requiring a third party crate



Discussion / hints:

Fix patch:
diff --git a/diesel_derives/src/sql_function.rs b/diesel_derives/src/sql_function.rs
index 1f76d9d9adfd..c35a3fe95930 100644
--- a/diesel_derives/src/sql_function.rs
+++ b/diesel_derives/src/sql_function.rs
@@ -405,7 +405,7 @@ pub(crate) fn expand(input: SqlFunctionDecl, legacy_helper_type_and_module: bool
                     #[doc = #helper_type_doc]
                     pub type #fn_name #ty_generics = #internals_module_name::#fn_name <
                         #(#type_args,)*
-                        #(<#arg_name as ::diesel::expression::AsExpression<#arg_type>>::Expression,)*
+                        #(<#arg_name as diesel::expression::AsExpression<#arg_type>>::Expression,)*
                     >;
                 }),
                 quote! { #fn_name },
@@ -419,7 +419,7 @@ pub(crate) fn expand(input: SqlFunctionDecl, legacy_helper_type_and_module: bool
         pub #fn_token #fn_name #impl_generics (#(#args_iter,)*)
             -> #return_type_path #ty_generics
         #where_clause
-            #(#arg_name: ::diesel::expression::AsExpression<#arg_type>,)*
+            #(#arg_name: diesel::expression::AsExpression<#arg_type>,)*
         {
             #internals_module_name::#fn_name {
                 #(#arg_struct_assign,)*


Test patch: