1
Fork 0

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> { impl<'a> Parser<'a> {
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err<S: Into<MultiSpan>>( pub fn struct_span_err<S: Into<MultiSpan>>(
&self, &self,
sp: S, sp: S,

View file

@ -294,17 +294,6 @@ impl<'a> Parser<'a> {
continue; 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; let op = op.node;
// Special cases: // Special cases:
if op == AssocOp::As { if op == AssocOp::As {
@ -619,9 +608,7 @@ impl<'a> Parser<'a> {
token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => { token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => {
make_it!(this, attrs, |this, _| this.recover_not_expr(lo)) 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 { 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::Expect => self.check(k),
TokenExpectType::NoExpect => self.token == **k, TokenExpectType::NoExpect => self.token == **k,
}); })
res
} }
fn parse_seq_to_before_tokens<T>( fn parse_seq_to_before_tokens<T>(
@ -960,6 +959,7 @@ impl<'a> Parser<'a> {
let t = f(self)?; let t = f(self)?;
v.push(t); v.push(t);
} }
Ok((v, trailing, recovered)) Ok((v, trailing, recovered))
} }
@ -1045,7 +1045,6 @@ impl<'a> Parser<'a> {
f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
) -> PResult<'a, (ThinVec<T>, bool /* trailing */)> { ) -> PResult<'a, (ThinVec<T>, bool /* trailing */)> {
let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?; let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
if !recovered { if !recovered {
self.eat(ket); self.eat(ket);
} }

View file

@ -17,7 +17,7 @@ use thin_vec::ThinVec;
use tracing::debug; use tracing::debug;
/// Specifies how to parse a path. /// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq)]
pub enum PathStyle { pub enum PathStyle {
/// In some contexts, notably in expressions, paths with generic arguments are ambiguous /// In some contexts, notably in expressions, paths with generic arguments are ambiguous
/// with something else. For example, in expressions `segment < ....` can be interpreted /// 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 opt_ns: Option<Namespace>, // `None` indicates a module path in import
finalize: Option<Finalize>, finalize: Option<Finalize>,
) -> PathResult<'a> { ) -> PathResult<'a> {
let res = self.r.resolve_path_with_ribs( self.r.resolve_path_with_ribs(
path, path,
opt_ns, opt_ns,
&self.parent_scope, &self.parent_scope,
finalize, finalize,
Some(&self.ribs), Some(&self.ribs),
None, None,
); )
res
} }
// AST resolution // 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. // Similar thing, for types, happens in `report_errors` above.
let report_errors_for_call = |this: &mut Self, parent_err: Spanned<ResolutionError<'a>>| { 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 // Before we start looking for candidates, we have to get our hands
// on the type user is trying to perform invocation on; basically: // on the type user is trying to perform invocation on; basically:
// we're transforming `HashMap::new` into just `HashMap`. // 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={:?})", "resolve_qpath(qself={:?}, path={:?}, ns={:?}, finalize={:?})",
qself, path, ns, finalize, qself, path, ns, finalize,
); );
if let Some(qself) = qself { if let Some(qself) = qself {
if qself.position == 0 { if qself.position == 0 {
// This is a case like `<T>::B`, where there is no // 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() { 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 // rustfmt-format_macro_bodies: true
macro_rules! foo { macro_rules! foo {
($a: ident : $b: ty) => { ($a: ident : $b: ty) => { $a(42): $b; };
$a(42): $b; ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
};
($a: ident $b: ident $c: ident) => {
$a = $b + $c;
};
} }

View file

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

View file

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

View file

@ -122,7 +122,7 @@ fn main() {
20, 21, 22); 20, 21, 22);
// #1092 // #1092
chain!(input, a: take!(max_size), || []); chain!(input, a:take!(max_size), || []);
// #2727 // #2727
foo!("bar"); foo!("bar");
@ -156,17 +156,13 @@ fn issue1178() {
} }
fn issue1739() { fn issue1739() {
sql_function!( sql_function!(add_rss_item,
add_rss_item, add_rss_item_t,
add_rss_item_t, (a: types::Integer,
( b: types::Timestamptz,
a: types::Integer, c: types::Text,
b: types::Timestamptz, d: types::Text,
c: types::Text, e: types::Text));
d: types::Text,
e: types::Text
)
);
w.slice_mut(s![ w.slice_mut(s![
.., ..,
@ -232,7 +228,7 @@ fn issue_3174() {
"debugMessage": debug.message, "debugMessage": debug.message,
}) })
} else { } 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() { fn main() {
let xxxxxxxxxxx = let xxxxxxxxxxx =
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, BB, CC>; yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as SomeTrait<AA, BB, CC>;
let xxxxxxxxxxxxxxx = let xxxxxxxxxxxxxxx =
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww): let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww)
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; 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() { fn issue3139() {
assert_eq!( assert_eq!(
to_json_value(&None::<i32>).unwrap(), 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 --> $DIR/equality-bound.rs:9:41
| |
LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 { LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 {
| ^ | ^ use of undeclared type `I`
| |
| use of undeclared type `I`
| help: a type parameter with a similar name exists: `J`
error: aborting due to 4 previous errors 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; LL | env::current_dir;
| ^^^ use of undeclared crate or module `env` | ^^^ 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` error[E0433]: failed to resolve: use of undeclared crate or module `panic`
--> $DIR/builtin-prelude-no-accidents.rs:6:14 --> $DIR/builtin-prelude-no-accidents.rs:6:14
| |
LL | type A = panic::PanicInfo; LL | type A = panic::PanicInfo;
| ^^^^^ use of undeclared crate or module `panic` | ^^^^^ 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 error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0433`. 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 error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:1:11 --> $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>; LL | type A3 = dyn<<dyn as dyn>::dyn>;
| ^^^ not found in this scope | ^^^ 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 error: aborting due to 8 previous errors
Some errors have detailed explanations: E0405, E0412, E0433. 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
--> $DIR/pattern-error-continue.rs:18:9 --> $DIR/pattern-error-continue.rs:18:9
| |
@ -50,15 +56,6 @@ note: function defined here
LL | fn f(_c: char) {} 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 error: aborting due to 5 previous errors
Some errors have detailed explanations: E0023, E0308, E0433, E0532. 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; LL | E::V::associated_item;
| ^ `V` is a variant, not a module | ^ `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 error[E0433]: failed to resolve: `V` is a variant, not a module
--> $DIR/resolve-variant-assoc-item.rs:6:5 --> $DIR/resolve-variant-assoc-item.rs:6:5
| |
LL | V::associated_item; LL | V::associated_item;
| ^ `V` is a variant, not a module | ^ `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 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` error[E0404]: expected trait, found struct `String`
--> $DIR/assoc_type_bound_with_struct.rs:5:46 --> $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 = 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 error: aborting due to 6 previous errors
Some errors have detailed explanations: E0404, E0405. 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 error[E0412]: cannot find type `Nonexistent` in this scope
--> $DIR/type-path-err-node-types.rs:7:12 --> $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>(); LL | nonexistent.nonexistent::<u8>();
| ^^^^^^^^^^^ not found in this scope | ^^^^^^^^^^^ 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 error[E0282]: type annotations needed
--> $DIR/type-path-err-node-types.rs:23:14 --> $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; LL | let _: <u8 as E::Y>::NN;
| ^ `Y` is a variant, not a module | ^ `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 error[E0433]: failed to resolve: `Y` is a variant, not a module
--> $DIR/ufcs-partially-resolved.rs:50:15 --> $DIR/ufcs-partially-resolved.rs:50:15
| |
LL | <u8 as E::Y>::NN; LL | <u8 as E::Y>::NN;
| ^ `Y` is a variant, not a module | ^ `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` error[E0576]: cannot find associated type `N` in trait `Tr`
--> $DIR/ufcs-partially-resolved.rs:19:24 --> $DIR/ufcs-partially-resolved.rs:19:24