about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2015-03-24syntax: Allow quotes to insert pathErick Tryzelaar-0/+2
2015-03-24syntax: Allow where strings to be parsed independent from genericsErick Tryzelaar-0/+2
This allows quasiquoting to insert where clauses.
2015-03-25Change lint names to pluralsNick Cameron-1/+1
2015-03-25Add trivial cast lints.Nick Cameron-4/+5
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-23rollup merge of #23506: alexcrichton/remove-some-deprecated-thingsAlex Crichton-10/+0
Conflicts: src/test/run-pass/deprecated-no-split-stack.rs
2015-03-23rollup merge of #23601: nikomatsakis/by-value-indexAlex Crichton-3/+3
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`. r? @japaric cc @aturon @Gankro
2015-03-23Add generic conversion traitsAaron Turon-1/+1
This commit: * Introduces `std::convert`, providing an implementation of RFC 529. * Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all in favor of the corresponding generic conversion traits. Consequently, various IO APIs now take `AsRef<Path>` rather than `AsPath`, and so on. Since the types provided by `std` implement both traits, this should cause relatively little breakage. * Deprecates many `from_foo` constructors in favor of `from`. * Changes `PathBuf::new` to take no argument (creating an empty buffer, as per convention). The previous behavior is now available as `PathBuf::from`. * De-stabilizes `IntoCow`. It's not clear whether we need this separate trait. Closes #22751 Closes #14433 [breaking-change]
2015-03-23Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses ofNiko Matsakis-3/+3
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about how to use `[]`.
2015-03-20Auto merge of #23512 - oli-obk:result_ok_unwrap, r=alexcrichtonbors-3/+3
because then the call to `unwrap()` will not print the error object.
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-3/+3
2015-03-19Added missing impl_to_source! and impl_to_tokens! for TraitItem.Vladimir Pouzanov-0/+2
2015-03-19Added missing impl_to_source! and impl_to_tokens! for ImplItem.Vladimir Pouzanov-0/+2
This fixes several use cases that were broken after #23265 landed.
2015-03-18rustc: Remove some long deprecated features:Alex Crichton-10/+0
* no_split_stack was renamed to no_stack_check * deriving was renamed to derive * `use foo::mod` was renamed to `use foo::self`; * legacy lifetime definitions in closures have been replaced with `for` syntax * `fn foo() -> &A + B` has been deprecated for some time (needs parens) * Obsolete `for Sized?` syntax * Obsolete `Sized? Foo` syntax * Obsolete `|T| -> U` syntax
2015-03-13syntax: use lookahead to distinguish inner and outer attributes, instead of ↵Eduard Burtescu-25/+15
passing the latter around.
2015-03-13Auto merge of #23229 - aturon:stab-path, r=alexcrichtonbors-5/+1
This commit stabilizes essentially all of the new `std::path` API. The API itself is changed in a couple of ways (which brings it in closer alignment with the RFC): * `.` components are now normalized away, unless they appear at the start of a path. This in turn effects the semantics of e.g. asking for the file name of `foo/` or `foo/.`, both of which yield `Some("foo")` now. This semantics is what the original RFC specified, and is also desirable given early experience rolling out the new API. * The `parent` method is now `without_file` and succeeds if, and only if, `file_name` is `Some(_)`. That means, in particular, that it fails for a path like `foo/../`. This change affects `pop` as well. In addition, the `old_path` module is now deprecated. [breaking-change] r? @alexcrichton
2015-03-12Stabilize std::pathAaron Turon-5/+1
This commit stabilizes essentially all of the new `std::path` API. The API itself is changed in a couple of ways (which brings it in closer alignment with the RFC): * `.` components are now normalized away, unless they appear at the start of a path. This in turn effects the semantics of e.g. asking for the file name of `foo/` or `foo/.`, both of which yield `Some("foo")` now. This semantics is what the original RFC specified, and is also desirable given early experience rolling out the new API. * The `parent` function now succeeds if, and only if, the path has at least one non-root/prefix component. This change affects `pop` as well. * The `Prefix` component now involves a separate `PrefixComponent` struct, to better allow for keeping both parsed and unparsed prefix data. In addition, the `old_path` module is now deprecated. Closes #23264 [breaking-change]
2015-03-12Auto merge of #23265 - eddyb:meth-ast-refactor, r=nikomatsakisbors-173/+120
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures `ImplItem` and `TraitItem`. The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share `MethodSig`. This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions: * `pub fn` methods in a trait no longer parse - remove the `pub`, it has no meaning anymore * `MacResult::make_methods` is now `make_impl_items` and the return type has changed accordingly * `quote_method` is gone, because `P<ast::Method>` doesn't exist and it couldn't represent a full method anyways - could be replaced by `quote_impl_item`/`quote_trait_item` in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a single `quote` macro + some type hints - or just no types at all (only token-trees) r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.
2015-03-11syntax: move MethMac to MacImplItem and combine {Provided,Required}Method ↵Eduard Burtescu-83/+73
into MethodTraitItem.
2015-03-11syntax: rename TypeMethod to MethodSig and use it in MethDecl.Eduard Burtescu-15/+16
2015-03-11syntax: gather common fields of impl & trait items into their respective types.Eduard Burtescu-147/+108
2015-03-11syntax: move indirection around {Trait,Impl}Item, from within.Eduard Burtescu-47/+42
2015-03-09Switch derive(Debug) to use the debug buildersSteven Fackler-63/+41
2015-03-09Rename #[should_fail] to #[should_panic]Steven Fackler-2/+2
2015-03-06Make #[derive(Anything)] into sugar for #[derive_Anything]Keegan McAllister-121/+143
This is a hack, but I don't think we can do much better as long as `derive` is running at the syntax expansion phase. If the custom_derive feature gate is enabled, this works with user-defined traits and syntax extensions. Without the gate, you can't use e.g. #[derive_Clone] directly, so this does not change the stable language. This commit also cleans up the deriving code somewhat, and forbids some previously-meaningless attribute syntax. For this reason it's technically a [breaking-change]
2015-03-06Consolidate ExpansionConfig feature testsKeegan McAllister-40/+20
2015-03-06Auto merge of #22899 - huonw:macro-stability, r=alexcrichtonbors-16/+61
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!("{}", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system. --- This updates `thread_local!` macro to use the attribute, since it uses unstable features internally (initialising a struct with unstable fields).
2015-03-06Add #[allow_internal_unstable] to track stability for macros better.Huon Wilson-16/+61
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!("{}", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system.
2015-03-05Rollup merge of #22764 - ivanradanov:fileline_help, r=huonwManish Goregaokar-1/+5
When warnings and errors occur, the associated help message should not print the same code snippet. https://github.com/rust-lang/rust/issues/21938
2015-03-05Fix quoting of ?SizedSeo Sanghyeon-1/+2
2015-03-05Auto merge of #22061 - pczarn:quote_matcher_and_attr, r=kmcallisterbors-42/+143
Fixes #19674 Fixes #17396 (already closed, yeah) cc @kmcallister , @cmr
2015-03-04std: Deprecate std::old_io::fsAlex Crichton-13/+20
This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change.
2015-03-04Add quasiquote for matchers and attributesPiotr Czarnecki-42/+143
2015-03-03Switched to Box::new in many places.Felix S. Klock II-43/+44
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-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-20/+19
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
2015-03-03Change span_help calls to fileline_help where appropriateIvan Radanov Ivanov-1/+5
2015-03-03Accommodate simple cases of arith-overflow in `rustc` related crates.Felix S. Klock II-1/+1
2015-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-19/+18
Many of the core rust libraries have places that rely on integer wrapping behaviour. These places have been altered to use the wrapping_* methods: * core::hash::sip - A number of macros * core::str - The `maximal_suffix` method in `TwoWaySearcher` * rustc::util::nodemap - Implementation of FnvHash * rustc_back::sha2 - A number of macros and other places * rand::isaac - Isaac64Rng, changed to use the Wrapping helper type Some places had "benign" underflow. This is when underflow or overflow occurs, but the unspecified value is not used due to other conditions. * collections::bit::Bitv - underflow when `self.nbits` is zero. * collections::hash::{map,table} - Underflow when searching an empty table. Did cause undefined behaviour in this case due to an out-of-bounds ptr::offset based on the underflowed index. However the resulting pointers would never be read from. * syntax::ext::deriving::encodable - Underflow when calculating the index of the last field in a variant with no fields. These cases were altered to avoid the underflow, often by moving the underflowing operation to a place where underflow could not happen. There was one case that relied on the fact that unsigned arithmetic and two's complement arithmetic are identical with wrapping semantics. This was changed to use the wrapping_* methods. Finally, the calculation of variant discriminants could overflow if the preceeding discriminant was `U64_MAX`. The logic in `rustc::middle::ty` for this was altered to avoid the overflow completely, while the remaining places were changed to use wrapping methods. This is because `rustc::middle::ty::enum_variants` now throws an error when the calculated discriminant value overflows a `u64`. This behaviour can be triggered by the following code: ``` enum Foo { A = U64_MAX, B } ``` This commit also implements the remaining integer operators for Wrapped<T>.
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-28Rollup merge of #22875 - kmcallister:maceager, r=sfacklerManish Goregaokar-69/+91
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. r? @sfackler
2015-02-27Replace MacExpr / MacPat / MacItems with MacEagerKeegan McAllister-69/+91
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-27Rollup merge of #22823 - kmcallister:fix-21370, r=huonwManish Goregaokar-4/+4
Fixes #21370. `unused-macro-with-follow-violation.rs` was already handled correctly. That test is just for good measure. :) I have a more involved plan to clean this up, but it ran into difficulties such as #22814.
2015-02-25Always error on invalid macro fragment specifiersKeegan McAllister-4/+4
Fixes #21370. unused-macro-with-follow-violation.rs was already handled correctly. That test is just for good measure. :)
2015-02-25Rollup merge of #22635 - kmcallister:macros-chapter, r=steveklabnikManish Goregaokar-38/+41
r? @steveklabnik
2015-02-24Use arrays instead of vectors in testsVadim Petrochenkov-16/+14
2015-02-24Implement `<T>::method` UFCS expression syntax.Eduard Burtescu-21/+18
2015-02-24rustc_resolve: use the visitor model more, remove redundant repeated lookups.Eduard Burtescu-4/+10
2015-02-24syntax: use a single Path for Trait::Item in QPath.Eduard Burtescu-22/+22
2015-02-24syntax: don't store a secondary NodeId for TyPath.Eduard Burtescu-2/+2
2015-02-24Remove double expr_u32 (fixup #22700)Manish Goregaokar-3/+0
2015-02-24Rollup merge of #22700 - nick29581:ints_hash, r=alexcrichtonManish Goregaokar-2/+5
fmt and hash are pretty straightforward I think. sync is a bit more complex. I thought one or two of the `isize`s ought to be `i32`s, but that would require a bunch of casting (the root cause being the lack of atomics other than isize/usize). r? @alexcrichton