mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-20 02:20:25 +00:00

Update to [Rust 1.74](https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html) and use the new clippy lints table. The update itself introduced a new clippy lint about superfluous hashes in raw strings, which got removed. I moved our lint config from `rustflags` to the newly stabilized [workspace.lints](https://doc.rust-lang.org/stable/cargo/reference/workspaces.html#the-lints-table). One consequence is that we have to `unsafe_code = "warn"` instead of "forbid" because the latter now actually bans unsafe code: ``` error[E0453]: allow(unsafe_code) incompatible with previous forbid --> crates/ruff_source_file/src/newlines.rs:62:17 | 62 | #[allow(unsafe_code)] | ^^^^^^^^^^^ overruled by previous forbid | = note: `forbid` lint level was set on command line ``` --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
24 lines
571 B
Rust
24 lines
571 B
Rust
use ruff_python_parser::{parse_suite, ParseError};
|
|
use ruff_text_size::{TextRange, TextSize};
|
|
|
|
use ruff_python_ast::identifier;
|
|
|
|
#[test]
|
|
fn extract_else_range() -> Result<(), ParseError> {
|
|
let contents = r"
|
|
for x in y:
|
|
pass
|
|
else:
|
|
pass
|
|
"
|
|
.trim();
|
|
let stmts = parse_suite(contents, "<filename>")?;
|
|
let stmt = stmts.first().unwrap();
|
|
let range = identifier::else_(stmt, contents).unwrap();
|
|
assert_eq!(&contents[range], "else");
|
|
assert_eq!(
|
|
range,
|
|
TextRange::new(TextSize::from(21), TextSize::from(25))
|
|
);
|
|
Ok(())
|
|
}
|