mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-09 16:37:36 +00:00
Avoid follow up errors
This commit is contained in:
parent
972c95a6e2
commit
0e82aaeb67
@ -134,6 +134,21 @@ impl TaitConstraintLocator<'_> {
|
|||||||
debug!("no constraint: no typeck results");
|
debug!("no constraint: no typeck results");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(hir_sig) = self.tcx.hir_node_by_def_id(item_def_id).fn_decl() {
|
||||||
|
if hir_sig.output.get_infer_ret_ty().is_some() {
|
||||||
|
let guar = self.tcx.dcx().span_delayed_bug(
|
||||||
|
hir_sig.output.span(),
|
||||||
|
"inferring return types and opaque types do not mix well",
|
||||||
|
);
|
||||||
|
self.found = Some(ty::OpaqueHiddenType {
|
||||||
|
span: DUMMY_SP,
|
||||||
|
ty: Ty::new_error(self.tcx, guar),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Calling `mir_borrowck` can lead to cycle errors through
|
// Calling `mir_borrowck` can lead to cycle errors through
|
||||||
// const-checking, avoid calling it if we don't have to.
|
// const-checking, avoid calling it if we don't have to.
|
||||||
// ```rust
|
// ```rust
|
||||||
|
@ -6,9 +6,7 @@ type Pointer<T> = impl std::ops::Deref<Target = T>;
|
|||||||
|
|
||||||
fn test() -> Pointer<_> {
|
fn test() -> Pointer<_> {
|
||||||
//~^ ERROR: the placeholder `_` is not allowed within types
|
//~^ ERROR: the placeholder `_` is not allowed within types
|
||||||
//~| ERROR: non-defining opaque type use in defining scope
|
|
||||||
Box::new(1)
|
Box::new(1)
|
||||||
//~^ ERROR expected generic type parameter, found `i32`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -7,28 +7,6 @@ LL | fn test() -> Pointer<_> {
|
|||||||
| | not allowed in type signatures
|
| | not allowed in type signatures
|
||||||
| help: replace with the correct return type: `Pointer<i32>`
|
| help: replace with the correct return type: `Pointer<i32>`
|
||||||
|
|
||||||
error[E0792]: non-defining opaque type use in defining scope
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/issue-77179.rs:7:14
|
|
||||||
|
|
|
||||||
LL | fn test() -> Pointer<_> {
|
|
||||||
| ^^^^^^^^^^ argument `i32` is not a generic parameter
|
|
||||||
|
|
|
||||||
note: for this opaque type
|
|
||||||
--> $DIR/issue-77179.rs:5:19
|
|
||||||
|
|
|
||||||
LL | type Pointer<T> = impl std::ops::Deref<Target = T>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0792]: expected generic type parameter, found `i32`
|
For more information about this error, try `rustc --explain E0121`.
|
||||||
--> $DIR/issue-77179.rs:10:5
|
|
||||||
|
|
|
||||||
LL | type Pointer<T> = impl std::ops::Deref<Target = T>;
|
|
||||||
| - this generic parameter must be used with a generic type parameter
|
|
||||||
...
|
|
||||||
LL | Box::new(1)
|
|
||||||
| ^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0121, E0792.
|
|
||||||
For more information about an error, try `rustc --explain E0121`.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user