mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 07:10:29 +00:00
Handle unrecognized type names in checking signature for mutable return type
This commit is contained in:
parent
e59625a9d4
commit
06ef96fa5f
@ -521,7 +521,10 @@ fn check_mut_return_restriction(cx: &mut Check, efn: &ExternFn) {
|
||||
if receiver.mutable {
|
||||
return;
|
||||
}
|
||||
let resolve = cx.types.resolve(&receiver.ty);
|
||||
let resolve = match cx.types.try_resolve(&receiver.ty) {
|
||||
Some(resolve) => resolve,
|
||||
None => return,
|
||||
};
|
||||
if !resolve.generics.lifetimes.is_empty() {
|
||||
return;
|
||||
}
|
||||
@ -536,9 +539,11 @@ fn check_mut_return_restriction(cx: &mut Check, efn: &ExternFn) {
|
||||
fn visit_type(&mut self, ty: &'t Type) {
|
||||
self.found |= match ty {
|
||||
Type::Ref(ty) => ty.mutable,
|
||||
Type::Ident(ident) => {
|
||||
let resolve = self.cx.types.resolve(ident);
|
||||
!resolve.generics.lifetimes.is_empty()
|
||||
Type::Ident(ident) if Atom::from(&ident.rust).is_none() => {
|
||||
match self.cx.types.try_resolve(ident) {
|
||||
Some(resolve) => !resolve.generics.lifetimes.is_empty(),
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
|
@ -11,11 +11,16 @@ pub struct Resolution<'a> {
|
||||
impl<'a> Types<'a> {
|
||||
pub fn resolve(&self, ident: &impl UnresolvedName) -> Resolution<'a> {
|
||||
let ident = ident.ident();
|
||||
match self.resolutions.get(ident) {
|
||||
Some(resolution) => *resolution,
|
||||
match self.try_resolve(ident) {
|
||||
Some(resolution) => resolution,
|
||||
None => panic!("Unable to resolve type `{}`", ident),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_resolve(&self, ident: &impl UnresolvedName) -> Option<Resolution<'a>> {
|
||||
let ident = ident.ident();
|
||||
self.resolutions.get(ident).copied()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait UnresolvedName {
|
||||
|
Loading…
Reference in New Issue
Block a user