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

Replace syntax's SmallVector with AccumulateVec #37551

Merged
merged 1 commit into from Nov 12, 2016

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Nov 3, 2016

This adds a new type to data_structures, SmallVec, which wraps AccumulateVec with support for re-allocating onto the heap (SmallVec::reserve). SmallVec is then used to replace the implementation of SmallVector in libsyntax.

r? @eddyb

Fixes #37371. Using SmallVec instead of libsyntax's SmallVector will provide the N = 2/4 case easily (just needs a few more Array impls).

cc @nnethercote, probably interested in this area

@Mark-Simulacrum
Copy link
Member Author

Also cc #37371, which has some discussion on expanding/generalizing SmallVector.

_ => unreachable!()
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This code would look better with @ticki's replace_with, but it's not altogether that bad without either.

@arielb1
Copy link
Contributor

arielb1 commented Nov 5, 2016

AccumulateVec intentionally can't change its capacity once created, because that improves LLVM's optimizations.

LLVM gets confused by reserve functions that can't be reached in practice.

@eddyb
Copy link
Member

eddyb commented Nov 5, 2016

There should probably be two types still, at least a SmallVec type wrapping the existing AccumulateVec, providing the extended API, until someone can prove merging them results in no losses (keep in mind that AccumulateVec may use the heap for less than its inline size, if the hint was too pessimistic).

@Mark-Simulacrum
Copy link
Member Author

Mark-Simulacrum commented Nov 5, 2016

Alright, the implementation now consists of small_vec.rs having push capability (and as such re-sizeable).

This currently doesn't compile, but I don't know why--from what I can tell, I didn't change the method signatures shown here.

rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsyntax
error[E0507]: cannot move out of borrowed content
   --> src/libsyntax/fold.rs:610:27
    |
610 |             token::NtItem(fld.fold_item(item)
    |                           ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
   --> src/libsyntax/fold.rs:617:43
    |
617 |             token::NtStmt(stmt.map(|stmt| fld.fold_stmt(stmt)
    |                                           ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
   --> src/libsyntax/fold.rs:632:45
    |
632 |             token::NtImplItem(arm.map(|arm| fld.fold_impl_item(arm)
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
   --> src/libsyntax/fold.rs:635:46
    |
635 |             token::NtTraitItem(arm.map(|arm| fld.fold_trait_item(arm)
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
   --> src/libsyntax/test.rs:183:22
    |
183 |         let folded = fold::noop_fold_item(i, self).expect_one("noop did something");
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content

error: aborting due to 5 previous errors

Edit: Also, as a sidenote, this error message could really be improved: I can't tell what is being moved out of borrowed content. cc @jonathandturner.

@arielb1
Copy link
Contributor

arielb1 commented Nov 5, 2016

That's an odd error - are you sure you didn't change a signature by accident?

@Mark-Simulacrum Mark-Simulacrum force-pushed the upgrade-accvec branch 2 times, most recently from 743fb75 to 1894f71 Compare November 5, 2016 23:51
@Mark-Simulacrum Mark-Simulacrum changed the title Implement methods from syntax's SmallVector on AccumulateVec. [WIP] Replace syntax's SmallVector with AccumulateVec Nov 6, 2016
@Mark-Simulacrum
Copy link
Member Author

The current code segfaults with this backtrace. I don't know why this is, and would appreciate any suggestions.

#0  core::cell::{{impl}}::set<usize> (value=6215344901283465300, self=<optimized out>) at /home/mark/Edit/rust/src/libcore/cell.rs:239
#1  alloc::rc::RcBoxPtr::dec_strong<alloc::rc::Rc<syntax::tokenstream::Delimited>,syntax::tokenstream::Delimited> (self=0x7fd537eedd98) at /home/mark/Edit/rust/src/liballoc/rc.rs:1115
#2  alloc::rc::{{impl}}::drop<syntax::tokenstream::Delimited> (self=0x7fd537eedd98) at /home/mark/Edit/rust/src/liballoc/rc.rs:648
#3  0x00007fd53a4156ad in rustc_data_structures::array_vec::{{impl}}::push<[syntax::ext::tt::transcribe::TtFrame; 1]> (self=0x7fd537eedd80, el=...) at /home/mark/Edit/rust/src/librustc_data_structures/array_vec.rs:70
#4  0x00007fd53a42708e in rustc_data_structures::array_vec::{{impl}}::extend<[syntax::ext::tt::transcribe::TtFrame; 1],core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>> (self=<optimized out>, iter=...)
    at /home/mark/Edit/rust/src/librustc_data_structures/array_vec.rs:132
#5  rustc_data_structures::accumulate_vec::{{impl}}::from_iter<[syntax::ext::tt::transcribe::TtFrame; 1],core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>> (iter=...)
    at /home/mark/Edit/rust/src/librustc_data_structures/accumulate_vec.rs:112
#6  core::iter::iterator::Iterator::collect<core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>,rustc_data_structures::accumulate_vec::AccumulateVec<[syntax::ext::tt::transcribe::TtFrame; 1]>> (self=...)
    at /home/mark/Edit/rust/src/libcore/iter/iterator.rs:1196
#7  rustc_data_structures::accumulate_vec::{{impl}}::one<[syntax::ext::tt::transcribe::TtFrame; 1]> (el=...) at /home/mark/Edit/rust/src/librustc_data_structures/accumulate_vec.rs:48
#8  rustc_data_structures::small_vec::{{impl}}::one<[syntax::ext::tt::transcribe::TtFrame; 1]> (el=...) at /home/mark/Edit/rust/src/librustc_data_structures/small_vec.rs:51
#9  syntax::ext::tt::transcribe::new_tt_reader_with_doc_flag (sp_diag=0x7fd537f0a108, interp=..., src=..., desugar_doc_comments=<error reading variable: access outside bounds of object referenced via synthetic pointer>)
    at /home/mark/Edit/rust/src/libsyntax/ext/tt/transcribe.rs:78
#10 0x00007fd53a426bb2 in syntax::ext::tt::transcribe::new_tt_reader (sp_diag=0x0, interp=..., src=...) at /home/mark/Edit/rust/src/libsyntax/ext/tt/transcribe.rs:62
#11 0x00007fd53a285981 in syntax::parse::tts_to_parser (sess=0x7fd537f0a108, tts=...) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:217
#12 0x00007fd53a28543a in syntax::parse::filemap_to_parser (sess=0x7fd537f0a108, filemap=...) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:166
#13 0x00007fd53a28537b in syntax::parse::new_sub_parser_from_file (sess=0x7fd537f0a108, path=<optimized out>, owns_directory=false, module_name=..., sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:157
#14 0x00007fd53a3209d3 in syntax::parse::parser::{{impl}}::eval_src_mod_from_path (self=<optimized out>, path=..., owns_directory=<optimized out>, name=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5492
#15 syntax::parse::parser::{{impl}}::eval_src_mod (self=0x7fd537efa610, id=..., outer_attrs=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5467
#16 0x00007fd53a32742c in syntax::parse::parser::{{impl}}::parse_item_mod (outer_attrs=..., self=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5339
#17 syntax::parse::parser::{{impl}}::parse_item_ (self=<optimized out>, attrs=..., macros_allowed=<optimized out>, attributes_allowed=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5919
#18 0x00007fd53a330a06 in syntax::parse::parser::{{impl}}::parse_item (self=0x7fd537efa610) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6097
#19 0x00007fd53a31ed3b in syntax::parse::parser::{{impl}}::parse_mod_items (self=<optimized out>, term=0x7fd53a443238 <ref24582>, inner_lo=BytePos = {...}) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5286
#20 0x00007fd53a320bdc in syntax::parse::parser::{{impl}}::eval_src_mod_from_path (self=<optimized out>, path=..., owns_directory=<optimized out>, name=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5495
#21 syntax::parse::parser::{{impl}}::eval_src_mod (self=0x7fd537f052b0, id=..., outer_attrs=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5467
#22 0x00007fd53a32742c in syntax::parse::parser::{{impl}}::parse_item_mod (outer_attrs=..., self=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5339
#23 syntax::parse::parser::{{impl}}::parse_item_ (self=<optimized out>, attrs=..., macros_allowed=<optimized out>, attributes_allowed=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5919
#24 0x00007fd53a330a06 in syntax::parse::parser::{{impl}}::parse_item (self=0x7fd537f052b0) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6097
#25 0x00007fd53a31ed3b in syntax::parse::parser::{{impl}}::parse_mod_items (self=<optimized out>, term=0x7fd53a443238 <ref24582>, inner_lo=BytePos = {...}) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5286
#26 0x00007fd53a33182b in syntax::parse::parser::{{impl}}::parse_crate_mod (self=0x7fd537f052b0) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6185
#27 0x00007fd53a284c18 in syntax::parse::parse_crate_from_file (input=<optimized out>, sess=0x7fd537f0a108) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:85
#28 0x00007fd5417d43a2 in rustc_driver::driver::phase_1_parse_input::{{closure}} () at /home/mark/Edit/rust/src/librustc_driver/driver.rs:493
#29 rustc::util::common::time<core::result::Result<syntax::ast::Crate, rustc_errors::diagnostic_builder::DiagnosticBuilder>,closure> (what=<error reading variable: access outside bounds of object referenced via synthetic pointer>,
    do_it=<optimized out>, f=...) at /home/mark/Edit/rust/src/librustc/util/common.rs:38
#30 rustc_driver::driver::phase_1_parse_input (sess=0x7fd537f096e0, input=0x7fd537f0ab80) at /home/mark/Edit/rust/src/librustc_driver/driver.rs:490
#31 0x00007fd5417cf57b in rustc_driver::driver::compile_input (sess=0x0, cstore=0x7fd530009d40, input=0x7fd537f0ab80, outdir=0x7fd537f0ab68, output=0x7fd537f0ab48, addl_plugins=..., control=0x7fd537f09648)
    at /home/mark/Edit/rust/src/librustc_driver/driver.rs:95
#32 0x00007fd54188a42d in rustc_driver::run_compiler (args=..., callbacks=..., file_loader=..., emitter_dest=...) at /home/mark/Edit/rust/src/librustc_driver/lib.rs:222
#33 0x00007fd54187b252 in rustc_driver::main::{{closure}} () at /home/mark/Edit/rust/src/librustc_driver/lib.rs:1138
#34 rustc_driver::run::{{closure}}<closure> () at /home/mark/Edit/rust/src/librustc_driver/lib.rs:138
#35 rustc_driver::monitor::{{closure}}<closure> () at /home/mark/Edit/rust/src/librustc_driver/lib.rs:1072
#36 std::panic::{{impl}}::call_once<(),closure> (self=...) at /home/mark/Edit/rust/src/libstd/panic.rs:295
#37 std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()> (data=<optimized out>) at /home/mark/Edit/rust/src/libstd/panicking.rs:356
#38 0x00007fd5414eece8 in panic_unwind::__rust_maybe_catch_panic (f=0x7fd54187aed0 <std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()>>, data=0x7fd537eedd98 "", data_ptr=0x7fd537f0dc00, vtable_ptr=0x7fd537f0dc08)
    at /home/mark/Edit/rust/src/libpanic_unwind/lib.rs:97
#39 0x00007fd541885259 in std::panicking::try<(),std::panic::AssertUnwindSafe<closure>> (f=AssertUnwindSafe<closure> = {...}) at /home/mark/Edit/rust/src/libstd/panicking.rs:332
#40 std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (f=AssertUnwindSafe<closure> = {...}) at /home/mark/Edit/rust/src/libstd/panic.rs:351
#41 std::thread::{{impl}}::spawn::{{closure}}<closure,()> () at /home/mark/Edit/rust/src/libstd/thread/mod.rs:287
#42 alloc::boxed::{{impl}}::call_box<(),closure> (self=0x556231475090, args=<optimized out>) at /home/mark/Edit/rust/src/liballoc/boxed.rs:595
#43 0x00007fd5414b50f4 in alloc::boxed::{{impl}}::call_once<(),()> (self=...) at /home/mark/Edit/rust/src/liballoc/boxed.rs:605
#44 std::sys_common::thread::start_thread (main=0x5562314751a0) at /home/mark/Edit/rust/src/libstd/sys_common/thread.rs:21
#45 0x00007fd5414bcbb9 in std::sys::imp::thread::{{impl}}::new::thread_start (main=0x7fd537eedd98) at /home/mark/Edit/rust/src/libstd/sys/unix/thread.rs:84
#46 0x00007fd53944f70a in start_thread (arg=0x7fd537f0e700) at pthread_create.c:333
#47 0x00007fd54118282d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

@Mark-Simulacrum
Copy link
Member Author

Hmm, after removing the derives for Copy and Clone on ManuallyDrop, this is the new backtrace. Looks quite similar, overall.

#0  alloc::rc::RcBoxPtr::dec_strong<alloc::rc::Rc<syntax::tokenstream::Delimited>,syntax::tokenstream::Delimited> (self=0x7fffee1bed98)
    at /home/mark/Edit/rust/src/liballoc/rc.rs:1115
#1  alloc::rc::{{impl}}::drop<syntax::tokenstream::Delimited> (self=0x7fffee1bed98) at /home/mark/Edit/rust/src/liballoc/rc.rs:648
#2  0x00007ffff06e66ad in rustc_data_structures::array_vec::{{impl}}::push<[syntax::ext::tt::transcribe::TtFrame; 1]> (self=0x7fffee1bed80, el=...)
    at /home/mark/Edit/rust/src/librustc_data_structures/array_vec.rs:70
#3  0x00007ffff06f808e in rustc_data_structures::array_vec::{{impl}}::extend<[syntax::ext::tt::transcribe::TtFrame; 1],core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>> (self=<optimized out>, iter=...) at /home/mark/Edit/rust/src/librustc_data_structures/array_vec.rs:132
#4  rustc_data_structures::accumulate_vec::{{impl}}::from_iter<[syntax::ext::tt::transcribe::TtFrame; 1],core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>> (
    iter=...) at /home/mark/Edit/rust/src/librustc_data_structures/accumulate_vec.rs:112
#5  core::iter::iterator::Iterator::collect<core::iter::sources::Once<syntax::ext::tt::transcribe::TtFrame>,rustc_data_structures::accumulate_vec::AccumulateVec<[syntax::ext::tt::transcribe::TtFrame; 1]>> (self=...) at /home/mark/Edit/rust/src/libcore/iter/iterator.rs:1196
#6  rustc_data_structures::accumulate_vec::{{impl}}::one<[syntax::ext::tt::transcribe::TtFrame; 1]> (el=...)
    at /home/mark/Edit/rust/src/librustc_data_structures/accumulate_vec.rs:48
#7  rustc_data_structures::small_vec::{{impl}}::one<[syntax::ext::tt::transcribe::TtFrame; 1]> (el=...) at /home/mark/Edit/rust/src/librustc_data_structures/small_vec.rs:51
#8  syntax::ext::tt::transcribe::new_tt_reader_with_doc_flag (sp_diag=0x7fffee1db108, interp=..., src=...,
    desugar_doc_comments=<error reading variable: access outside bounds of object referenced via synthetic pointer>)
    at /home/mark/Edit/rust/src/libsyntax/ext/tt/transcribe.rs:78
#9  0x00007ffff06f7bb2 in syntax::ext::tt::transcribe::new_tt_reader (sp_diag=0x0, interp=..., src=...) at /home/mark/Edit/rust/src/libsyntax/ext/tt/transcribe.rs:62
#10 0x00007ffff0556981 in syntax::parse::tts_to_parser (sess=0x7fffee1db108, tts=...) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:217
#11 0x00007ffff055643a in syntax::parse::filemap_to_parser (sess=0x7fffee1db108, filemap=...) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:166
#12 0x00007ffff055637b in syntax::parse::new_sub_parser_from_file (sess=0x7fffee1db108, path=<optimized out>, owns_directory=false, module_name=..., sp=...)
    at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:157
#13 0x00007ffff05f19d3 in syntax::parse::parser::{{impl}}::eval_src_mod_from_path (self=<optimized out>, path=..., owns_directory=<optimized out>, name=..., id_sp=...)
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5492
#14 syntax::parse::parser::{{impl}}::eval_src_mod (self=0x7fffee1cb610, id=..., outer_attrs=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5467
#15 0x00007ffff05f842c in syntax::parse::parser::{{impl}}::parse_item_mod (outer_attrs=..., self=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5339
#16 syntax::parse::parser::{{impl}}::parse_item_ (self=<optimized out>, attrs=..., macros_allowed=<optimized out>, attributes_allowed=<optimized out>)
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5919
#17 0x00007ffff0601a06 in syntax::parse::parser::{{impl}}::parse_item (self=0x7fffee1cb610) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6097
#18 0x00007ffff05efd3b in syntax::parse::parser::{{impl}}::parse_mod_items (self=<optimized out>, term=0x7ffff0714238 <ref24582>, inner_lo=BytePos = {...})
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5286
#19 0x00007ffff05f1bdc in syntax::parse::parser::{{impl}}::eval_src_mod_from_path (self=<optimized out>, path=..., owns_directory=<optimized out>, name=..., id_sp=...)
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5495
#20 syntax::parse::parser::{{impl}}::eval_src_mod (self=0x7fffee1d62b0, id=..., outer_attrs=..., id_sp=...) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5467
#21 0x00007ffff05f842c in syntax::parse::parser::{{impl}}::parse_item_mod (outer_attrs=..., self=<optimized out>) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5339
#22 syntax::parse::parser::{{impl}}::parse_item_ (self=<optimized out>, attrs=..., macros_allowed=<optimized out>, attributes_allowed=<optimized out>)
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5919
#23 0x00007ffff0601a06 in syntax::parse::parser::{{impl}}::parse_item (self=0x7fffee1d62b0) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6097
#24 0x00007ffff05efd3b in syntax::parse::parser::{{impl}}::parse_mod_items (self=<optimized out>, term=0x7ffff0714238 <ref24582>, inner_lo=BytePos = {...})
    at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:5286
#25 0x00007ffff060282b in syntax::parse::parser::{{impl}}::parse_crate_mod (self=0x7fffee1d62b0) at /home/mark/Edit/rust/src/libsyntax/parse/parser.rs:6185
#26 0x00007ffff0555c18 in syntax::parse::parse_crate_from_file (input=<optimized out>, sess=0x7fffee1db108) at /home/mark/Edit/rust/src/libsyntax/parse/mod.rs:85

Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

So I'm not sure if this causes the observed bug, but the iteration order is definitely wrong.

pub fn pop(&mut self) -> Option<A::Element> {
if self.count > 0 {
let arr = &mut self.values as &mut [ManuallyDrop<_>];
let value = mem::replace(&mut arr[self.count - 1], ManuallyDrop::new());
Copy link
Member

Choose a reason for hiding this comment

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

You don't need mem::replace, you can just do ptr::read(&arr[self.count - 1].value).
Also, you can decrement first, and use self.count then.

}
}
}

impl<A: Array> Iterator for ArrayVec<A> {
Copy link
Member

Choose a reason for hiding this comment

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

Why? You could make a forward by-value iterator if you wanted to (by having an ArrayVec and a start index), and then implement IntoIterator on ArrayVec.


fn next(&mut self) -> Option<A::Element> {
match self.repr {
IntoIterRepr::Array(ref mut arr) => arr.pop(),
Copy link
Member

Choose a reason for hiding this comment

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

This is not a good idea at all, it goes in the reverse order!

fn into_iter(self) -> Self::IntoIter {
match *self {
AccumulateVec::Array(ref arr) => arr.iter(),
AccumulateVec::Heap(ref vec) => vec.iter(),
Copy link
Member

Choose a reason for hiding this comment

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

You can just self.iter() - same for the mutable version below.

@Mark-Simulacrum Mark-Simulacrum force-pushed the upgrade-accvec branch 2 times, most recently from cb581ec to c5b951a Compare November 6, 2016 16:05
@Mark-Simulacrum Mark-Simulacrum changed the title [WIP] Replace syntax's SmallVector with AccumulateVec Replace syntax's SmallVector with AccumulateVec Nov 6, 2016
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
try!(s.emit_seq_elt(i, |s| e.encode(s)));
Copy link
Member

Choose a reason for hiding this comment

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

You can use ? instead of try! here and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was going to, but then we need to add ? to the feature list and I recalled needing to mess with cfg(stage0) or something like that in order for that to work properly.

I can change it if you'd like, though--let me know.

@eddyb
Copy link
Member

eddyb commented Nov 7, 2016

f? @erickt

@alexcrichton
Copy link
Member

@eddyb unfortunately @erickt seems pretty busy nowadays, were you thinking of any particular feedback in specific though?

@alexcrichton alexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 10, 2016
@Mark-Simulacrum
Copy link
Member Author

I believe @eddyb was waiting on @erickt to review since this may be a difficult merge into syntex, so if we can aid that by doing something differently here, that would be good.

@eddyb
Copy link
Member

eddyb commented Nov 10, 2016

Eh, it looks fine enough for me. @bors r+

@bors
Copy link
Contributor

bors commented Nov 10, 2016

📌 Commit 8380d32 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Nov 11, 2016

☔ The latest upstream changes (presumably #37246) made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum
Copy link
Member Author

Rebased.

@eddyb
Copy link
Member

eddyb commented Nov 11, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2016

📌 Commit 7bbebb1 has been approved by eddyb

eddyb added a commit to eddyb/rust that referenced this pull request Nov 11, 2016
…ddyb

Replace syntax's SmallVector with AccumulateVec

This adds a new type to data_structures, `SmallVec`, which wraps `AccumulateVec` with support for re-allocating onto the heap (`SmallVec::reserve`). `SmallVec` is then used to replace the implementation of `SmallVector` in libsyntax.

r? @eddyb

Fixes rust-lang#37371. Using `SmallVec` instead of libsyntax's `SmallVector` will provide the `N = 2/4` case easily (just needs a few more `Array` impls).

cc @nnethercote, probably interested in this area
@nnethercote
Copy link
Contributor

This is nice, thank you. I particularly like that you found a way to let N be choosable. E.g. I was looking at TypeWalker the other day and using a SmallVector for its stack was a small win, but it'll be a bigger win with 4 stack elements. I will revisit that change once this lands.

eddyb added a commit to eddyb/rust that referenced this pull request Nov 12, 2016
…ddyb

Replace syntax's SmallVector with AccumulateVec

This adds a new type to data_structures, `SmallVec`, which wraps `AccumulateVec` with support for re-allocating onto the heap (`SmallVec::reserve`). `SmallVec` is then used to replace the implementation of `SmallVector` in libsyntax.

r? @eddyb

Fixes rust-lang#37371. Using `SmallVec` instead of libsyntax's `SmallVector` will provide the `N = 2/4` case easily (just needs a few more `Array` impls).

cc @nnethercote, probably interested in this area
bors added a commit that referenced this pull request Nov 12, 2016
@bors bors merged commit 7bbebb1 into rust-lang:master Nov 12, 2016
@Mark-Simulacrum Mark-Simulacrum deleted the upgrade-accvec branch December 27, 2016 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants