summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
AgeCommit message (Collapse)AuthorLines
2014-03-29Register new snapshotFlavio Percoco-18/+0
2014-03-27serialize: use ResultSean McArthur-0/+18
All of Decoder and Encoder's methods now return a Result. Encodable.encode() and Decodable.decode() return a Result as well. fixes #12292
2014-03-27syntax: add a some docs/clarification to the fields of ExpnInfo.Huon Wilson-3/+26
2014-03-23use TotalEq for HashMapDaniel Micay-4/+5
Closes #5283
2014-03-22syntax: Fix fallout of removing get()Alex Crichton-31/+31
2014-03-20Removing imports of std::vec_ng::VecAlex Crichton-1/+0
It's now in the prelude.
2014-03-20rename std::vec_ng -> std::vecDaniel Micay-1/+1
Closes #12771
2014-03-18libsyntax: librustdoc: ignore utf-8 BOM in .rs filesLiigo Zhuang-1/+10
Closes #12974
2014-03-17De-@ codemap and diagnostic.Eduard Burtescu-67/+54
2014-03-10syntax: fixed ICEs and incorrect line nums when reporting Spans at the end ↵Dmitry Promsky-14/+58
of the file. CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports. Example: ```` pub fn main() { let mut num = 3; let refe = &mut num; *refe = 5; println!("{}", num); }```` (note the empty line in the beginning and the absence of newline at the end) The above would have caused ICE when trying to report where "refe" borrow ends. The above without an empty line in the beginning would have reported borrow end to be the first line. Most probably, this is also responsible for (at least some occurrences of) issue #8256. The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.
2014-03-01libsyntax: Fix errors arising from the automated `~[T]` conversionPatrick Walton-9/+10
2014-03-01libsyntax: Mechanically change `~[T]` to `Vec<T>`Patrick Walton-9/+8
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-6/+6
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-27Fix bytepos_to_file_charpos.Nick Cameron-10/+52
Make bytepos_to_charpos relative to the start of the filemap rather than its previous behaviour which was to be realtive to the start of the codemap, but ignoring multi-byte chars in earlier filemaps. Rename to bytepos_to_file_charpos. Add tests for multi-byte chars.
2014-02-25auto merge of #12522 : erickt/rust/hash, r=alexcrichtonbors-1/+1
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
2014-02-24syntax: calculate positions of multibyte characters more correctly.Huon Wilson-3/+4
They are still are not completely correct, since it does not handle graphemes at all, just codepoints, but at least it handles the common case correctly. The calculation was previously very wrong (rather than just a little bit wrong): it wasn't accounting for the fact that every character is 1 byte, and so multibyte characters were pretending to be zero width. cc #8706
2014-02-24std: minor whitespace cleanupErick Tryzelaar-1/+1
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-7/+7
2014-02-19Fix bug with zero-length filemaps and rename bytepos_to_local_charpos to ↵Nick Cameron-8/+78
bytepos_to_charpos.
2014-02-05pull extra::{serialize, ebml} into a separate libserialize crateJeff Olson-1/+1
- `extra::json` didn't make the cut, because of `extra::json` required dep on `extra::TreeMap`. If/when `extra::TreeMap` moves out of `extra`, then `extra::json` could move into `serialize` - `libextra`, `libsyntax` and `librustc` depend on the newly created `libserialize` - The extensions to various `extra` types like `DList`, `RingBuf`, `TreeMap` and `TreeSet` for `Encodable`/`Decodable` were moved into the respective modules in `extra` - There is some trickery, evident in `src/libextra/lib.rs` where a stub of `extra::serialize` is set up (in `src/libextra/serialize.rs`) for use in the stage0 build, where the snapshot rustc is still making deriving for `Encodable` and `Decodable` point at extra. Big props to @huonw for help working out the re-export solution for this extra: inline extra::serialize stub fix stuff clobbered in rebase + don't reexport serialize::serialize no more globs in libserialize syntax: fix import of libserialize traits librustc: fix bad imports in encoder/decoder add serialize dep to librustdoc fix failing run-pass tests w/ serialize dep adjust uuid dep more rebase de-clobbering for libserialize fixing tests, pushing libextra dep into cfg(test) fix doc code in extra::json adjust index.md links to serialize and uuid library
2014-02-02libsyntax: Fix tests.Patrick Walton-2/+2
2014-02-02librustc: De-`@str` `NameAndSpan`Patrick Walton-3/+3
2014-02-02libsyntax: De-`@str` pathnamesPatrick Walton-3/+3
2014-02-02librustc: Stop using `@str` for source.Patrick Walton-2/+2
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-1/+1
2014-01-23auto merge of #11718 : ktt3ja/rust/borrowck-error-msg, r=brsonbors-4/+0
A mutable and immutable borrow place some restrictions on what you can with the variable until the borrow ends. This commit attempts to convey to the user what those restrictions are. Also, if the original borrow is a mutable borrow, the error message has been changed (more specifically, i. "cannot borrow `x` as immutable because it is also borrowed as mutable" and ii. "cannot borrow `x` as mutable more than once" have been changed to "cannot borrow `x` because it is already borrowed as mutable"). In addition, this adds a (custom) span note to communicate where the original borrow ends. ```rust fn main() { match true { true => { let mut x = 1; let y = &x; let z = &mut x; } false => () } } test.rs:6:21: 6:27 error: cannot borrow `x` as mutable because it is already borrowed as immutable test.rs:6 let z = &mut x; ^~~~~~ test.rs:5:21: 5:23 note: previous borrow of `x` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `x` until the borrow ends test.rs:5 let y = &x; ^~ test.rs:7:10: 7:10 note: previous borrow ends here test.rs:3 true => { test.rs:4 let mut x = 1; test.rs:5 let y = &x; test.rs:6 let z = &mut x; test.rs:7 } ^ ``` ```rust fn foo3(t0: &mut &mut int) { let t1 = &mut *t0; let p: &int = &**t0; } fn main() {} test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable test.rs:3 let p: &int = &**t0; ^~~~~ test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends test.rs:2 let t1 = &mut *t0; ^~~~~~~~ test.rs:4:2: 4:2 note: previous borrow ends here test.rs:1 fn foo3(t0: &mut &mut int) { test.rs:2 let t1 = &mut *t0; test.rs:3 let p: &int = &**t0; test.rs:4 } ^ ``` For the "previous borrow ends here" note, if the span is too long (has too many lines), then only the first and last lines are printed, and the middle is replaced with dot dot dot: ```rust fn foo3(t0: &mut &mut int) { let t1 = &mut *t0; let p: &int = &**t0; } fn main() {} test.rs:3:19: 3:24 error: cannot borrow `**t0` because it is already borrowed as mutable test.rs:3 let p: &int = &**t0; ^~~~~ test.rs:2:14: 2:22 note: previous borrow of `**t0` as mutable occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `**t0` until the borrow ends test.rs:2 let t1 = &mut *t0; ^~~~~~~~ test.rs:7:2: 7:2 note: previous borrow ends here test.rs:1 fn foo3(t0: &mut &mut int) { ... test.rs:7 } ^ ``` (Sidenote: the `span_end_note` currently also has issue #11715)
2014-01-23Make some borrow checker errors more user friendlyKiet Tran-4/+0
A mutable and immutable borrow place some restrictions on what you can with the variable until the borrow ends. This commit attempts to convey to the user what those restrictions are. Also, if the original borrow is a mutable borrow, the error message has been changed (more specifically, i. "cannot borrow `x` as immutable because it is also borrowed as mutable" and ii. "cannot borrow `x` as mutable more than once" have been changed to "cannot borrow `x` because it is already borrowed as mutable"). In addition, this adds a (custom) span note to communicate where the original borrow ends.
2014-01-21[std::vec] Rename .last_opt() to .last(), drop the old .last() behaviorSimon Sapin-6/+3
2014-01-21Remove unnecessary parentheses.Huon Wilson-1/+1
2014-01-15libsyntax: Remove the obsolete ability to parse from substrings.Patrick Walton-42/+8
This was used by the quasiquoter.
2014-01-04Don't allow newtype structs to be dereferenced. #6246Brian Anderson-6/+6
2014-01-03libsyntax: De-`@mut` `CodeMap::files`Patrick Walton-16/+28
2014-01-03libsyntax: De-`@mut` `FileMap::multibyte_chars`Patrick Walton-4/+6
2014-01-03libsyntax: De-`@mut` `FileMap::lines`Patrick Walton-10/+14
2014-01-02Output columns 1-based. Fixes #10848Jan Niklas Hasse-2/+2
2014-01-01syntax::codemap: Add static DUMMY_SPklutzy-8/+5
It replaces `dummy_sp()`.
2013-12-12Add --dep-info to write Makefile-compatible dependency info.Jack Moffitt-0/+4
When --dep-info is given, rustc will write out a `$input_base.d` file in the output directory that contains Makefile compatible dependency information for use with tools like make and ninja.
2013-12-08Remove dead codesKiet Tran-7/+0
2013-12-07syntax: print expansion info from #[attribute] macros in the correctHuon Wilson-1/+15
format. Previously, any attempt to use this information from inside something like #[deriving(Foo)] would result in it printing like `deriving(Foo)!`.
2013-11-20Make BytePos 32-bitSeo Sanghyeon-5/+7
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-7/+7
Who doesn't like a massive renaming?
2013-09-30syntax: Remove usage of fmt!Alex Crichton-10/+10
2013-09-14These impls, at least, can be avoided by deriving Ord.Lindsey Kuper-16/+2
2013-09-01Modernized a few type names in rustc and syntaxMarvin Löbel-27/+27
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-2/+2
Closes #5495
2013-08-05auto merge of #8278 : cmr/rust/workaround, r=brsonbors-4/+11
2013-08-03remove obsolete `foreach` keywordDaniel Micay-3/+3
this has been replaced by `for`
2013-08-03Work around #8256, do not fail the task, just return NoneCorey Richardson-4/+11
2013-08-02replace `range` with an external iteratorDaniel Micay-2/+1
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-2/+2