mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Remove UserError from LayoutError
This commit is contained in:
parent
e844784d8d
commit
b74015512d
4 changed files with 42 additions and 32 deletions
|
@ -145,7 +145,7 @@ pub fn layout_of_adt_recover(
|
|||
_: &Substitution,
|
||||
_: &Arc<TraitEnvironment>,
|
||||
) -> Result<Arc<Layout>, LayoutError> {
|
||||
user_error!("infinite sized recursive type");
|
||||
Err(LayoutError::RecursiveTypeWithoutIndirection)
|
||||
}
|
||||
|
||||
/// Finds the appropriate Integer type and signedness for the given
|
||||
|
@ -169,11 +169,7 @@ fn repr_discr(
|
|||
let discr = Integer::from_attr(dl, ity);
|
||||
let fit = if ity.is_signed() { signed_fit } else { unsigned_fit };
|
||||
if discr < fit {
|
||||
return Err(LayoutError::UserError(
|
||||
"Integer::repr_discr: `#[repr]` hint too small for \
|
||||
discriminant range of enum "
|
||||
.into(),
|
||||
));
|
||||
return Err(LayoutError::UserReprTooSmall);
|
||||
}
|
||||
return Ok((discr, ity.is_signed()));
|
||||
}
|
||||
|
|
|
@ -210,16 +210,13 @@ fn recursive() {
|
|||
struct BoxLike<T: ?Sized>(*mut T);
|
||||
struct Goal(BoxLike<Goal>);
|
||||
}
|
||||
check_fail(
|
||||
r#"struct Goal(Goal);"#,
|
||||
LayoutError::UserError("infinite sized recursive type".into()),
|
||||
);
|
||||
check_fail(r#"struct Goal(Goal);"#, LayoutError::RecursiveTypeWithoutIndirection);
|
||||
check_fail(
|
||||
r#"
|
||||
struct Foo<T>(Foo<T>);
|
||||
struct Goal(Foo<i32>);
|
||||
"#,
|
||||
LayoutError::UserError("infinite sized recursive type".into()),
|
||||
LayoutError::RecursiveTypeWithoutIndirection,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue