mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
only downgrade Error -> Ambiguous if type error is in predicate
This commit is contained in:
parent
8f36334ca9
commit
7bd22e29d0
@ -231,8 +231,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
// `Err(Unimplemented)` to `Ok(None)`. This helps us avoid
|
// `Err(Unimplemented)` to `Ok(None)`. This helps us avoid
|
||||||
// emitting additional spurious errors, since we're guaranteed
|
// emitting additional spurious errors, since we're guaranteed
|
||||||
// to have emitted at least one.
|
// to have emitted at least one.
|
||||||
if stack.obligation.references_error() {
|
if stack.obligation.predicate.references_error() {
|
||||||
debug!("no results for error type, treating as ambiguous");
|
debug!(?stack.obligation.predicate, "found error type in predicate, treating as ambiguous");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
return Err(Unimplemented);
|
return Err(Unimplemented);
|
||||||
|
@ -8,15 +8,7 @@ where
|
|||||||
//~^ ERROR cannot find type `T` in this scope
|
//~^ ERROR cannot find type `T` in this scope
|
||||||
//~| NOTE not found in this scope
|
//~| NOTE not found in this scope
|
||||||
{
|
{
|
||||||
// The part where it claims that there is no method named `len` is a bug. Feel free to fix it.
|
|
||||||
// This test is intended to ensure that a different bug, where it claimed
|
|
||||||
// that `v` was a function, does not regress.
|
|
||||||
fn method(v: Vec<u8>) { v.len(); }
|
fn method(v: Vec<u8>) { v.len(); }
|
||||||
//~^ ERROR type annotations needed
|
|
||||||
//~| NOTE cannot infer type
|
|
||||||
//~| NOTE type must be known at this point
|
|
||||||
//~| ERROR no method named `len`
|
|
||||||
//~| NOTE private field, not a method
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -12,21 +12,6 @@ error[E0412]: cannot find type `T` in this scope
|
|||||||
LL | T: Copy,
|
LL | T: Copy,
|
||||||
| ^ not found in this scope
|
| ^ not found in this scope
|
||||||
|
|
||||||
error[E0282]: type annotations needed
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31
|
|
||||||
|
|
|
||||||
LL | fn method(v: Vec<u8>) { v.len(); }
|
|
||||||
| ^^^ cannot infer type
|
|
||||||
|
|
|
||||||
= note: type must be known at this point
|
|
||||||
|
|
||||||
error[E0599]: no method named `len` found for struct `Vec<u8>` in the current scope
|
For more information about this error, try `rustc --explain E0412`.
|
||||||
--> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31
|
|
||||||
|
|
|
||||||
LL | fn method(v: Vec<u8>) { v.len(); }
|
|
||||||
| ^^^ private field, not a method
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0282, E0412, E0599.
|
|
||||||
For more information about an error, try `rustc --explain E0282`.
|
|
||||||
|
9
src/test/ui/typeck/autoderef-with-param-env-error.rs
Normal file
9
src/test/ui/typeck/autoderef-with-param-env-error.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fn foo()
|
||||||
|
where
|
||||||
|
T: Send,
|
||||||
|
//~^ cannot find type `T` in this scope
|
||||||
|
{
|
||||||
|
let s = "abc".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
12
src/test/ui/typeck/autoderef-with-param-env-error.stderr
Normal file
12
src/test/ui/typeck/autoderef-with-param-env-error.stderr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
error[E0412]: cannot find type `T` in this scope
|
||||||
|
--> $DIR/autoderef-with-param-env-error.rs:3:5
|
||||||
|
|
|
||||||
|
LL | fn foo()
|
||||||
|
| - help: you might be missing a type parameter: `<T>`
|
||||||
|
LL | where
|
||||||
|
LL | T: Send,
|
||||||
|
| ^ not found in this scope
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0412`.
|
Loading…
Reference in New Issue
Block a user