ruff_python_formatter: copy and inline shared traits (#8656)

It seems as though using `include!(...)` to avoid the source code copy
breaks rust-analzer. Namely, it treats the included file as unlinked,
and so any part of analysis (e.g., goto-definition) that needs that file
to reason about the code ends up failing.

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
This commit is contained in:
Andrew Gallant 2023-11-13 12:16:04 -05:00 committed by GitHub
parent 6a6de53722
commit 8984072df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 115 additions and 2 deletions

View file

@ -16,6 +16,7 @@ use crate::comments::{
};
pub use crate::context::PyFormatContext;
pub use crate::options::{MagicTrailingComma, PreviewMode, PyFormatOptions, QuoteStyle};
pub use crate::shared_traits::{AsFormat, FormattedIter, FormattedIterExt, IntoFormat};
use crate::verbatim::suppressed_node;
pub(crate) mod builders;
@ -29,12 +30,11 @@ mod options;
pub(crate) mod other;
pub(crate) mod pattern;
mod prelude;
mod shared_traits;
pub(crate) mod statement;
pub(crate) mod type_param;
mod verbatim;
include!("../../ruff_formatter/shared_traits.rs");
/// 'ast is the lifetime of the source code (input), 'buf is the lifetime of the buffer (output)
pub(crate) type PyFormatter<'ast, 'buf> = Formatter<'buf, PyFormatContext<'ast>>;