about summary refs log tree commit diff
path: root/src/libsyntax/ext/format.rs
AgeCommit message (Collapse)AuthorLines
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-715/+0
2015-11-13Auto merge of #29761 - eefriedman:rename-nopanic, r=sanxiynbors-3/+3
Just `sed s/_nopanic//g`. Hopefully makes libsyntax a bit more readable.
2015-11-12libsyntax: deny warnings in doctestsKevin Butler-3/+4
2015-11-10Rename _nopanic methods to remove the suffix.Eli Friedman-3/+3
Just `sed s/_nopanic//g`. Hopefully makes libsyntax a bit more readable.
2015-10-27Don't use panicking helpers in Parser.Eli Friedman-3/+3
2015-08-03syntax: Implement #![no_core]Alex Crichton-22/+9
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-28remove `get_ident` and `get_name`, make `as_str` soundOliver Schneider-2/+1
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-2/+1
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-06-07change some statics to constantsOliver 'ker' Schneider-0/+1
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-12Use the ecx.call_site() span for generating refs to format_args! internalsRyan Prichard-19/+25
`format_args!` uses `#[allow_internal_unstable]` to access internal functions and structs that are marked unstable. For this to work, the spans on AST nodes referencing unstable internals must be equal (same lo/hi values) to the `format_args!` call site, so that the stability checker can recognize that the AST node was generated by the macro.
2015-04-11Propagate macro backtraces more often, improve formatting diagnosticsRyan Prichard-2/+6
* In noop_fold_expr, call new_span in these cases: - ExprMethodCall's identifier - ExprField's identifier - ExprTupField's integer Calling new_span for ExprMethodCall's identifier is necessary to print an acceptable diagnostic for write!(&2, ""). We see this error: <std macros>:2:20: 2:66 error: type `&mut _` does not implement any method in scope named `write_fmt` <std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With this change, we also see a macro expansion backtrace leading to the write!(&2, "") call site. * After fully expanding a macro, we replace the expansion expression's span with the original span. Call fld.new_span to add a backtrace to this span. (Note that I'm call new_span after bt.pop(), so the macro just expanded isn't on the backtrace.) The motivating example for this change is println!("{}"). The format string literal is concat!($fmt, "arg") and is inside the libstd macro. We need to see the backtrace to find the println! call site. * Add a backtrace to the format_args! format expression span. Addresses #23459
2015-04-05Add comments suggested by NikoPhil Dawes-11/+0
2015-04-05Work towards a non-panicing parser (libsyntax)Phil Dawes-3/+14
- 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-03-23Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses ofNiko Matsakis-1/+1
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about how to use `[]`.
2015-02-27Replace MacExpr / MacPat / MacItems with MacEagerKeegan McAllister-1/+1
MacEager is a MacResult implementation for the common case where you've already built each form of AST that you might return. Fixes #17637. Based on #18814. This is a [breaking-change] for syntax extensions: * MacExpr::new becomes MacEager::expr. * MacPat::new becomes MacEager::pat. * MacItems::new becomes MacEager::items. It takes a SmallVector directly, not an iterator.
2015-02-23int audit - libcore::fmtNick Cameron-2/+2
2015-02-20Remove remaining uses of `[]`. This time I tried to use deref coercions ↵Niko Matsakis-10/+10
where possible.
2015-02-18Replace all uses of `&foo[]` with `&foo[..]` en masse.Niko Matsakis-4/+4
2015-02-07Don't use std:: paths in syntax extensions when compiling a #![no_std] crateKeegan McAllister-5/+5
Fixes #16803. Fixes #14342. Fixes half of #21827 -- slice syntax is still broken.
2015-02-06Update to last version, remove "[]" as much as possibleGuillaumeGomez-1/+1
2015-02-06Libsyntax has been updatedGuillaumeGomez-3/+4
2015-02-06Replace the get method by the deref one on InternedStringGuillaumeGomez-2/+3
2015-02-04remove all kind annotations from closuresJorge Aparicio-3/+3
2015-02-02`for x in xs.iter()` -> `for x in &xs`Jorge Aparicio-2/+2
2015-01-30std: Stabilize the std::fmt moduleAlex Crichton-75/+61
This commit performs a final stabilization pass over the std::fmt module, marking all necessary APIs as stable. One of the more interesting aspects of this module is that it exposes a good deal of its runtime representation to the outside world in order for `format_args!` to be able to construct the format strings. Instead of hacking the compiler to assume that these items are stable, this commit instead lays out a story for the stabilization and evolution of these APIs. There are three primary details used by the `format_args!` macro: 1. `Arguments` - an opaque package of a "compiled format string". This structure is passed around and the `write` function is the source of truth for transforming a compiled format string into a string at runtime. This must be able to be constructed in stable code. 2. `Argument` - an opaque structure representing an argument to a format string. This is *almost* a trait object as it's just a pointer/function pair, but due to the function originating from one of many traits, it's not actually a trait object. Like `Arguments`, this must be constructed from stable code. 3. `fmt::rt` - this module contains the runtime type definitions primarily for the `rt::Argument` structure. Whenever an argument is formatted with nonstandard flags, a corresponding `rt::Argument` is generated describing how the argument is being formatted. This can be used to construct an `Arguments`. The primary interface to `std::fmt` is the `Arguments` structure, and as such this type name is stabilize as-is today. It is expected for libraries to pass around an `Arguments` structure to represent a pending formatted computation. The remaining portions are largely "cruft" which would rather not be stabilized, but due to the stability checks they must be. As a result, almost all pieces have been renamed to represent that they are "version 1" of the formatting representation. The theory is that at a later date if we change the representation of these types we can add new definitions called "version 2" and corresponding constructors for `Arguments`. One of the other remaining large questions about the fmt module were how the pending I/O reform would affect the signatures of methods in the module. Due to [RFC 526][rfc], however, the writers of fmt are now incompatible with the writers of io, so this question has largely been solved. As a result the interfaces are largely stabilized as-is today. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md Specifically, the following changes were made: * The contents of `fmt::rt` were all moved under `fmt::rt::v1` * `fmt::rt` is stable * `fmt::rt::v1` is stable * `Error` is stable * `Writer` is stable * `Writer::write_str` is stable * `Writer::write_fmt` is stable * `Formatter` is stable * `Argument` has been renamed to `ArgumentV1` and is stable * `ArgumentV1::new` is stable * `ArgumentV1::from_uint` is stable * `Arguments::new_v1` is stable (renamed from `new`) * `Arguments::new_v1_formatted` is stable (renamed from `with_placeholders`) * All formatting traits are now stable, as well as the `fmt` method. * `fmt::write` is stable * `fmt::format` is stable * `Formatter::pad_integral` is stable * `Formatter::pad` is stable * `Formatter::write_str` is stable * `Formatter::write_fmt` is stable * Some assorted top level items which were only used by `format_args!` were removed in favor of static functions on `ArgumentV1` as well. * The formatting-flag-accessing methods remain unstable Within the contents of the `fmt::rt::v1` module, the following actions were taken: * Reexports of all enum variants were removed * All prefixes on enum variants were removed * A few miscellaneous enum variants were renamed * Otherwise all structs, fields, and variants were marked stable. In addition to these actions in the `std::fmt` module, many implementations of `Show` and `String` were stabilized as well. In some other modules: * `ToString` is now stable * `ToString::to_string` is now stable * `Vec` no longer implements `fmt::Writer` (this has moved to `String`) This is a breaking change due to all of the changes to the `fmt::rt` module, but this likely will not have much impact on existing programs. Closes #20661 [breaking-change]
2015-01-29convert remaining `range(a, b)` to `a..b`Jorge Aparicio-1/+1
2015-01-21rollup merge of #21457: alexcrichton/issue-21436Alex Crichton-2/+2
Conflicts: src/liballoc/boxed.rs src/librustc/middle/traits/error_reporting.rs src/libstd/sync/mpsc/mod.rs
2015-01-20std: Rename Show/String to Debug/DisplayAlex Crichton-2/+2
This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-17libsyntax: rename functions from uint to usizePaul Collier-6/+6
2015-01-17libsyntax: uint types to usizePaul Collier-4/+4
2015-01-10core: rm unused lifetime.Huon Wilson-6/+2
2015-01-07use slicing sugarJorge Aparicio-21/+21
2015-01-06rollup merge of #20481: seanmonstar/fmt-show-stringAlex Crichton-1/+1
Conflicts: src/compiletest/runtest.rs src/libcore/fmt/mod.rs src/libfmt_macros/lib.rs src/libregex/parse.rs src/librustc/middle/cfg/construct.rs src/librustc/middle/dataflow.rs src/librustc/middle/infer/higher_ranked/mod.rs src/librustc/middle/ty.rs src/librustc_back/archive.rs src/librustc_borrowck/borrowck/fragments.rs src/librustc_borrowck/borrowck/gather_loans/mod.rs src/librustc_resolve/lib.rs src/librustc_trans/back/link.rs src/librustc_trans/save/mod.rs src/librustc_trans/trans/base.rs src/librustc_trans/trans/callee.rs src/librustc_trans/trans/common.rs src/librustc_trans/trans/consts.rs src/librustc_trans/trans/controlflow.rs src/librustc_trans/trans/debuginfo.rs src/librustc_trans/trans/expr.rs src/librustc_trans/trans/monomorphize.rs src/librustc_typeck/astconv.rs src/librustc_typeck/check/method/mod.rs src/librustc_typeck/check/mod.rs src/librustc_typeck/check/regionck.rs src/librustc_typeck/collect.rs src/libsyntax/ext/format.rs src/libsyntax/ext/source_util.rs src/libsyntax/ext/tt/transcribe.rs src/libsyntax/parse/mod.rs src/libsyntax/parse/token.rs src/test/run-pass/issue-8898.rs
2015-01-06core: split into fmt::Show and fmt::StringSean McArthur-1/+1
fmt::Show is for debugging, and can and should be implemented for all public types. This trait is used with `{:?}` syntax. There still exists #[derive(Show)]. fmt::String is for types that faithfully be represented as a String. Because of this, there is no way to derive fmt::String, all implementations must be purposeful. It is used by the default format syntax, `{}`. This will break most instances of `{}`, since that now requires the type to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the correct fix. Types that were being printed specifically for users should receive a fmt::String implementation to fix this. Part of #20013 [breaking-change]
2015-01-07Replace full slice notation with index callsNick Cameron-13/+13
2015-01-03sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rsJorge Aparicio-1/+1
2014-12-30Fallout from stabilizationAaron Turon-9/+7
2014-12-27syntax: change format_args! to produce fmt::Arguments instead of calling a ↵Eduard Burtescu-62/+23
function with them.
2014-12-27syntax: use std::string::String unqualified in format.Eduard Burtescu-13/+12
2014-12-27syntax: turn the match-call generated by format_args inside-out.Eduard Burtescu-39/+41
2014-12-27syntax: format: put static arrays in their own blocks to avoid needing a ↵Eduard Burtescu-40/+39
wrapper block.
2014-12-27syntax: format: remove unused method_statics field.Eduard Burtescu-15/+4
2014-12-21Fallout of std::str stabilizationAlex Crichton-14/+13
2014-12-20add {:?} fmt syntaxSean McArthur-0/+1
2014-12-12Add support for equality constraints on associated typesNick Cameron-0/+1
2014-12-08core: make the public fmt API completely safe.Eduard Burtescu-25/+8
2014-11-26rollup merge of #19298: nikomatsakis/unboxed-closure-parse-the-plusAlex Crichton-1/+1
Implements RFC 438. Fixes #19092. This is a [breaking-change]: change types like `&Foo+Send` or `&'a mut Foo+'a` to `&(Foo+Send)` and `&'a mut (Foo+'a)`, respectively. r? @brson
2014-11-26Rote changes due to the fact that ast paths no longer carry this extraneous ↵Niko Matsakis-1/+1
bounds.
2014-11-25Fallout from stabilizationAaron Turon-1/+1