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

adding move_iter() function to collections::treemap::TreeSet #14122

Merged
merged 1 commit into from
May 19, 2014
Merged

adding move_iter() function to collections::treemap::TreeSet #14122

merged 1 commit into from
May 19, 2014

Conversation

dagitses
Copy link
Contributor

This is my first patch and hopefully nothing controversial: just a straightforward forwarding of TreeMap::move_iter() as TreeSet::move_iter().

fn size_hint(&self) -> (uint, Option<uint>) {
self.iter.size_hint()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be expressible as an iter::Map iterator (one fewer struct!)

pub type MoveSetItems<T> = iter::Map<'static, (T, ()), T>;

(or something like that)

@dagitses
Copy link
Contributor Author

Hi Alex, I did as you suggested with a couple caveats:

  • For some reason, I had to add an "extern crate std" statement to the top of the file. I don't see that in too many places in the standard libraries, so it gave me some hesitation. It would not compile without this, regardless of if I specified core::iter::Map, std::iter::Map, or iter::Map.
  • I couldn't add "use std::iter::Map" due to the conflict with the core::container::Map from the prelude.

Thanks.

@alexcrichton
Copy link
Member

It may be better to have use std::iter; at the top of the file instead of extern crate std;, you'll then reference it via iter::Map instead of std::iter::Map.

@dagitses
Copy link
Contributor Author

Done.

@alexcrichton
Copy link
Member

Looks good to me, thanks! Could you squash the commits into one? Other than that, I think this is good to go!

@dagitses
Copy link
Contributor Author

Done.

@alexcrichton
Copy link
Member

It seems that a merge commit may have snuck in, perhaps a rebase gone awry?

@dagitses
Copy link
Contributor Author

Aha. There it is. Sorry about that.

bors added a commit that referenced this pull request May 19, 2014
This is my first patch and hopefully nothing controversial: just a straightforward forwarding of TreeMap::move_iter() as TreeSet::move_iter().
@bors bors closed this May 19, 2014
@bors bors merged commit 4353e44 into rust-lang:master May 19, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2023
…verflow, r=Veykril

fix: Don't expand macros in the same expansion tree after overflow

This patch fixes 2 bugs:

- In `Expander::enter_expand_id()` (and in code paths it's called), we never check whether we've reached the recursion limit. Although it hasn't been reported as far as I'm aware, this may cause hangs or stack overflows if some malformed attribute macro is used on associated items.
- We keep expansion even when recursion limit is reached. Take the following for example:

  ```rust
  macro_rules! foo { () => {{ foo!(); foo!(); }} }
  fn main() { foo!(); }
  ```

  We keep expanding the first `foo!()` in each expansion and would reach the limit at some point, *after which* we would try expanding the second `foo!()` in each expansion until it hits the limit again. This will (by default) lead to ~2^128 expansions.

  This is essentially what's happening in rust-lang#14074. Unlike rustc, we don't just stop expanding macros when we fail as long as it produces some tokens so that we can provide completions and other services in incomplete macro calls.

This patch provides a method that takes care of recursion depths (`Expander::within_limit()`) and stops macro expansions in the whole macro expansion tree once it detects recursion depth overflow. To be honest, I'm not really satisfied with this fix because it can still be used in unintended ways to bypass overflow checks, and I'm still seeking ways such that misuses are caught by the compiler by leveraging types or something.

Fixes rust-lang#14074
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 6, 2025
changelog: [`cmp_null`]: add autofix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants