{"record":{"id":"2ee6f62c92039462","repo":"diesel-rs/diesel","slug":"warning-message-help-help","errorCode":null,"errorMessage":"warning: {message}\n  = help: {help}\n","messagePattern":"warning: (.+?)\n  = help: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"diesel_attribute_parser/src/deprecated/mod.rs","lineNumber":218,"sourceCode":"                    );\n                    Ok(Some(FieldAttr::ColumnName(name, lit_str.parse()?)))\n                }\n                \"sql_type\" => {\n                    let lit_str = parse_eq_and_lit_str(name.clone(), input, SQL_TYPE_NOTE)?;\n                    warn!(\n                        name,\n                        &format!(\"use `#[diesel(sql_type = {})]` instead\", lit_str.value())\n                    );\n                    Ok(Some(FieldAttr::SqlType(name, lit_str.parse()?)))\n                }\n\n                _ => Ok(None),\n            }\n        }\n    }\n\n    #[cfg(feature = \"nightly\")]\n    fn warn(span: Span, message: &str, help: &str) {\n        proc_macro::Diagnostic::spanned(span.unwrap(), proc_macro::Level::Warning, message)\n            .help(help)\n            .emit()\n    }\n\n    #[cfg(not(feature = \"nightly\"))]\n    fn warn(_span: Span, message: &str, help: &str) {\n        eprintln!(\"warning: {message}\\n  = help: {help}\\n\");\n    }\n}\n","sourceCodeStart":200,"sourceCodeEnd":229,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_attribute_parser/src/deprecated/mod.rs#L200-L229","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n#[belongs_to(User, foreign_key = \"author_id\")]\npub struct Post;\n// after\n#[diesel(belongs_to(User, foreign_key = author_id))]\npub struct Post;","handlingStrategy":"validation","validationCode":"// nightly: catch these diagnostics as hard errors so they get fixed immediately\n// add to crate root:\n// #![feature(proc_macro_diagnostic)] — tool-level; simpler CI guard:\ngrep -rnE '#\\[(table_name|column_name|primary_key|belongs_to) *=' src/ \\\n  && echo 'deprecated diesel attribute (would emit warning)' && exit 1 || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","diesel","deprecation","proc-macro","diagnostics"],"backgroundTag":"deprecated-api-usage","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}