fix tests

This commit is contained in:
yukang 2023-03-15 07:10:59 +08:00
parent a4453c20ca
commit f54489978d
20 changed files with 76 additions and 135 deletions

View File

@ -238,7 +238,6 @@ impl<'a> DerefMut for SnapshotParser<'a> {
impl<'a> Parser<'a> {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,

View File

@ -294,17 +294,6 @@ impl<'a> Parser<'a> {
continue;
}
// Special cases:
if op.node == AssocOp::As {
lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?;
continue;
} else if op.node == AssocOp::DotDot || op.node == AssocOp::DotDotEq {
// If we didn't have to handle `x..`/`x..=`, it would be pretty easy to
// generalise it to the Fixity::None code.
lhs = self.parse_expr_range(prec, lhs, op.node, cur_op_span)?;
break;
}
let op = op.node;
// Special cases:
if op == AssocOp::As {
@ -619,9 +608,7 @@ impl<'a> Parser<'a> {
token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => {
make_it!(this, attrs, |this, _| this.recover_not_expr(lo))
}
_ => {
return this.parse_expr_dot_or_call(Some(attrs));
}
_ => return this.parse_expr_dot_or_call(Some(attrs)),
}
}

View File

@ -828,11 +828,10 @@ impl<'a> Parser<'a> {
}
fn expect_any_with_type(&mut self, kets: &[&TokenKind], expect: TokenExpectType) -> bool {
let res = kets.iter().any(|k| match expect {
kets.iter().any(|k| match expect {
TokenExpectType::Expect => self.check(k),
TokenExpectType::NoExpect => self.token == **k,
});
res
})
}
fn parse_seq_to_before_tokens<T>(
@ -960,6 +959,7 @@ impl<'a> Parser<'a> {
let t = f(self)?;
v.push(t);
}
Ok((v, trailing, recovered))
}
@ -1045,7 +1045,6 @@ impl<'a> Parser<'a> {
f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
) -> PResult<'a, (ThinVec<T>, bool /* trailing */)> {
let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
if !recovered {
self.eat(ket);
}

View File

@ -17,7 +17,7 @@ use thin_vec::ThinVec;
use tracing::debug;
/// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq)]
pub enum PathStyle {
/// In some contexts, notably in expressions, paths with generic arguments are ambiguous
/// with something else. For example, in expressions `segment < ....` can be interpreted

View File

@ -1261,15 +1261,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
opt_ns: Option<Namespace>, // `None` indicates a module path in import
finalize: Option<Finalize>,
) -> PathResult<'a> {
let res = self.r.resolve_path_with_ribs(
self.r.resolve_path_with_ribs(
path,
opt_ns,
&self.parent_scope,
finalize,
Some(&self.ribs),
None,
);
res
)
}
// AST resolution
@ -3486,6 +3485,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
//
// Similar thing, for types, happens in `report_errors` above.
let report_errors_for_call = |this: &mut Self, parent_err: Spanned<ResolutionError<'a>>| {
if !source.is_call() {
return Some(parent_err);
}
// Before we start looking for candidates, we have to get our hands
// on the type user is trying to perform invocation on; basically:
// we're transforming `HashMap::new` into just `HashMap`.
@ -3726,6 +3729,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
"resolve_qpath(qself={:?}, path={:?}, ns={:?}, finalize={:?})",
qself, path, ns, finalize,
);
if let Some(qself) = qself {
if qself.position == 0 {
// This is a case like `<T>::B`, where there is no

View File

@ -1,10 +1,10 @@
// #101728, we remove type ascription, so this test case is changed to `var as ty`
fn main() {
let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy : SomeTrait<AA, BB, CC>;
let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as SomeTrait<AA, BB, CC>;
let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww) as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
x : u32 - 1u32 / 10f32 : u32
let _ = x as u32 - 1u32 / (10f32 as u32);
}

View File

@ -1,10 +1,6 @@
// rustfmt-format_macro_bodies: true
macro_rules! foo {
($a: ident : $b: ty) => {
$a(42): $b;
};
($a: ident $b: ident $c: ident) => {
$a = $b + $c;
};
($a: ident : $b: ty) => { $a(42): $b; };
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
}

View File

@ -1,10 +1,6 @@
// rustfmt-format_macro_matchers: false
macro_rules! foo {
($a: ident : $b: ty) => {
$a(42): $b;
};
($a: ident $b: ident $c: ident) => {
$a = $b + $c;
};
($a: ident : $b: ty) => { $a(42): $b; };
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
}

View File

@ -1,10 +1,6 @@
// rustfmt-format_macro_matchers: true
macro_rules! foo {
($a:ident : $b:ty) => {
$a(42): $b;
};
($a:ident $b:ident $c:ident) => {
$a = $b + $c;
};
($a: ident : $b: ty) => { $a(42): $b; };
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
}

View File

@ -122,7 +122,7 @@ fn main() {
20, 21, 22);
// #1092
chain!(input, a: take!(max_size), || []);
chain!(input, a:take!(max_size), || []);
// #2727
foo!("bar");
@ -156,17 +156,13 @@ fn issue1178() {
}
fn issue1739() {
sql_function!(
add_rss_item,
add_rss_item_t,
(
a: types::Integer,
b: types::Timestamptz,
c: types::Text,
d: types::Text,
e: types::Text
)
);
sql_function!(add_rss_item,
add_rss_item_t,
(a: types::Integer,
b: types::Timestamptz,
c: types::Text,
d: types::Text,
e: types::Text));
w.slice_mut(s![
..,
@ -232,7 +228,7 @@ fn issue_3174() {
"debugMessage": debug.message,
})
} else {
json!({ "errorKind": format!("{:?}", error.err_kind()) })
json!({"errorKind": format!("{:?}", error.err_kind())})
};
}

View File

@ -1,12 +1,13 @@
// #101728, we remove type ascription, so this test case is changed to `var as ty`
fn main() {
let xxxxxxxxxxx =
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, BB, CC>;
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as SomeTrait<AA, BB, CC>;
let xxxxxxxxxxxxxxx =
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww):
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww)
as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
x: u32 - 1u32 / 10f32: u32
let _ = x as u32 - 1u32 / (10f32 as u32);
}

View File

@ -129,7 +129,7 @@ fn issue3117() {
fn issue3139() {
assert_eq!(
to_json_value(&None::<i32>).unwrap(),
json!({ "test": None::<i32> })
json!( { "test": None :: <i32> } )
);
}

View File

@ -36,10 +36,7 @@ error[E0433]: failed to resolve: use of undeclared type `I`
--> $DIR/equality-bound.rs:9:41
|
LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 {
| ^
| |
| use of undeclared type `I`
| help: a type parameter with a similar name exists: `J`
| ^ use of undeclared type `I`
error: aborting due to 4 previous errors

View File

@ -4,21 +4,18 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env`
LL | env::current_dir;
| ^^^ use of undeclared crate or module `env`
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
--> $DIR/builtin-prelude-no-accidents.rs:7:14
|
LL | type B = vec::Vec<u8>;
| ^^^
| |
| use of undeclared crate or module `vec`
| help: a struct with a similar name exists (notice the capitalization): `Vec`
error[E0433]: failed to resolve: use of undeclared crate or module `panic`
--> $DIR/builtin-prelude-no-accidents.rs:6:14
|
LL | type A = panic::PanicInfo;
| ^^^^^ use of undeclared crate or module `panic`
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
--> $DIR/builtin-prelude-no-accidents.rs:7:14
|
LL | type B = vec::Vec<u8>;
| ^^^ use of undeclared crate or module `vec`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0433`.

View File

@ -1,3 +1,15 @@
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
--> $DIR/dyn-trait-compatibility.rs:3:11
|
LL | type A1 = dyn::dyn;
| ^^^ use of undeclared crate or module `dyn`
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
--> $DIR/dyn-trait-compatibility.rs:9:23
|
LL | type A3 = dyn<<dyn as dyn>::dyn>;
| ^^^ use of undeclared crate or module `dyn`
error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:1:11
|
@ -40,18 +52,6 @@ error[E0412]: cannot find type `dyn` in this scope
LL | type A3 = dyn<<dyn as dyn>::dyn>;
| ^^^ not found in this scope
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
--> $DIR/dyn-trait-compatibility.rs:3:11
|
LL | type A1 = dyn::dyn;
| ^^^ use of undeclared crate or module `dyn`
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
--> $DIR/dyn-trait-compatibility.rs:9:23
|
LL | type A3 = dyn<<dyn as dyn>::dyn>;
| ^^^ use of undeclared crate or module `dyn`
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0405, E0412, E0433.

View File

@ -1,3 +1,9 @@
error[E0433]: failed to resolve: use of undeclared type `E`
--> $DIR/pattern-error-continue.rs:33:9
|
LL | E::V => {}
| ^ use of undeclared type `E`
error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
--> $DIR/pattern-error-continue.rs:18:9
|
@ -50,15 +56,6 @@ note: function defined here
LL | fn f(_c: char) {}
| ^ --------
error[E0433]: failed to resolve: use of undeclared type `E`
--> $DIR/pattern-error-continue.rs:33:9
|
LL | E::V => {}
| ^
| |
| use of undeclared type `E`
| help: an enum with a similar name exists: `A`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0023, E0308, E0433, E0532.

View File

@ -3,26 +3,12 @@ error[E0433]: failed to resolve: `V` is a variant, not a module
|
LL | E::V::associated_item;
| ^ `V` is a variant, not a module
|
help: there is an enum variant `E::V`; try using the variant's enum
|
LL | E;
| ~
error[E0433]: failed to resolve: `V` is a variant, not a module
--> $DIR/resolve-variant-assoc-item.rs:6:5
|
LL | V::associated_item;
| ^ `V` is a variant, not a module
|
help: there is an enum variant `E::V`; try using the variant's enum
|
LL | E;
| ~
help: an enum with a similar name exists
|
LL | E::associated_item;
| ~
error: aborting due to 2 previous errors

View File

@ -1,3 +1,9 @@
error[E0433]: failed to resolve: use of undeclared type `Unresolved`
--> $DIR/assoc_type_bound_with_struct.rs:19:31
|
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
| ^^^^^^^^^^ use of undeclared type `Unresolved`
error[E0404]: expected trait, found struct `String`
--> $DIR/assoc_type_bound_with_struct.rs:5:46
|
@ -85,12 +91,6 @@ LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
|
= note: similarly named trait `ToString` defined here
error[E0433]: failed to resolve: use of undeclared type `Unresolved`
--> $DIR/assoc_type_bound_with_struct.rs:19:31
|
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
| ^^^^^^^^^^ use of undeclared type `Unresolved`
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0404, E0405.

View File

@ -1,3 +1,9 @@
error[E0433]: failed to resolve: use of undeclared type `NonExistent`
--> $DIR/type-path-err-node-types.rs:15:5
|
LL | NonExistent::Assoc::<u8>;
| ^^^^^^^^^^^ use of undeclared type `NonExistent`
error[E0412]: cannot find type `Nonexistent` in this scope
--> $DIR/type-path-err-node-types.rs:7:12
|
@ -16,12 +22,6 @@ error[E0425]: cannot find value `nonexistent` in this scope
LL | nonexistent.nonexistent::<u8>();
| ^^^^^^^^^^^ not found in this scope
error[E0433]: failed to resolve: use of undeclared type `NonExistent`
--> $DIR/type-path-err-node-types.rs:15:5
|
LL | NonExistent::Assoc::<u8>;
| ^^^^^^^^^^^ use of undeclared type `NonExistent`
error[E0282]: type annotations needed
--> $DIR/type-path-err-node-types.rs:23:14
|

View File

@ -3,22 +3,12 @@ error[E0433]: failed to resolve: `Y` is a variant, not a module
|
LL | let _: <u8 as E::Y>::NN;
| ^ `Y` is a variant, not a module
|
help: there is an enum variant `E::Y`; try using the variant's enum
|
LL | let _: E;
| ~
error[E0433]: failed to resolve: `Y` is a variant, not a module
--> $DIR/ufcs-partially-resolved.rs:50:15
|
LL | <u8 as E::Y>::NN;
| ^ `Y` is a variant, not a module
|
help: there is an enum variant `E::Y`; try using the variant's enum
|
LL | E;
| ~
error[E0576]: cannot find associated type `N` in trait `Tr`
--> $DIR/ufcs-partially-resolved.rs:19:24