Skip to content

Fix misleading comments #920

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

Merged
merged 1 commit into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ir/analysis/derive_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
// default, the may have an explicit destructor in C++, so we can't
// defer this check just for the union case.
if info.has_destructor(self.ctx) {
trace!(" comp has destructor which cannot derive copy");
trace!(" comp has destructor which cannot derive Copy");
return self.insert(id);
}

Expand All @@ -211,7 +211,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
// NOTE: If there's no template parameters we can derive copy
// unconditionally, since arrays are magical for rustc, and
// __BindgenUnionField always implements copy.
trace!(" comp can always derive debug if it's a Union and no template parameters");
trace!(" comp can always derive Copy if it's a Union and no template parameters");
return ConstrainResult::Same
}

Expand Down
8 changes: 4 additions & 4 deletions src/ir/analysis/derive_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct CannotDeriveDefault<'ctx, 'gen>
ctx: &'ctx BindgenContext<'gen>,

// The incremental result of this analysis's computation. Everything in this
// set cannot derive debug.
// set cannot derive default.
cannot_derive_default: HashSet<ItemId>,

// Dependencies saying that if a key ItemId has been inserted into the
Expand All @@ -45,15 +45,15 @@ pub struct CannotDeriveDefault<'ctx, 'gen>
//
// This is a subset of the natural IR graph with reversed edges, where we
// only include the edges from the IR graph that can affect whether a type
// can derive debug or not.
// can derive default or not.
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx, 'gen> CannotDeriveDefault<'ctx, 'gen> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
// debug or not.
// default or not.
EdgeKind::BaseMember |
EdgeKind::Field |
EdgeKind::TypeReference |
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDefault<'ctx, 'gen> {
}

match *ty.kind() {
// Handle the simple cases. These can derive debug without further
// Handle the simple cases. These can derive Default without further
// information.
TypeKind::Function(..) |
TypeKind::Int(..) |
Expand Down
8 changes: 4 additions & 4 deletions src/ir/analysis/has_type_param_in_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ pub struct HasTypeParameterInArray<'ctx, 'gen>
impl<'ctx, 'gen> HasTypeParameterInArray<'ctx, 'gen> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
// debug or not.
// These are the only edges that can affect whether a type has type parameter
// in array or not.
EdgeKind::BaseMember |
EdgeKind::Field |
EdgeKind::TypeReference |
Expand Down Expand Up @@ -119,8 +119,8 @@ impl<'ctx, 'gen> MonotoneFramework for HasTypeParameterInArray<'ctx, 'gen> {
};

match *ty.kind() {
// Handle the simple cases. These can derive copy without further
// information.
// Handle the simple cases. These cannot have array in type parameter
// without further information.
TypeKind::Void |
TypeKind::NullPtr |
TypeKind::Int(..) |
Expand Down
14 changes: 7 additions & 7 deletions src/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ pub struct BindgenContext<'ctx> {

/// The set of (`ItemId`s of) types that can't derive debug.
///
/// This is populated when we enter codegen by `compute_can_derive_debug`
/// This is populated when we enter codegen by `compute_cannot_derive_debug`
/// and is always `None` before that and `Some` after.
cannot_derive_debug: Option<HashSet<ItemId>>,

/// The set of (`ItemId`s of) types that can't derive default.
///
/// This is populated when we enter codegen by `compute_can_derive_default`
/// This is populated when we enter codegen by `compute_cannot_derive_default`
/// and is always `None` before that and `Some` after.
cannot_derive_default: Option<HashSet<ItemId>>,

Expand Down Expand Up @@ -1839,7 +1839,7 @@ impl<'ctx> BindgenContext<'ctx> {
!self.cannot_derive_default.as_ref().unwrap().contains(&id)
}

/// Compute whether we can derive debug.
/// Compute whether we can derive copy.
fn compute_cannot_derive_copy(&mut self) {
assert!(self.cannot_derive_copy.is_none());
self.cannot_derive_copy = Some(analyze::<CannotDeriveCopy>(self));
Expand All @@ -1864,7 +1864,7 @@ impl<'ctx> BindgenContext<'ctx> {
!self.cannot_derive_hash.as_ref().unwrap().contains(&id)
}

/// Compute whether we can derive hash.
/// Compute whether we can derive partialeq.
fn compute_cannot_derive_partialeq(&mut self) {
assert!(self.cannot_derive_partialeq.is_none());
if self.options.derive_partialeq {
Expand Down Expand Up @@ -1895,19 +1895,19 @@ impl<'ctx> BindgenContext<'ctx> {
!self.cannot_derive_copy.as_ref().unwrap().contains(&id)
}

/// Compute whether the type has array.
/// Compute whether the type has type parameter in array.
fn compute_has_type_param_in_array(&mut self) {
assert!(self.has_type_param_in_array.is_none());
self.has_type_param_in_array = Some(analyze::<HasTypeParameterInArray>(self));
}

/// Look up whether the item with `id` has array or not.
/// Look up whether the item with `id` has type parameter in array or not.
pub fn lookup_item_id_has_type_param_in_array(&self, id: &ItemId) -> bool {
assert!(self.in_codegen_phase(),
"We only compute has array when we enter codegen");

// Look up the computed value for whether the item with `id` has
// array or not.
// type parameter in array or not.
self.has_type_param_in_array.as_ref().unwrap().contains(id)
}
}
Expand Down