diesel-rs/diesel · warning
warning: = help
Error message
warning: {message}
= help: {help}
What it means
This is the `warn` helper in diesel's deprecated-attribute parser that actually emits the deprecation warning. On nightly compilers with the `nightly` feature it builds a `proc_macro::Diagnostic` spanned at the offending attribute, attaches the help text via `.help()`, and `.emit()`s it, producing output like `warning: #[table_name] attribute form is deprecated\n = help: ...`. The message field is the format template `"warning: {message}\n = help: {help}\n"` used by the non-nightly fallback path (which prints to stderr instead). It is purely informational.
Solutions
- Fix the underlying deprecated attribute usage (see the `= help:` line for the replacement, e.g. `#[table_name = "x"]` → `#[diesel(table_name = x)]`)
- The warning itself needs no fix — treat it as a pointer to code to migrate; warnings do not block compilation
- If warnings must not appear in CI, either migrate the attributes or allow/ignore deprecated diagnostics in the lint configuration
- On stable toolchains the non-nightly fallback prints the same text to stderr; switching toolchains does not remove it — only fixing the attribute does
Example fix
// before #[belongs_to(User, foreign_key = "author_id")] pub struct Post; // after #[diesel(belongs_to(User, foreign_key = author_id))] pub struct Post;
Defensive patterns
Strategy: validation
Validate before calling
// nightly: catch these diagnostics as hard errors so they get fixed immediately // add to crate root: // #![feature(proc_macro_diagnostic)] — tool-level; simpler CI guard: grep -rnE '#\[(table_name|column_name|primary_key|belongs_to) *=' src/ \ && echo 'deprecated diesel attribute (would emit warning)' && exit 1 || true
Prevention
- Treat the emitted `warning: ... = help: ...` text as an instruction: apply the exact replacement shown in the help line
- Migrate deprecated attributes promptly so nightly diagnostics do not accumulate in build logs
- Avoid enabling the `nightly` feature in production builds if diagnostic noise matters; stable emits the same text via the stderr fallback
- Pin a diesel version and read its CHANGELOG for attribute-syntax deprecations before upgrading
When it happens
Trigger: Compiling on a nightly toolchain with diesel's `nightly` feature enabled while a derive uses a deprecated (un-namespaced) attribute form — the parser's `_ =>` catch-all calls `warn!(ident, help)` which routes here. Also triggered whenever any deprecation check (table_name, primary_key, belongs_to, column_name, etc.) rejects an attribute.
Common situations: Nightly-only projects using `#![feature(proc_macro_diagnostic)]`-backed warnings; CI on nightly where these diagnostics appear in build logs and are mistaken for errors; teams migrating diesel 1.x attribute syntax seeing a burst of these warnings.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- #[ ] attribute form is deprecated
- expected attribute `name` help: the correct format looks…
- unknown attribute, expected
- unexpected end of input, expected `=` help: the correct…
- expected type
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/2ee6f62c92039462.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_attribute_parser/src/deprecated/mod.rs:218
);
Ok(Some(FieldAttr::ColumnName(name, lit_str.parse()?)))
}
"sql_type" => {
let lit_str = parse_eq_and_lit_str(name.clone(), input, SQL_TYPE_NOTE)?;
warn!(
name,
&format!("use `#[diesel(sql_type = {})]` instead", lit_str.value())
);
Ok(Some(FieldAttr::SqlType(name, lit_str.parse()?)))
}
_ => Ok(None),
}
}
}
#[cfg(feature = "nightly")]
fn warn(span: Span, message: &str, help: &str) {
proc_macro::Diagnostic::spanned(span.unwrap(), proc_macro::Level::Warning, message)
.help(help)
.emit()
}
#[cfg(not(feature = "nightly"))]
fn warn(_span: Span, message: &str, help: &str) {
eprintln!("warning: {message}\n = help: {help}\n");
}
}
View on GitHub (pinned to 6fa6ed01b2)