Skip to content
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

Fix errors when using rust-analyzer with canister method attributes #237

Merged
merged 2 commits into from
Dec 2, 2024
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
2 changes: 1 addition & 1 deletion ic-auction/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub struct Controller<'a> {
state: &'a mut AuctionState,
}

impl<'a> Authorized<Controller<'a>> {
impl Authorized<Controller<'_>> {
pub fn set_min_cycles(&mut self, min_cycles: Cycles) {
self.auth.state.min_cycles = min_cycles;
}
Expand Down
12 changes: 1 addition & 11 deletions ic-canister/ic-canister-macros/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,7 @@ fn store_candid_definitions(modes: &str, sig: &Signature) -> Result<(), syn::Err
}

if modes == "init" {
match &mut *INIT.lock().unwrap() {
Some(_) => return Err(Error::new_spanned(&sig.ident, "duplicate init method")),
ret @ None => *ret = Some(args),
}
*INIT.lock().unwrap() = Some(args);
return Ok(());
}

Expand All @@ -530,13 +527,6 @@ fn store_candid_definitions(modes: &str, sig: &Signature) -> Result<(), syn::Err
// Insert method
let mut map = METHODS.lock().unwrap();

if map.contains_key(&name) {
return Err(Error::new_spanned(
&name,
format!("duplicate method name {name}"),
));
}

let method = Method {
args,
rets,
Expand Down
2 changes: 1 addition & 1 deletion ic-log/src/formatter/humantime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl fmt::Debug for Rfc3339Timestamp {
/// A `Debug` wrapper for `Timestamp` that uses the `Display` implementation.
struct TimestampValue<'a>(&'a Rfc3339Timestamp);

impl<'a> fmt::Debug for TimestampValue<'a> {
impl fmt::Debug for TimestampValue<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
Expand Down
4 changes: 2 additions & 2 deletions ic-log/src/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct DefaultFormat<'a> {
suffix: &'a str,
}

impl<'a> DefaultFormat<'a> {
impl DefaultFormat<'_> {
fn write(mut self, record: &Record) -> io::Result<()> {
self.write_timestamp()?;
self.write_level(record)?;
Expand Down Expand Up @@ -250,7 +250,7 @@ impl<'a> DefaultFormat<'a> {
indent_count: usize,
}

impl<'a, 'b> Write for IndentWrapper<'a, 'b> {
impl Write for IndentWrapper<'_, '_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
let mut first = true;
for chunk in buf.split(|&x| x == b'\n') {
Expand Down
4 changes: 2 additions & 2 deletions ic-stable-structures/src/structure/stable_storage/multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
// -----------------------------------------------------------------------------
// - Range Iterator impl -
// -----------------------------------------------------------------------------
impl<'a, K1, K2, V, M> Iterator for StableMultimapRangeIter<'a, K1, K2, V, M>
impl<K1, K2, V, M> Iterator for StableMultimapRangeIter<'_, K1, K2, V, M>
where
K1: Storable + Ord + Clone,
K2: Storable + Ord + Clone,
Expand Down Expand Up @@ -165,7 +165,7 @@ where
}
}

impl<'a, K1, K2, V, M> Iterator for StableMultimapIter<'a, K1, K2, V, M>
impl<K1, K2, V, M> Iterator for StableMultimapIter<'_, K1, K2, V, M>
where
K1: Storable + Ord + Clone,
K2: Storable + Ord + Clone,
Expand Down