Skip to content

Commit f544899

Browse files
committed
fix tests
1 parent a4453c2 commit f544899

File tree

20 files changed

+76
-135
lines changed

20 files changed

+76
-135
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ impl<'a> DerefMut for SnapshotParser<'a> {
238238

239239
impl<'a> Parser<'a> {
240240
#[rustc_lint_diagnostics]
241-
#[track_caller]
242241
pub fn struct_span_err<S: Into<MultiSpan>>(
243242
&self,
244243
sp: S,

compiler/rustc_parse/src/parser/expr.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,6 @@ impl<'a> Parser<'a> {
294294
continue;
295295
}
296296

297-
// Special cases:
298-
if op.node == AssocOp::As {
299-
lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?;
300-
continue;
301-
} else if op.node == AssocOp::DotDot || op.node == AssocOp::DotDotEq {
302-
// If we didn't have to handle `x..`/`x..=`, it would be pretty easy to
303-
// generalise it to the Fixity::None code.
304-
lhs = self.parse_expr_range(prec, lhs, op.node, cur_op_span)?;
305-
break;
306-
}
307-
308297
let op = op.node;
309298
// Special cases:
310299
if op == AssocOp::As {
@@ -619,9 +608,7 @@ impl<'a> Parser<'a> {
619608
token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => {
620609
make_it!(this, attrs, |this, _| this.recover_not_expr(lo))
621610
}
622-
_ => {
623-
return this.parse_expr_dot_or_call(Some(attrs));
624-
}
611+
_ => return this.parse_expr_dot_or_call(Some(attrs)),
625612
}
626613
}
627614

compiler/rustc_parse/src/parser/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,10 @@ impl<'a> Parser<'a> {
828828
}
829829

830830
fn expect_any_with_type(&mut self, kets: &[&TokenKind], expect: TokenExpectType) -> bool {
831-
let res = kets.iter().any(|k| match expect {
831+
kets.iter().any(|k| match expect {
832832
TokenExpectType::Expect => self.check(k),
833833
TokenExpectType::NoExpect => self.token == **k,
834-
});
835-
res
834+
})
836835
}
837836

838837
fn parse_seq_to_before_tokens<T>(
@@ -960,6 +959,7 @@ impl<'a> Parser<'a> {
960959
let t = f(self)?;
961960
v.push(t);
962961
}
962+
963963
Ok((v, trailing, recovered))
964964
}
965965

@@ -1045,7 +1045,6 @@ impl<'a> Parser<'a> {
10451045
f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
10461046
) -> PResult<'a, (ThinVec<T>, bool /* trailing */)> {
10471047
let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
1048-
10491048
if !recovered {
10501049
self.eat(ket);
10511050
}

compiler/rustc_parse/src/parser/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use thin_vec::ThinVec;
1717
use tracing::debug;
1818

1919
/// Specifies how to parse a path.
20-
#[derive(Copy, Clone, PartialEq, Debug)]
20+
#[derive(Copy, Clone, PartialEq)]
2121
pub enum PathStyle {
2222
/// In some contexts, notably in expressions, paths with generic arguments are ambiguous
2323
/// with something else. For example, in expressions `segment < ....` can be interpreted

compiler/rustc_resolve/src/late.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1261,15 +1261,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
12611261
opt_ns: Option<Namespace>, // `None` indicates a module path in import
12621262
finalize: Option<Finalize>,
12631263
) -> PathResult<'a> {
1264-
let res = self.r.resolve_path_with_ribs(
1264+
self.r.resolve_path_with_ribs(
12651265
path,
12661266
opt_ns,
12671267
&self.parent_scope,
12681268
finalize,
12691269
Some(&self.ribs),
12701270
None,
1271-
);
1272-
res
1271+
)
12731272
}
12741273

12751274
// AST resolution
@@ -3486,6 +3485,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
34863485
//
34873486
// Similar thing, for types, happens in `report_errors` above.
34883487
let report_errors_for_call = |this: &mut Self, parent_err: Spanned<ResolutionError<'a>>| {
3488+
if !source.is_call() {
3489+
return Some(parent_err);
3490+
}
3491+
34893492
// Before we start looking for candidates, we have to get our hands
34903493
// on the type user is trying to perform invocation on; basically:
34913494
// we're transforming `HashMap::new` into just `HashMap`.
@@ -3726,6 +3729,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
37263729
"resolve_qpath(qself={:?}, path={:?}, ns={:?}, finalize={:?})",
37273730
qself, path, ns, finalize,
37283731
);
3732+
37293733
if let Some(qself) = qself {
37303734
if qself.position == 0 {
37313735
// This is a case like `<T>::B`, where there is no
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
1+
// #101728, we remove type ascription, so this test case is changed to `var as ty`
22
fn main() {
3-
let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy : SomeTrait<AA, BB, CC>;
3+
let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as SomeTrait<AA, BB, CC>;
44

5-
let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
5+
let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
66

7-
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
7+
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww) as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
88

9-
x : u32 - 1u32 / 10f32 : u32
9+
let _ = x as u32 - 1u32 / (10f32 as u32);
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// rustfmt-format_macro_bodies: true
22

33
macro_rules! foo {
4-
($a: ident : $b: ty) => {
5-
$a(42): $b;
6-
};
7-
($a: ident $b: ident $c: ident) => {
8-
$a = $b + $c;
9-
};
4+
($a: ident : $b: ty) => { $a(42): $b; };
5+
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
106
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// rustfmt-format_macro_matchers: false
22

33
macro_rules! foo {
4-
($a: ident : $b: ty) => {
5-
$a(42): $b;
6-
};
7-
($a: ident $b: ident $c: ident) => {
8-
$a = $b + $c;
9-
};
4+
($a: ident : $b: ty) => { $a(42): $b; };
5+
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
106
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// rustfmt-format_macro_matchers: true
22

33
macro_rules! foo {
4-
($a:ident : $b:ty) => {
5-
$a(42): $b;
6-
};
7-
($a:ident $b:ident $c:ident) => {
8-
$a = $b + $c;
9-
};
4+
($a: ident : $b: ty) => { $a(42): $b; };
5+
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
106
}

src/tools/rustfmt/tests/target/macros.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn main() {
122122
20, 21, 22);
123123

124124
// #1092
125-
chain!(input, a: take!(max_size), || []);
125+
chain!(input, a:take!(max_size), || []);
126126

127127
// #2727
128128
foo!("bar");
@@ -156,17 +156,13 @@ fn issue1178() {
156156
}
157157

158158
fn issue1739() {
159-
sql_function!(
160-
add_rss_item,
161-
add_rss_item_t,
162-
(
163-
a: types::Integer,
164-
b: types::Timestamptz,
165-
c: types::Text,
166-
d: types::Text,
167-
e: types::Text
168-
)
169-
);
159+
sql_function!(add_rss_item,
160+
add_rss_item_t,
161+
(a: types::Integer,
162+
b: types::Timestamptz,
163+
c: types::Text,
164+
d: types::Text,
165+
e: types::Text));
170166

171167
w.slice_mut(s![
172168
..,
@@ -232,7 +228,7 @@ fn issue_3174() {
232228
"debugMessage": debug.message,
233229
})
234230
} else {
235-
json!({ "errorKind": format!("{:?}", error.err_kind()) })
231+
json!({"errorKind": format!("{:?}", error.err_kind())})
236232
};
237233
}
238234

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
// #101728, we remove type ascription, so this test case is changed to `var as ty`
12
fn main() {
23
let xxxxxxxxxxx =
3-
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, BB, CC>;
4+
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as SomeTrait<AA, BB, CC>;
45

56
let xxxxxxxxxxxxxxx =
6-
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
7+
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
78

8-
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww):
9-
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
9+
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww)
10+
as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
1011

11-
x: u32 - 1u32 / 10f32: u32
12+
let _ = x as u32 - 1u32 / (10f32 as u32);
1213
}

src/tools/rustfmt/tests/target/type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn issue3117() {
129129
fn issue3139() {
130130
assert_eq!(
131131
to_json_value(&None::<i32>).unwrap(),
132-
json!({ "test": None::<i32> })
132+
json!( { "test": None :: <i32> } )
133133
);
134134
}
135135

tests/ui/generic-associated-types/equality-bound.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ error[E0433]: failed to resolve: use of undeclared type `I`
3636
--> $DIR/equality-bound.rs:9:41
3737
|
3838
LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 {
39-
| ^
40-
| |
41-
| use of undeclared type `I`
42-
| help: a type parameter with a similar name exists: `J`
39+
| ^ use of undeclared type `I`
4340

4441
error: aborting due to 4 previous errors
4542

tests/ui/macros/builtin-prelude-no-accidents.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env`
44
LL | env::current_dir;
55
| ^^^ use of undeclared crate or module `env`
66

7-
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
8-
--> $DIR/builtin-prelude-no-accidents.rs:7:14
9-
|
10-
LL | type B = vec::Vec<u8>;
11-
| ^^^
12-
| |
13-
| use of undeclared crate or module `vec`
14-
| help: a struct with a similar name exists (notice the capitalization): `Vec`
15-
167
error[E0433]: failed to resolve: use of undeclared crate or module `panic`
178
--> $DIR/builtin-prelude-no-accidents.rs:6:14
189
|
1910
LL | type A = panic::PanicInfo;
2011
| ^^^^^ use of undeclared crate or module `panic`
2112

13+
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
14+
--> $DIR/builtin-prelude-no-accidents.rs:7:14
15+
|
16+
LL | type B = vec::Vec<u8>;
17+
| ^^^ use of undeclared crate or module `vec`
18+
2219
error: aborting due to 3 previous errors
2320

2421
For more information about this error, try `rustc --explain E0433`.

tests/ui/parser/dyn-trait-compatibility.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
2+
--> $DIR/dyn-trait-compatibility.rs:3:11
3+
|
4+
LL | type A1 = dyn::dyn;
5+
| ^^^ use of undeclared crate or module `dyn`
6+
7+
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
8+
--> $DIR/dyn-trait-compatibility.rs:9:23
9+
|
10+
LL | type A3 = dyn<<dyn as dyn>::dyn>;
11+
| ^^^ use of undeclared crate or module `dyn`
12+
113
error[E0412]: cannot find type `dyn` in this scope
214
--> $DIR/dyn-trait-compatibility.rs:1:11
315
|
@@ -40,18 +52,6 @@ error[E0412]: cannot find type `dyn` in this scope
4052
LL | type A3 = dyn<<dyn as dyn>::dyn>;
4153
| ^^^ not found in this scope
4254

43-
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
44-
--> $DIR/dyn-trait-compatibility.rs:3:11
45-
|
46-
LL | type A1 = dyn::dyn;
47-
| ^^^ use of undeclared crate or module `dyn`
48-
49-
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
50-
--> $DIR/dyn-trait-compatibility.rs:9:23
51-
|
52-
LL | type A3 = dyn<<dyn as dyn>::dyn>;
53-
| ^^^ use of undeclared crate or module `dyn`
54-
5555
error: aborting due to 8 previous errors
5656

5757
Some errors have detailed explanations: E0405, E0412, E0433.

tests/ui/pattern/pattern-error-continue.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error[E0433]: failed to resolve: use of undeclared type `E`
2+
--> $DIR/pattern-error-continue.rs:33:9
3+
|
4+
LL | E::V => {}
5+
| ^ use of undeclared type `E`
6+
17
error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
28
--> $DIR/pattern-error-continue.rs:18:9
39
|
@@ -50,15 +56,6 @@ note: function defined here
5056
LL | fn f(_c: char) {}
5157
| ^ --------
5258

53-
error[E0433]: failed to resolve: use of undeclared type `E`
54-
--> $DIR/pattern-error-continue.rs:33:9
55-
|
56-
LL | E::V => {}
57-
| ^
58-
| |
59-
| use of undeclared type `E`
60-
| help: an enum with a similar name exists: `A`
61-
6259
error: aborting due to 5 previous errors
6360

6461
Some errors have detailed explanations: E0023, E0308, E0433, E0532.

tests/ui/resolve/resolve-variant-assoc-item.stderr

-14
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@ error[E0433]: failed to resolve: `V` is a variant, not a module
33
|
44
LL | E::V::associated_item;
55
| ^ `V` is a variant, not a module
6-
|
7-
help: there is an enum variant `E::V`; try using the variant's enum
8-
|
9-
LL | E;
10-
| ~
116

127
error[E0433]: failed to resolve: `V` is a variant, not a module
138
--> $DIR/resolve-variant-assoc-item.rs:6:5
149
|
1510
LL | V::associated_item;
1611
| ^ `V` is a variant, not a module
17-
|
18-
help: there is an enum variant `E::V`; try using the variant's enum
19-
|
20-
LL | E;
21-
| ~
22-
help: an enum with a similar name exists
23-
|
24-
LL | E::associated_item;
25-
| ~
2612

2713
error: aborting due to 2 previous errors
2814

tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error[E0433]: failed to resolve: use of undeclared type `Unresolved`
2+
--> $DIR/assoc_type_bound_with_struct.rs:19:31
3+
|
4+
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
5+
| ^^^^^^^^^^ use of undeclared type `Unresolved`
6+
17
error[E0404]: expected trait, found struct `String`
28
--> $DIR/assoc_type_bound_with_struct.rs:5:46
39
|
@@ -85,12 +91,6 @@ LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
8591
|
8692
= note: similarly named trait `ToString` defined here
8793

88-
error[E0433]: failed to resolve: use of undeclared type `Unresolved`
89-
--> $DIR/assoc_type_bound_with_struct.rs:19:31
90-
|
91-
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
92-
| ^^^^^^^^^^ use of undeclared type `Unresolved`
93-
9494
error: aborting due to 6 previous errors
9595

9696
Some errors have detailed explanations: E0404, E0405.

0 commit comments

Comments
 (0)