Update to Rust 1.74 and use new clippy lints table (#8722)

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>
This commit is contained in:
konsti 2023-11-17 00:12:46 +01:00 committed by GitHub
parent 6d5d079a18
commit 14e65afdc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 1124 additions and 1054 deletions

View file

@ -33,3 +33,6 @@ ruff_python_parser = { path = "../ruff_python_parser" }
[features]
serde = ["dep:serde", "ruff_text_size/serde"]
[lints]
workspace = true

View file

@ -229,7 +229,7 @@ mod tests {
#[test]
fn extract_global_names() {
let contents = r#"global X,Y, Z"#.trim();
let contents = r"global X,Y, Z".trim();
let mut names = IdentifierTokenizer::new(
contents,

View file

@ -5,12 +5,12 @@ use ruff_python_ast::identifier;
#[test]
fn extract_else_range() -> Result<(), ParseError> {
let contents = r#"
let contents = r"
for x in y:
pass
else:
pass
"#
"
.trim();
let stmts = parse_suite(contents, "<filename>")?;
let stmt = stmts.first().unwrap();

View file

@ -5,7 +5,7 @@ use ruff_text_size::TextRange;
#[test]
fn test_parenthesized_name() {
let source_code = r#"(x) + 1"#;
let source_code = r"(x) + 1";
let expr = parse_expression(source_code, "<filename>").unwrap();
let bin_op = expr.as_bin_op_expr().unwrap();
@ -22,7 +22,7 @@ fn test_parenthesized_name() {
#[test]
fn test_non_parenthesized_name() {
let source_code = r#"x + 1"#;
let source_code = r"x + 1";
let expr = parse_expression(source_code, "<filename>").unwrap();
let bin_op = expr.as_bin_op_expr().unwrap();
@ -39,7 +39,7 @@ fn test_non_parenthesized_name() {
#[test]
fn test_parenthesized_argument() {
let source_code = r#"f((a))"#;
let source_code = r"f((a))";
let expr = parse_expression(source_code, "<filename>").unwrap();
let call = expr.as_call_expr().unwrap();
@ -57,7 +57,7 @@ fn test_parenthesized_argument() {
#[test]
fn test_non_parenthesized_argument() {
let source_code = r#"f(a)"#;
let source_code = r"f(a)";
let expr = parse_expression(source_code, "<filename>").unwrap();
let call = expr.as_call_expr().unwrap();
@ -75,7 +75,7 @@ fn test_non_parenthesized_argument() {
#[test]
fn test_parenthesized_tuple_member() {
let source_code = r#"(a, (b))"#;
let source_code = r"(a, (b))";
let expr = parse_expression(source_code, "<filename>").unwrap();
let tuple = expr.as_tuple_expr().unwrap();
@ -92,7 +92,7 @@ fn test_parenthesized_tuple_member() {
#[test]
fn test_non_parenthesized_tuple_member() {
let source_code = r#"(a, b)"#;
let source_code = r"(a, b)";
let expr = parse_expression(source_code, "<filename>").unwrap();
let tuple = expr.as_tuple_expr().unwrap();
@ -109,7 +109,7 @@ fn test_non_parenthesized_tuple_member() {
#[test]
fn test_twice_parenthesized_name() {
let source_code = r#"((x)) + 1"#;
let source_code = r"((x)) + 1";
let expr = parse_expression(source_code, "<filename>").unwrap();
let bin_op = expr.as_bin_op_expr().unwrap();
@ -126,7 +126,7 @@ fn test_twice_parenthesized_name() {
#[test]
fn test_twice_parenthesized_argument() {
let source_code = r#"f(((a + 1)))"#;
let source_code = r"f(((a + 1)))";
let expr = parse_expression(source_code, "<filename>").unwrap();
let call = expr.as_call_expr().unwrap();

View file

@ -17,7 +17,7 @@ use ruff_python_parser::{parse_tokens, Mode};
#[test]
fn function_arguments() {
let source = r#"def a(b, c,/, d, e = 20, *args, named=5, other=20, **kwargs): pass"#;
let source = r"def a(b, c,/, d, e = 20, *args, named=5, other=20, **kwargs): pass";
let trace = trace_preorder_visitation(source);
@ -26,7 +26,7 @@ fn function_arguments() {
#[test]
fn function_positional_only_with_default() {
let source = r#"def a(b, c = 34,/, e = 20, *args): pass"#;
let source = r"def a(b, c = 34,/, e = 20, *args): pass";
let trace = trace_preorder_visitation(source);
@ -35,7 +35,7 @@ fn function_positional_only_with_default() {
#[test]
fn compare() {
let source = r#"4 < x < 5"#;
let source = r"4 < x < 5";
let trace = trace_preorder_visitation(source);
@ -71,13 +71,13 @@ fn set_comprehension() {
#[test]
fn match_class_pattern() {
let source = r#"
let source = r"
match x:
case Point2D(0, 0):
...
case Point3D(x=0, y=0, z=0):
...
"#;
";
let trace = trace_preorder_visitation(source);
@ -86,7 +86,7 @@ match x:
#[test]
fn decorators() {
let source = r#"
let source = r"
@decorator
def a():
pass
@ -94,7 +94,7 @@ def a():
@test
class A:
pass
"#;
";
let trace = trace_preorder_visitation(source);
@ -103,7 +103,7 @@ class A:
#[test]
fn type_aliases() {
let source = r#"type X[T: str, U, *Ts, **P] = list[T]"#;
let source = r"type X[T: str, U, *Ts, **P] = list[T]";
let trace = trace_preorder_visitation(source);
@ -112,7 +112,7 @@ fn type_aliases() {
#[test]
fn class_type_parameters() {
let source = r#"class X[T: str, U, *Ts, **P]: ..."#;
let source = r"class X[T: str, U, *Ts, **P]: ...";
let trace = trace_preorder_visitation(source);
@ -121,7 +121,7 @@ fn class_type_parameters() {
#[test]
fn function_type_parameters() {
let source = r#"def X[T: str, U, *Ts, **P](): ..."#;
let source = r"def X[T: str, U, *Ts, **P](): ...";
let trace = trace_preorder_visitation(source);

View file

@ -18,7 +18,7 @@ use ruff_python_ast::{
#[test]
fn function_arguments() {
let source = r#"def a(b, c,/, d, e = 20, *args, named=5, other=20, **kwargs): pass"#;
let source = r"def a(b, c,/, d, e = 20, *args, named=5, other=20, **kwargs): pass";
let trace = trace_visitation(source);
@ -27,7 +27,7 @@ fn function_arguments() {
#[test]
fn function_positional_only_with_default() {
let source = r#"def a(b, c = 34,/, e = 20, *args): pass"#;
let source = r"def a(b, c = 34,/, e = 20, *args): pass";
let trace = trace_visitation(source);
@ -36,7 +36,7 @@ fn function_positional_only_with_default() {
#[test]
fn compare() {
let source = r#"4 < x < 5"#;
let source = r"4 < x < 5";
let trace = trace_visitation(source);
@ -72,13 +72,13 @@ fn set_comprehension() {
#[test]
fn match_class_pattern() {
let source = r#"
let source = r"
match x:
case Point2D(0, 0):
...
case Point3D(x=0, y=0, z=0):
...
"#;
";
let trace = trace_visitation(source);
@ -87,7 +87,7 @@ match x:
#[test]
fn decorators() {
let source = r#"
let source = r"
@decorator
def a():
pass
@ -95,7 +95,7 @@ def a():
@test
class A:
pass
"#;
";
let trace = trace_visitation(source);
@ -104,7 +104,7 @@ class A:
#[test]
fn type_aliases() {
let source = r#"type X[T: str, U, *Ts, **P] = list[T]"#;
let source = r"type X[T: str, U, *Ts, **P] = list[T]";
let trace = trace_visitation(source);
@ -113,7 +113,7 @@ fn type_aliases() {
#[test]
fn class_type_parameters() {
let source = r#"class X[T: str, U, *Ts, **P]: ..."#;
let source = r"class X[T: str, U, *Ts, **P]: ...";
let trace = trace_visitation(source);
@ -122,7 +122,7 @@ fn class_type_parameters() {
#[test]
fn function_type_parameters() {
let source = r#"def X[T: str, U, *Ts, **P](): ..."#;
let source = r"def X[T: str, U, *Ts, **P](): ...";
let trace = trace_visitation(source);