Skip to content

Commit

Permalink
[cm] Trivial: Elide unneccessary lifetime parameters on async functions.
Browse files Browse the repository at this point in the history
Rust previously had a bug [1] where these lifetimes were incorrectly
inferred, and required manual annotations. The rust issue has now been
resolved, so we can now elide these lifetimes.

[1]: rust-lang/rust#63388

Change-Id: I26ceead7fe5e4165b07280705567fbef0e56c7b0
  • Loading branch information
davidgreenaway authored and CQ bot account: commit-bot@chromium.org committed Nov 7, 2019
1 parent 289bb61 commit 6f8ae14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
25 changes: 11 additions & 14 deletions src/sys/component_manager/src/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ impl Model {

/// Given a realm and path, lazily bind to the instance in the realm, open its outgoing
/// directory at that path, then bind its eager children.
pub async fn bind_instance_open_outgoing<'a>(
&'a self,
pub async fn bind_instance_open_outgoing(
&self,
realm: Arc<Realm>,
flags: u32,
open_mode: u32,
path: &'a CapabilityPath,
path: &CapabilityPath,
server_chan: zx::Channel,
) -> Result<(), ModelError> {
let eager_children = {
Expand Down Expand Up @@ -160,8 +160,8 @@ impl Model {

/// Given a realm and path, lazily bind to the instance in the realm, open its exposed
/// directory, then bind its eager children.
pub async fn bind_instance_open_exposed<'a>(
&'a self,
pub async fn bind_instance_open_exposed(
&self,
realm: Arc<Realm>,
server_chan: zx::Channel,
) -> Result<(), ModelError> {
Expand Down Expand Up @@ -204,9 +204,9 @@ impl Model {

/// Looks up a realm by absolute moniker. The component instance in the realm will be resolved
/// if that has not already happened.
pub async fn look_up_realm<'a>(
&'a self,
look_up_abs_moniker: &'a AbsoluteMoniker,
pub async fn look_up_realm(
&self,
look_up_abs_moniker: &AbsoluteMoniker,
) -> Result<Arc<Realm>, ModelError> {
let mut cur_realm = self.root_realm.clone();
for moniker in look_up_abs_moniker.path().iter() {
Expand All @@ -229,10 +229,7 @@ impl Model {
/// already running. Returns the list of child realms whose instances need to be eagerly started
/// after this function returns. The caller is responsible for calling
/// bind_eager_children_recursive themselves to ensure eager children are recursively binded.
async fn bind_single_instance<'a>(
&'a self,
realm: Arc<Realm>,
) -> Result<Vec<Arc<Realm>>, ModelError> {
async fn bind_single_instance(&self, realm: Arc<Realm>) -> Result<Vec<Arc<Realm>>, ModelError> {
let eager_children = self.bind_inner(realm.clone()).await?;
let event = {
let routing_facade = RoutingFacade::new(self.clone());
Expand All @@ -251,8 +248,8 @@ impl Model {
}

/// Binds to a list of instances, and any eager children they may return.
async fn bind_eager_children_recursive<'a>(
&'a self,
async fn bind_eager_children_recursive(
&self,
mut instances_to_bind: Vec<Arc<Realm>>,
) -> Result<(), ModelError> {
loop {
Expand Down
26 changes: 13 additions & 13 deletions src/sys/component_manager/src/model/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ impl Realm {
/// Resolves and populates this component's meta directory handle if it has not been done so
/// already, and returns a reference to the handle. If this component does not use meta storage
/// Ok(None) will be returned.
pub async fn resolve_meta_dir<'a>(
&'a self,
model: &'a Model,
pub async fn resolve_meta_dir(
&self,
model: &Model,
) -> Result<Option<Arc<DirectoryProxy>>, ModelError> {
{
// If our meta directory has already been resolved, just return the answer.
Expand Down Expand Up @@ -151,10 +151,10 @@ impl Realm {

/// Adds the dynamic child defined by `child_decl` to the given `collection_name`. Once
/// added, the component instance exists but is not bound.
pub async fn add_dynamic_child<'a>(
&'a self,
pub async fn add_dynamic_child(
&self,
collection_name: String,
child_decl: &'a ChildDecl,
child_decl: &ChildDecl,
) -> Result<(), ModelError> {
match child_decl.startup {
fsys::StartupMode::Lazy => {}
Expand Down Expand Up @@ -196,10 +196,10 @@ impl Realm {
}

/// Removes the dynamic child `partial_moniker`.
pub async fn remove_dynamic_child<'a>(
pub async fn remove_dynamic_child(
model: Model,
realm: Arc<Realm>,
partial_moniker: &'a PartialMoniker,
partial_moniker: &PartialMoniker,
) -> Result<(), ModelError> {
realm.resolve_decl().await?;
let mut state = realm.lock_state().await;
Expand Down Expand Up @@ -455,10 +455,10 @@ impl RealmState {

/// Adds a new child of this realm for the given `ChildDecl`. Returns the child realm,
/// or None if it already existed.
async fn add_child_realm<'a>(
&'a mut self,
realm: &'a Realm,
child: &'a ChildDecl,
async fn add_child_realm(
&mut self,
realm: &Realm,
child: &ChildDecl,
collection: Option<String>,
) -> Option<Arc<Realm>> {
let instance_id = match collection {
Expand Down Expand Up @@ -491,7 +491,7 @@ impl RealmState {
}
}

async fn add_static_child_realms<'a>(&'a mut self, realm: &'a Realm, decl: &'a ComponentDecl) {
async fn add_static_child_realms(&mut self, realm: &Realm, decl: &ComponentDecl) {
for child in decl.children.iter() {
self.add_child_realm(realm, child, None).await;
}
Expand Down

0 comments on commit 6f8ae14

Please sign in to comment.