-
Notifications
You must be signed in to change notification settings - Fork 271
Update c2rust-refactor to nightly-2022-08-08 #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I reviewed 100/127 files. I'll review the rest a bit later. Left a few comments, but it generally all looks fine to my cursory review so far.
@@ -135,7 +136,7 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> { | |||
}; | |||
|
|||
let span = match &decl.local_info { | |||
LocalInfo::User(ClearCrossCrate::Set(binding)) => Some(binding), | |||
Some(box LocalInfo::User(ClearCrossCrate::Set(binding))) => Some(binding), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come we're using the box
keyword?
let (defaultness, generics, sig, body) = expect!([i.kind] | ||
ItemKind::Fn(box Fn { defaultness, generics, sig, body }) | ||
=> (defaultness, generics, sig, body)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's expect!
?
// Don't keep the old tokens. The callback could have made arbitrary changes to | ||
// the signature and body of the function. | ||
tokens: None, | ||
tokens: i.tokens.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still up-to-date?
if let ItemKind::Mod(_, ModKind::Loaded(ref mut items_ref, ..)) = i { | ||
let items = mem::replace(items_ref, vec![]); | ||
let mut curs = Cursor::from_vec(items); | ||
(self.f)(&mut curs); | ||
*items_ref = curs.into_vec(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to the indentation here?
Also, I think you could use mem::take
instead of mem::replace
here. Or not, cause the old code didn't do that.
extern crate env_logger; | ||
#[macro_use] | ||
extern crate log; | ||
#[macro_use] | ||
extern crate clap; | ||
extern crate c2rust_refactor; | ||
extern crate shlex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need any of these in Rust anymore.
let (path_qself, path_pattern) = match parse_path(&mut p) { | ||
Some(p) => p, | ||
None => return Err(Error::DefMismatch) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let (path_qself, path_pattern) = match parse_path(&mut p) { | |
Some(p) => p, | |
None => return Err(Error::DefMismatch) | |
}; | |
let (path_qself, path_pattern) = match parse_path(&mut p).ok_or(Error::DefMismatch)?; |
if self.try_match(&path_pattern, &def_path).is_err() { | ||
return Err(Error::DefMismatch); | ||
} | ||
if self.try_match(&path_qself, &def_qself).is_err() { | ||
return Err(Error::DefMismatch); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.try_match(&path_pattern, &def_path).is_err() { | |
return Err(Error::DefMismatch); | |
} | |
if self.try_match(&path_qself, &def_qself).is_err() { | |
return Err(Error::DefMismatch); | |
} | |
self.try_match(&path_pattern, &def_path).map_err(|_| Error::DefMismatch)?; | |
self.try_match(&path_qself, &def_qself).map_err(|_| Error::DefMismatch)?; |
!matches!([i.kind] ItemKind::Impl(_, _, _, _, None, _, _)) { | ||
matches!(i.kind, ItemKind::Impl(box Impl { of_trait: None, .. })) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this is inverted?
let (unsafety, polarity, generics, constness, | ||
defaultness, of_trait, self_ty, mut items) = expect!([i.kind] ItemKind::Impl(box Impl { | ||
unsafety, polarity, generics, constness, | ||
defaultness, of_trait, self_ty, items | ||
}) => (unsafety, polarity, generics, constness, | ||
defaultness, of_trait, self_ty, items | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to use let ... = i.kind else { panic!() }
but I don't think that was in 1.65 yet.
let unused = result | ||
.unused_unsafes | ||
.as_deref() | ||
.unwrap_or_else(|| &[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does .unwrap_or_default()
work?
497f587
to
a0477c2
Compare
Update the refactoring tool to build and run with the same Rust nightly as the transpiler.