diff --git a/src/rules/flake8_simplify/rules/fix_if.rs b/src/rules/flake8_simplify/rules/fix_if.rs index 48c20bd83f..d17da52c08 100644 --- a/src/rules/flake8_simplify/rules/fix_if.rs +++ b/src/rules/flake8_simplify/rules/fix_if.rs @@ -114,6 +114,7 @@ pub(crate) fn fix_nested_if_statements( let mut state = CodegenState { default_newline: stylist.line_ending(), + default_indent: stylist.indentation(), ..Default::default() }; tree.codegen(&mut state); diff --git a/src/rules/flake8_simplify/rules/fix_with.rs b/src/rules/flake8_simplify/rules/fix_with.rs index a947cacf27..5dc431d94f 100644 --- a/src/rules/flake8_simplify/rules/fix_with.rs +++ b/src/rules/flake8_simplify/rules/fix_with.rs @@ -78,6 +78,7 @@ pub(crate) fn fix_multiple_with_statements( let mut state = CodegenState { default_newline: stylist.line_ending(), + default_indent: stylist.indentation(), ..Default::default() }; tree.codegen(&mut state); diff --git a/src/source_code/stylist.rs b/src/source_code/stylist.rs index 8aec4fc115..cd30473d19 100644 --- a/src/source_code/stylist.rs +++ b/src/source_code/stylist.rs @@ -108,11 +108,17 @@ impl Default for Indentation { } } +impl Indentation { + pub fn as_str(&self) -> &str { + self.0.as_str() + } +} + impl Deref for Indentation { type Target = str; fn deref(&self) -> &Self::Target { - &self.0 + self.as_str() } }