diff --git a/crates/ruff/examples/main.rs b/crates/ruff/examples/main.rs deleted file mode 100644 index 9795962968..0000000000 --- a/crates/ruff/examples/main.rs +++ /dev/null @@ -1,72 +0,0 @@ -use std::mem::size_of_val; - -#[derive(Clone, Debug)] -pub struct Export<'a> { - /// The names of the bindings exported via `__all__`. - pub names: Vec<&'a str>, -} - -#[derive(Clone, Debug)] -pub struct Importation<'a> { - /// The name to which the import is bound. - /// Given `import foo`, `name` would be "foo". - /// Given `import foo as bar`, `name` would be "bar". - pub name: &'a str, - /// The full name of the module being imported. - /// Given `import foo`, `full_name` would be "foo". - /// Given `import foo as bar`, `full_name` would be "foo". - pub full_name: &'a str, -} - -#[derive(Clone, Debug)] -pub struct FromImportation<'a> { - /// The name to which the import is bound. - /// Given `from foo import bar`, `name` would be "bar". - /// Given `from foo import bar as baz`, `name` would be "baz". - pub name: &'a str, - /// The full name of the module being imported. - /// Given `from foo import bar`, `full_name` would be "foo.bar". - /// Given `from foo import bar as baz`, `full_name` would be "foo.bar". - pub full_name: String, -} - -#[derive(Clone, Debug)] -pub struct SubmoduleImportation<'a> { - /// The parent module imported by the submodule import. - /// Given `import foo.bar`, `module` would be "foo". - pub name: &'a str, - /// The full name of the submodule being imported. - /// Given `import foo.bar`, `full_name` would be "foo.bar". - pub full_name: &'a str, -} - -// If we box, this goes from 48 to 16 -// If we use a u32 pointer, this goes to 8 -#[derive(Clone, Debug)] -pub enum BindingKind { - Annotation, - Argument, - Assignment, - NamedExprAssignment, - Binding, - LoopVar, - Global, - Nonlocal, - Builtin, - ClassDefinition, - FunctionDefinition, - // 32 - Export(u32), - FutureImportation, - // 40 - Importation(u32), - // 48 - FromImportation(u32), - // 48 - SubmoduleImportation(u32), -} - -fn main() { - let smart = BindingKind::Assignment; - dbg!(size_of_val(&smart)); -} diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs index 4b1f738013..d5c13d8dfd 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs @@ -1,8 +1,6 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::{ - Binding, BindingKind, ExecutionContext, FromImportation, Importation, SubmoduleImportation, -}; +use ruff_python_semantic::binding::{Binding, BindingKind, ExecutionContext}; /// ## What it does /// Checks for runtime imports defined in a type-checking block. diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs index fc06561589..53cc6d7e35 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs @@ -2,9 +2,7 @@ use std::path::Path; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::{ - Binding, BindingKind, ExecutionContext, FromImportation, Importation, SubmoduleImportation, -}; +use ruff_python_semantic::binding::{Binding, BindingKind, ExecutionContext}; use crate::rules::isort::{categorize, ImportSection, ImportType}; use crate::settings::Settings; @@ -160,7 +158,7 @@ impl Violation for TypingOnlyStandardLibraryImport { } /// Return `true` if `this` is implicitly loaded via importing `that`. -fn is_implicit_import(this: &Binding, that: &Binding) -> bool { +fn is_implicit_import(_this: &Binding, _that: &Binding) -> bool { true // match &this.kind { // BindingKind::Importation(Importation { diff --git a/crates/ruff/src/rules/pandas_vet/rules/check_call.rs b/crates/ruff/src/rules/pandas_vet/rules/check_call.rs index b9c3839dd9..64b6dba813 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/check_call.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/check_call.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{Expr, ExprKind}; use ruff_diagnostics::Violation; use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::{BindingKind, Importation}; +use ruff_python_semantic::binding::BindingKind; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff_python_semantic/src/context.rs b/crates/ruff_python_semantic/src/context.rs index 34e5915ada..ca36dcbff4 100644 --- a/crates/ruff_python_semantic/src/context.rs +++ b/crates/ruff_python_semantic/src/context.rs @@ -11,10 +11,7 @@ use ruff_python_stdlib::path::is_python_stub_file; use ruff_python_stdlib::typing::TYPING_EXTENSIONS; use crate::analyze::visibility::{module_visibility, Modifier, VisibleScope}; -use crate::binding::{ - Binding, BindingId, BindingKind, Bindings, Exceptions, ExecutionContext, FromImportation, - Importation, SubmoduleImportation, -}; +use crate::binding::{Binding, BindingId, BindingKind, Bindings, Exceptions, ExecutionContext}; use crate::node::{NodeId, Nodes}; use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};