Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group imports by their visibilities #5767

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kafji
Copy link

@kafji kafji commented May 15, 2023

Hi. This is a patch for feature request #5696 and #4070.

This patch adds another variant, Visiblity to group_imports that turn

Unordered:

pub(super) use chrono::Utc;
pub use super::update::convert_publish_payload;

pub(crate) use juniper::{FieldError, FieldResult};
pub(in crate::models) use uuid::Uuid;
use alloc::alloc::Layout;

use std::sync::Arc;

pub(self) use broker::database::PooledConnection;

use super::schema::{Context, Payload};
use core::f32;
pub use crate::models::Event;

into

Ordered:

use super::schema::{Context, Payload};
use alloc::alloc::Layout;
use core::f32;
use std::sync::Arc;

pub(self) use broker::database::PooledConnection;

pub(super) use chrono::Utc;

pub(crate) use juniper::{FieldError, FieldResult};

pub(in crate::models) use uuid::Uuid;

pub use super::update::convert_publish_payload;
pub use crate::models::Event;

I opt to order the imports from the least visible to the most to make exporting imported declaration look more natural, for example:

use proto::*;

pub use proto::Response;

pub fn send_request() -> Response { ... }

@@ -115,7 +115,7 @@ pub(crate) struct UseTree {
pub(crate) list_item: Option<ListItem>,
// Additional fields for top level use items.
// Should we have another struct for top-level use items rather than reusing this?
visibility: Option<ast::Visibility>,
pub(crate) visibility: Option<ast::Visibility>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crate export for reorder module

use juniper::{FieldError, FieldResult};
pub use juniper::{FieldError, FieldResult};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just taking a quick glance at the tests, and was wondering why an existing test changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants