about summary refs log tree commit diff
path: root/src/libsyntax/diagnostic.rs
AgeCommit message (Collapse)AuthorLines
2015-12-17move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*Nick Cameron-900/+0
Also split out emitters into their own module.
2015-12-03libterm: bring across changes from termBryce Van Dyk-8/+8
This brings across changes made to the term library to libterm. This includes removing instances or unwrap, fixing format string handling, and removing a TODO. This fix does not bring all changes across, as term now relies on cargo deps that cannot be brought into the rust build at this stage, but has attempted as best to cross port changes not relying on this. This notably limits extra functionality since implemented int he Terminal trait in Term. This is in partly in response to rust issue #29992.
2015-11-17Detect confusing unicode characters and show the alternativeRavi Shankar-0/+4
2015-11-09std: Migrate to the new libcAlex Crichton-5/+8
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c
2015-10-27Make fatal errors more consistent.Eli Friedman-13/+10
2015-10-09Some cleanup of no longer used AST thingsNick Cameron-1/+0
2015-09-24Cleanup interfaces of Name, SyntaxContext and IdentVadim Petrochenkov-1/+1
Make sure Name, SyntaxContext and Ident are passed by value Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-09-14Print the file in which a macro was definedJonas Schievink-5/+14
2015-09-11Don't print duplicate macro backtrace framesJonas Schievink-6/+12
2015-09-10Don't print the macro definition site in backtracesJonas Schievink-6/+2
This halves the backtrace length. The definition site wasn't very useful anyways, since it may be invalid (for compiler expansions) or located in another crate. Since the macro name is still printed, grepping for it is still an easy way of finding the definition.
2015-09-10Make print_macro_backtrace non-recursiveJonas Schievink-22/+26
2015-08-27Enumify CompilerExpansion in ExpnInfoManish Goregaokar-4/+4
2015-07-29Auto merge of #26846 - P1start:print-maybe-styled-macro, r=pnkfelixbors-20/+38
`EmitterWriter::print_maybe_styled` was basically always used with `format!`, so this macro makes some code cleaner. It should also remove some unnecessary allocations (most `print_maybe_styled` invocations allocated a `String` previously, whereas the new macro uses `write_fmt` to write the formatted string directly to the terminal). This probably could have been part of #26838, but it’s too late now. It’s also rebased on #26838’s branch because otherwise pretty much all of the changes in this PR would conflict with the other PR’s changes.
2015-07-21Auto merge of #26816 - nrc:zero-codemap, r=@jroeschbors-12/+8
See commits for details
2015-07-21Provide a filemap ctor with line infoNick Cameron-6/+1
2015-07-21Allow for space between each filemap in the codemapNick Cameron-6/+7
So if a filemap's last byte is at position n in the codemap, then n+1 will not refer to any filemap, and the next filemap will begin an n+2. This is useful for empty files, it means that every file (even empty ones) has a byte in the codemap. Closes #23301, #26504
2015-07-20syntax: Suppress panic message on `fatal`Alex Crichton-0/+4
This commit ensures that the rustc thread does not leak a panic message whenever a call to `fatal` happens. This already happens for the main rustc thread as part of the `rustc_driver::monitor` function, but the compiler also spawns threads for other operations like `-C codegen-units`, and sometimes errors are emitted on these threads as well. To ensure that there's a consistent error-handling experience across threads this unifies these two to never print the panic message in the case of a normal and expected fatal error. This should also fix the flaky `asm-src-loc-codegen-units.rs` test as the output is sometimes garbled if diagnostics are printed while the panic message is also being printed.
2015-07-18Define and use a `print_maybe_styled!` macro in libsyntax/diagnostic.rsP1start-20/+38
`EmitterWriter::print_maybe_styled` was basically always used with `format!`, so this macro makes some code cleaner. It should also remove some unnecessary allocations (most `print_maybe_styled` invocations allocated a `String` previously, whereas the new macro uses `write_fmt` to write the formatted string directly to the terminal). This probably could have been part of #26838, but it’s too late now.
2015-07-08Change some free functions into methods in libsyntax/diagnostic.rsP1start-396/+392
2015-06-24Added unit test for code indent of multi-line errorsOliver Schneider-1/+66
2015-06-24Indent code past the widest line numberTheo Belaire-2/+8
Fixes #11715
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-1/+1
2015-05-17Auto merge of #25387 - eddyb:syn-file-loader, r=nikomatsakisbors-21/+19
This allows compiling entire crates from memory or preprocessing source files before they are tokenized. Minor API refactoring included, which is a [breaking-change] for libsyntax users: * `ParseSess::{next_node_id, reserve_node_ids}` moved to rustc's `Session` * `new_parse_sess` -> `ParseSess::new` * `new_parse_sess_special_handler` -> `ParseSess::with_span_handler` * `mk_span_handler` -> `SpanHandler::new` * `default_handler` -> `Handler::new` * `mk_handler` -> `Handler::with_emitter` * `string_to_filemap(sess source, path)` -> `sess.codemap().new_filemap(path, source)`
2015-05-14syntax: refactor (Span)Handler and ParseSess constructors to be methods.Eduard Burtescu-21/+19
2015-05-13make diagnostic message clearer when called from cargoMathieu Rochette-1/+1
2015-05-12Proper spans for for loop expansionNick Cameron-4/+7
2015-05-05Guard against overflow in `codemap::span_to_lines`.Felix S. Klock II-3/+19
Make `span_to_lines` to return a `Result`. (This is better than just asserting internally, since it allows caller to decide if they can recover from the problem.) Added type alias for `FileLinesResult` returned by `span_to_lines`. Update embedded unit test to reflect `span_to_lines` signature change. In diagnostic, catch `Err` from `span_to_lines` and print `"(internal compiler error: unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is not its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up.
2015-04-21syntax: Replace String::from_str with the stable String::fromErick Tryzelaar-1/+1
2015-04-18Auto merge of #24428 - kwantam:deprecate_unicode_fns, r=alexcrichtonbors-8/+7
This patch 1. renames libunicode to librustc_unicode, 2. deprecates several pieces of libunicode (see below), and 3. removes references to deprecated functions from librustc_driver and libsyntax. This may change pretty-printed output from these modules in cases involving wide or combining characters used in filenames, identifiers, etc. The following functions are marked deprecated: 1. char.width() and str.width(): --> use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): --> use unicode-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(), char.canonical_combining_class(): --> use unicode-normalization crate
2015-04-16deprecate Unicode functions that will be moved to crates.iokwantam-8/+7
This patch 1. renames libunicode to librustc_unicode, 2. deprecates several pieces of libunicode (see below), and 3. removes references to deprecated functions from librustc_driver and libsyntax. This may change pretty-printed output from these modules in cases involving wide or combining characters used in filenames, identifiers, etc. The following functions are marked deprecated: 1. char.width() and str.width(): --> use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): --> use unicode-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(), char.canonical_combining_class(): --> use unicode-normalization crate
2015-04-15Implement traits for parser error structsAdolfo Ochagavía-8/+29
Implement `Debug`, `Display` and `Error` for `FatalError` and `ExplicitBug`
2015-04-11Suppress the macro backtrace for `fileline_note` and `fileline_help`.Ryan Prichard-4/+3
2015-04-10Add a new `span_suggestion` infrastructure. This lets you edit a snippetNiko Matsakis-1/+65
of text (perhaps obtained by span_snippet) and then splice that edited form back into the original file in the form of a suggestion.
2015-04-10Modify the codemap code to use more slices and to information aboutNiko Matsakis-27/+41
columns within a line, not just the line numbers. Also try to clarify and use the term `line_index` when 0-based.
2015-04-10Replace the use of the rather randomly named boolean `custom` to meanNiko Matsakis-30/+37
"highlight end" and instead add a variant to `RenderSpan`
2015-04-05Add comments suggested by NikoPhil Dawes-3/+3
2015-04-05Work towards a non-panicing parser (libsyntax)Phil Dawes-4/+5
- Functions in parser.rs return PResult<> rather than panicing - Other functions in libsyntax call panic! explicitly for now if they rely on panicing behaviour. - 'panictry!' macro added as scaffolding while converting panicing functions. (This does the same as 'unwrap()' but is easier to grep for and turn into try!()) - Leaves panicing wrappers for the following functions so that the quote_* macros behave the same: - parse_expr, parse_item, parse_pat, parse_arm, parse_ty, parse_stmt
2015-04-02Tweak relese notes + rebase fixesAlex Crichton-1/+1
2015-04-01Fallout in libsyntaxNiko Matsakis-2/+2
2015-03-13Fallout of std::old_io deprecationAlex Crichton-24/+48
2015-03-03Switched to Box::new in many places.Felix S. Klock II-3/+3
Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box <expr>` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-1/+1
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-02-18Round 3 test fixes and conflictsAlex Crichton-5/+5
2015-02-18rollup merge of #22502: nikomatsakis/deprecate-bracket-bracketAlex Crichton-13/+13
Conflicts: src/libcollections/slice.rs src/libcollections/str.rs src/librustc/middle/lang_items.rs src/librustc_back/rpath.rs src/librustc_typeck/check/regionck.rs src/libstd/ffi/os_str.rs src/libsyntax/diagnostic.rs src/libsyntax/parse/parser.rs src/libsyntax/util/interner.rs src/test/run-pass/regions-refcell.rs
2015-02-18Replace all uses of `&foo[]` with `&foo[..]` en masse.Niko Matsakis-12/+12
2015-02-18std: Implement CString-related RFCsAlex Crichton-16/+19
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type to the module. [r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md [r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md The new `CStr` type is only constructable via two methods: 1. By `deref`'ing from a `CString` 2. Unsafely via `CStr::from_ptr` The purpose of `CStr` is to be an unsized type which is a thin pointer to a `libc::c_char` (currently it is a fat pointer slice due to implementation limitations). Strings from C can be safely represented with a `CStr` and an appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr` instead to allow producers to pass in C-originating strings instead of just Rust-allocated strings. A new constructor was added to `CString`, `new`, which takes `T: IntoBytes` instead of separate `from_slice` and `from_vec` methods (both have been deprecated in favor of `new`). The `new` method returns a `Result` instead of panicking. The error variant contains the relevant information about where the error happened and bytes (if present). Conversions are provided to the `io::Error` and `old_io::IoError` types via the `FromError` trait which translate to `InvalidInput`. This is a breaking change due to the modification of existing `#[unstable]` APIs and new deprecation, and more detailed information can be found in the two RFCs. Notable breakage includes: * All construction of `CString` now needs to use `new` and handle the outgoing `Result`. * Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call. * The `as_slice*` methods have been removed in favor of just having the `as_bytes*` methods. Closes #22469 Closes #22470 [breaking-change]
2015-02-08syntax: Fix integer underflow in diagnosticPiotr Czarnecki-2/+9
Fixes #22091
2015-02-04Compute widths properly when displaying spans in error messagesP1start-23/+58
Closes #8706.
2015-02-02rollup merge of #21830: japaric/for-cleanupAlex Crichton-2/+2
Conflicts: src/librustc/metadata/filesearch.rs src/librustc_back/target/mod.rs src/libstd/os.rs src/libstd/sys/windows/os.rs src/libsyntax/ext/tt/macro_parser.rs src/libsyntax/print/pprust.rs src/test/compile-fail/issue-2149.rs
2015-02-02`for x in xs.iter()` -> `for x in &xs`Jorge Aparicio-2/+2