mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
resolve: Simplify some diagnostic code to avoid an ICE
This commit is contained in:
parent
1d9c262eea
commit
a7d7a268e9
@ -696,14 +696,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||
) = &bounded_ty.kind
|
||||
{
|
||||
// use this to verify that ident is a type param.
|
||||
let Ok(Some(partial_res)) = self.resolve_qpath_anywhere(
|
||||
None,
|
||||
&Segment::from_path(path),
|
||||
Namespace::TypeNS,
|
||||
span,
|
||||
true,
|
||||
Finalize::No,
|
||||
) else {
|
||||
let Some(partial_res) = self.r.partial_res_map.get(&bounded_ty.id) else {
|
||||
return false;
|
||||
};
|
||||
if !(matches!(
|
||||
@ -718,16 +711,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||
return false;
|
||||
};
|
||||
|
||||
if let ast::TyKind::Path(None, type_param_path) = &ty.peel_refs().kind {
|
||||
let peeled_ty = ty.peel_refs();
|
||||
if let ast::TyKind::Path(None, type_param_path) = &peeled_ty.kind {
|
||||
// Confirm that the `SelfTy` is a type parameter.
|
||||
let Ok(Some(partial_res)) = self.resolve_qpath_anywhere(
|
||||
None,
|
||||
&Segment::from_path(type_param_path),
|
||||
Namespace::TypeNS,
|
||||
span,
|
||||
true,
|
||||
Finalize::No,
|
||||
) else {
|
||||
let Some(partial_res) = self.r.partial_res_map.get(&peeled_ty.id) else {
|
||||
return false;
|
||||
};
|
||||
if !(matches!(
|
||||
|
@ -16,4 +16,8 @@ fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String { //~ ERROR expected trait, f
|
||||
fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { //~ ERROR expected trait, found
|
||||
}
|
||||
|
||||
fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
|
||||
//~^ ERROR expected trait, found struct
|
||||
//~| ERROR use of undeclared type `Unresolved`
|
||||
|
||||
fn main() {}
|
||||
|
@ -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
|
||||
|
|
||||
@ -78,6 +84,18 @@ help: a trait with a similar name exists
|
||||
LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: ToString {
|
||||
| ~~~~~~~~
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error[E0404]: expected trait, found struct `String`
|
||||
--> $DIR/assoc_type_bound_with_struct.rs:19:51
|
||||
|
|
||||
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
|
||||
| ^^^^^^ help: a trait with a similar name exists: `ToString`
|
||||
|
|
||||
::: $SRC_DIR/alloc/src/string.rs:LL:COL
|
||||
|
|
||||
LL | pub trait ToString {
|
||||
| ------------------ similarly named trait `ToString` defined here
|
||||
|
||||
For more information about this error, try `rustc --explain E0404`.
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0404, E0433.
|
||||
For more information about an error, try `rustc --explain E0404`.
|
||||
|
Loading…
Reference in New Issue
Block a user