about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2017-06-11Added consumption logic for external sources in FileMapInokentiy Babushkin-1/+1
We now fetch source lines from the `external_src` member as a secondary fallback if no regular source is present, that is, if the file map belongs to an external crate and the source has been fetched from disk.
2017-06-11Improved lazy external source loading and inserted calls.Inokentiy Babushkin-1/+1
2017-06-10Added external crates' sources to FileMap.Inokentiy Babushkin-0/+20
They are now handled in their own member to prevent mutating access to the `src` member. This way, we can safely load external sources, while keeping the mutation of local source strings off-limits.
2017-06-10Moved FileMap construction to it's own constructor.Inokentiy Babushkin-27/+3
The rationale is that BOM stripping is needed for lazy source loading for external crates, and duplication can be avoided by moving the corresponding functionality to libsyntax_pos.
2017-06-10Added source hashes to FileMapInokentiy Babushkin-0/+10
We can use these to perform lazy loading of source files belonging to external crates. That way we will be able to show the source code of external spans that have been translated.
2017-06-10Auto merge of #42533 - Mark-Simulacrum:macro-parse-speed-small, r=jseyfriedbors-27/+34
Speed up expansion This reduces duplication, thereby increasing expansion speed. Based on tests with rust-uinput, this produces a 29x performance win (440 seconds to 15 seconds). I want to land this first, since it's a minimal patch, but with more changes to the macro parsing I can get down to 12 seconds locally. There is one FIXME added to the code that I'll keep for now since changing it will spread outward and increase the patch size, I think. Fixes #37074. r? @jseyfried cc @oberien
2017-06-08Speed up expansion.Mark Simulacrum-27/+34
This reduces duplication, thereby increasing expansion speed.
2017-06-07Replace some matches with try.Masaki Hara-8/+2
2017-06-06Auto merge of #41990 - ↵bors-0/+9
qnighy:disallow-underscore-suffix-for-string-like-literals, r=nikomatsakis Disallow underscore suffix for string-like literals. This patch turns string/bytestring/char/byte literals followed by an underscore, like `"Foo"_`, to an error. `scan_optional_raw_name` will parse `_` as a valid raw name, but it will be rejected by the parser. I also considered just stopping parsing when the suffix is `_`, but in that case `"Foo"_` will be lexed as two valid tokens. Fixes the latter half of #41723.
2017-06-04Merge branch 'profiling' of github.com:whitequark/rust into profilingMarco Castelluccio-0/+11
2017-06-03Auto merge of #42334 - est31:master, r=jseyfriedbors-4/+7
Extend the unused macro lint to macros 2.0 Extends the unused macro lint (added in PR #41907) to macros 2.0 (added in PR #40847). r? @jseyfried
2017-06-03Rollup merge of #42368 - estebank:call-site, r=nikomatsakisCorey Farwell-0/+9
Use callsite's span for macro calls on suggestion When suggesting an appropriate mutability for a macro call, use the call span instead of the expanded macro's span. ``` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:48:9 | 48 | s = format!("foo"); | ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String` | = note: expected type `&mut std::string::String` found type `std::string::String` = help: try with `&mut format!("foo")` = note: this error originates in a macro outside of the current crate ``` Fix #41858.
2017-06-02Rollup merge of #42319 - Manishearth:const-extern, r=nikomatsakisMark Simulacrum-0/+4
Improve error message for const extern fn It's currently ``error: unmatched visibility `pub` ``, which is a nonsensical error in this context.
2017-05-31Use callsite's span for macro calls on suggestionEsteban Küber-0/+9
When suggesting an appropriate mutability for a macro call, use the call span instead of the expanded macro's span.
2017-06-01Rollup merge of #42302 - GuillaumeGomez:new-error-codes-next, r=SusurrusCorey Farwell-0/+8
New error codes next Part #42229. To be merged after #42264. cc @Susurrus
2017-06-01Rollup merge of #42136 - petrochenkov:oldhard, r=nikomatsakisCorey Farwell-8/+0
Turn sufficiently old compatibility lints into hard errors It's been almost 7 months since https://github.com/rust-lang/rust/pull/36894 was merged, so it's time to take the next step. [breaking-change], needs crater run. PRs/issues submitted to affected crates: https://github.com/alexcrichton/ctest/pull/17 https://github.com/Sean1708/rusty-cheddar/pull/55 https://github.com/m-r-r/helianto/pull/3 https://github.com/azdle/virgil/pull/1 https://github.com/rust-locale/rust-locale/issues/24 https://github.com/mneumann/acyclic-network-rs/pull/1 https://github.com/reem/rust-typemap/pull/38 cc https://internals.rust-lang.org/t/moving-forward-on-forward-compatibility-lints/4204 cc https://github.com/rust-lang/rust/issues/34537 https://github.com/rust-lang/rust/issues/36887 Closes https://github.com/rust-lang/rust/issues/36886 Closes https://github.com/rust-lang/rust/issues/36888 Closes https://github.com/rust-lang/rust/issues/36890 Closes https://github.com/rust-lang/rust/issues/36891 Closes https://github.com/rust-lang/rust/issues/36892 r? @nikomatsakis
2017-05-31Improve error message for const extern fnManish Goregaokar-0/+4
2017-05-31Extend the unused macro lint to macros 2.0est31-4/+7
2017-05-31Emit proper expectation for the "default" keyword.Masaki Hara-2/+11
2017-05-31Parse macros named "default" correctly.Masaki Hara-19/+14
2017-05-31Add warning cycle #42326.Masaki Hara-1/+14
2017-05-30Turn sufficiently old compatibility lints into hard errorsVadim Petrochenkov-8/+0
2017-05-30Add new error codeGuillaume Gomez-0/+8
2017-05-28Auto merge of #42175 - michaelwoerister:filemap-hashing-fix-1, r=nikomatsakisbors-28/+0
incr.comp.: Track expanded spans instead of FileMaps. This PR removes explicit tracking of FileMaps in response to #42101. The reasoning behind being able to just *not* track access to FileMaps is similar to why we don't track access to the `DefId->DefPath` map: 1. One can only get ahold of a `Span` value by accessing the HIR (for local things) or a `metadata::schema::Entry` (for things from external crates). 2. For both of these things we compute a hash that incorporates the *expanded spans*, that is, what we hash is in the (FileMap independent) format `filename:line:col`. 3. Consequently, everything that emits a span should already be tracked via its dependency to something that has the span included in its hash and changes would be detected via that hash. One caveat here is that we have to be conservative when exporting things in metadata. A crate can be built without debuginfo and would thus by default not incorporate most spans into the metadata hashes. However, a downstream crate can make an inline copy of things in the upstream crate and span changes in the upstream crate would then go undetected, even if the downstream uses them (e.g. by emitting debuginfo for an inlined function). For this reason, we always incorporate spans into metadata hashes for now (there might be more efficient ways to handle this safely when red-green tracking is implemented). r? @nikomatsakis
2017-05-27Rollup merge of #42207 - Nashenas88:remove_fragment_info, r=eddybMark Simulacrum-6/+0
Remove all instances of fragment_infos and fragment sets Remove unused fragment structs. This was suggested by @eddyb in IRC: [botbot link](https://botbot.me/mozilla/rustc/2017-05-23/?msg=86016574&page=2).
2017-05-27Auto merge of #42162 - est31:closure-to-fn-coercion, r=aturonbors-6/+2
Stabilize non capturing closure to fn coercion Stabilisation PR for non capturing closure to fn coercion. closes #39817
2017-05-27Auto merge of #42103 - jorendorff:master, r=estebankbors-3/+12
trace_macro: Show both the macro call and its expansion. #42072. See #42072 for the initial motivation behind this. The change is not the minimal fix, but I want this behavior almost every time I use `trace_macros`.
2017-05-27Stabilize unions with `Copy` fields and no destructorVadim Petrochenkov-6/+0
2017-05-26Auto merge of #42058 - froydnj:thiscall-support, r=nikomatsakisbors-0/+9
add thiscall calling convention support This support is needed for bindgen to work well on 32-bit Windows, and also enables people to begin experimenting with C++ FFI support on that platform. Fixes #42044.
2017-05-25Auto merge of #40847 - jseyfried:decl_macro, r=nrcbors-66/+151
Initial implementation of declarative macros 2.0 Implement declarative macros 2.0 (rust-lang/rfcs#1584) behind `#![feature(decl_macro)]`. Differences from `macro_rules!` include: - new syntax: `macro m(..) { .. }` instead of `macro_rules! m { (..) => { .. } }` - declarative macros are items: ```rust // crate A: pub mod foo { m!(); // use before definition; declaration order is irrelevant pub macro m() {} // `pub`, `pub(super)`, etc. work } fn main() { foo::m!(); // named like other items { use foo::m as n; n!(); } // imported like other items } pub use foo::m; // re-exported like other items // crate B: extern crate A; // no need for `#[macro_use]` A::foo::m!(); A::m!(); ``` - Racket-like hygiene for items, imports, methods, fields, type parameters, privacy, etc. - Intuitively, names in a macro definition are resolved in the macro definition's scope, not the scope in which the macro is used. - This [explaination](http://beautifulracket.com/explainer/hygiene.html) of hygiene for Racket applies here (except for the "Breaking Hygiene" section). I wrote a similar [explanation](https://github.com/jseyfried/rfcs/blob/hygiene/text/0000-hygiene.md) for Rust. - Generally speaking, if `fn f() { <body> }` resolves, `pub macro m() { <body> } ... m!()` also resolves, even if `m!()` is in a separate crate. - `::foo::bar` in a `macro` behaves like `$crate::foo::bar` in a `macro_rules!`, except it can access everything visible from the `macro` (thus more permissive). - See [`src/test/{run-pass, compile-fail}/hygiene`](https://github.com/rust-lang/rust/pull/40847/commits/afe7d89858fd72b983e24727d6f4058293153c19) for examples. Small example: ```rust mod foo { fn f() { println!("hello world"); } pub macro m() { f(); } } fn main() { foo::m!(); } ``` Limitations: - This does not address planned changes to matchers (`expr`,`ty`, etc.), c.f. #26361. - Lints (including stability and deprecation) and `unsafe` are not hygienic. - adding hygiene here will be mostly or entirely backwards compatible - Nested macro definitions (a `macro` inside another `macro`) don't always work correctly when invoked from external crates. - pending improvements in how we encode macro definitions in crate metadata - There is no way to "escape" hygiene without using a procedural macro. r? @nrc
2017-05-25Remove irrelevant tests and unused testing attributePaul Faria-6/+0
2017-05-25Stabilize non capturing closure to fn coercionest31-6/+2
2017-05-25Auto merge of #41145 - matthewjasper:stabilize-relaxed-adts, r=petrochenkovbors-25/+3
Stabilize rfc 1506 - Clarified ADT Kinds Closes #35626 Documentation: - [ ] Reference rust-lang-nursery/reference#37 - [ ] Book? - [ ] Rust by example?
2017-05-25Hygienize lifetimes.Jeffrey Seyfried-13/+13
2017-05-25Hygienize `librustc_resolve`.Jeffrey Seyfried-21/+47
2017-05-25Declarative macros 2.0 without hygiene.Jeffrey Seyfried-29/+66
2017-05-25Refactor out `ast::MacroDef`.Jeffrey Seyfried-7/+29
2017-05-24Rollup merge of #42120 - euclio:unicode, r=arielb1Mark Simulacrum-1/+1
remove "much" from unicode diagnostic The English seems slightly awkward to me, and it's unnecessary.
2017-05-24Rollup merge of #42071 - nrc:parse-mods, r=nikomatsakisMark Simulacrum-10/+46
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-24add thiscall calling convention supportNathan Froyd-0/+9
This support is needed for bindgen to work well on 32-bit Windows, and also enables people to begin experimenting with C++ FFI support on that platform. Fixes #42044.
2017-05-23incr.comp.: Track expanded spans instead of FileMaps.Michael Woerister-28/+0
2017-05-23Stabilize in 1.19Matthew-789/+896
2017-05-23Rollup merge of #42016 - pietroalbini:stabilize/loop_break_value, r=nikomatsakisCorey Farwell-7/+2
Stabilize the loop_break_value feature Tracking issue: #37339. Documentation PRs already sent to the various repositories.
2017-05-20Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrumbors-1/+1
Correct some stability versions These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-20remove "much" from unicode diagnosticAndy Russell-1/+1
2017-05-20Correct some stability versionsOliver Middleton-1/+1
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-19Rollup merge of #42006 - jseyfried:fix_include_regression, r=nrcMark Simulacrum-5/+5
Fix ICE on `include!(line!())` (regression) Fixes #41776. r? @nrc
2017-05-19trace_macro: Show both the macro call and its expansion. #42072.Jason Orendorff-3/+12
2017-05-18Add an option to the parser to avoid parsing out of line modulesNick Cameron-10/+46
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-17Stabilize the loop_break_value featurePietro Albini-7/+2