about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2019-07-23Update src/librustc_lexer/src/lib.rsAleksey Kladov-1/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-07-22add rustc_private as a proper language feature gateAleksey Kladov-8/+35
At the moment, `rustc_private` as a (library) feature exists by accident: `char::is_xid_start`, `char::is_xid_continue` methods in libcore define it.
2019-07-21Auto merge of #59706 - matklad:the-essence-of-lexer, r=petrochenkovbors-1259/+1335
The essence of lexer cc @eddyb I would love to make a reusable library to lex rust code, which could be used by rustc, rust-analyzer, proc-macros, etc. This **draft** PR is my attempt at the API. Currently, the PR uses new lexer to lex comments and shebang, while using the old lexer for everything else. This should be enough to agree on the API though! ### High-level picture An `rust_lexer` crate is introduced, with zero or minimal (for XID_Start and other unicode) dependencies. This crate basically exposes a single function: `next_token(&str) -> (TokenKind, usize)` which returns the first token of a non-empty string (`usize` is the length of the token). The main goal of the API is to be minimal. Non-strictly essential concerns, like string interning, are left to the clients. ### Finer Points #### Iterator API We probably should expose a convenience function `fn tokenize(&str) -> impl Iterator<Item = Token>` EDIT: I've added `tokenize` #### Error handling The lexer itself provides only minimal amount of error detection and reporting. Additionally, it never fatal-errors and always produces some non-empty token. Examples of errors detected by the lexer: * unterminated block comment * unterminated string literals Example of errors **not** detected by the lexer: * invalid escape sequence in a string literal * out of range integer literal * bare `\r` in the doc comment. The idea is that the clients are responsible for additional validation of tokens. This is the mode IDE operates in: you want to skip validation for library files, because you are not showing errors there anyway, and for user-code, you want to do a deep validation with quick fixes and suggestions, which is not really fit for the lexer itself. In particular, in this PR unclosed `/*` comment is handled by the new lexer, bare `\r` and distinction between doc and non-doc comments is handled by the old lexer. #### Performance No attempt at performance measurement is made so far :) I think it is acceptable to regress perf here a bit in exchange for cleaner code, and I hope that regression wouldn't be too costly. In particular, because we validate tokens separately, we'll have to do one more pass for some of the tokens. I hope this is not a prohibitive cost. For example, for doc comments we already do two passes (lexing + interning), so adding a third one shouldn't be that much slower (and we also do an additional pass for utf-8 validation). And lexing is hopefully not a bottleneck. Note that for IDEs separate validation might actually improve performance, because we will be able to skip validation when, for example, computing completions. Long term, I hope that this approach will allow for *better* performance. If we separate pure lexing, in the future we can code-gen super-optimizes state machine that walks utf-8 directly, instead of current manual char-by-char toil. #### Cursor API For implementation, I am going slightly unconventionally. Instead of defining a `Lexer` struct with a bunch of helper methods (`current`, `bump`) and a bunch of lexing methods (`lex_comment`, `lex_whitespace`), I define a `Cursor` struct which has only helpers, and define a top-level function with a `&mut Cursor` argument for each grammar production. I find this C-style more readable for parsers and lexers. EDIT: swithced to a more conventional setup with lexing methods So, what do folks think about this?
2019-07-21Auto merge of #60913 - spastorino:place2_4, r=oli-obkbors-989/+1735
Place 2.0 change from enum to struct r? @oli-obk
2019-07-20Introduce rustc_lexerAleksey Kladov-1259/+1335
The idea here is to make a reusable library out of the existing rust-lexer, by separating out pure lexing and rustc-specific concerns, like spans, error reporting an interning. So, rustc_lexer operates directly on `&str`, produces simple tokens which are a pair of type-tag and a bit of original text, and does not report errors, instead storing them as flags on the token.
2019-07-20Auto merge of #62789 - GuillaumeGomez:update-pulldown-cmark, r=Manishearthbors-28/+28
Update pulldown-cmark version Fixes https://github.com/rust-lang/rust/issues/62571. Fixes #62770. Fixes #62552. cc @rust-lang/rustdoc @Centril @pietroalbini
2019-07-20Update pulldown-cmark versionGuillaume Gomez-28/+28
2019-07-20Auto merge of #62710 - estebank:bad-named-args, r=petrochenkovbors-34/+53
Specific error for positional args after named args in `format!()` When writing positional arguments after named arguments in the `format!()` and `println!()` macros, provide a targeted diagnostic. Follow up to https://github.com/rust-lang/rust/pull/57522/files#r247278885
2019-07-20Avoid cloning Place in check_and_patchSantiago Pastorino-12/+13
2019-07-20Avoid cloning Place in visit_rvalueSantiago Pastorino-4/+4
2019-07-20Avoid cloning Place in assign #2Santiago Pastorino-8/+2
2019-07-20Avoid cloning Place in assign #1Santiago Pastorino-8/+3
2019-07-20Avoid cloning Place in in_projection_structurallySantiago Pastorino-20/+20
2019-07-20Avoid cloning Place in is_stableSantiago Pastorino-5/+6
2019-07-20Avoid unneeded else branchesSantiago Pastorino-22/+13
2019-07-20Avoid cloning Place in gather_initSantiago Pastorino-13/+13
2019-07-20Avoid cloning Place in calculate_fake_borrowsSantiago Pastorino-9/+18
2019-07-20Avoid cloning Place in limit_capture_mutabilitySantiago Pastorino-3/+3
2019-07-20Avoid cloning Place in report_cannot_move_from_borrowed_contentSantiago Pastorino-12/+12
2019-07-20Avoid cloning Place in report_cannot_move_from_staticSantiago Pastorino-4/+4
2019-07-20Avoid cloning Place in check_access_permissionsSantiago Pastorino-28/+36
2019-07-20Avoid cloning Place in append_place_to_stringSantiago Pastorino-14/+15
2019-07-20Avoid cloning Place in classify_drop_access_kindSantiago Pastorino-5/+5
2019-07-20Avoid cloning Place in describe_place_for_conflicting_borrowSantiago Pastorino-37/+42
2019-07-20Avoid cloning Place in report_use_of_moved_or_uninitialized and friendsSantiago Pastorino-231/+253
2019-07-20Remove explicit lifetimeSantiago Pastorino-3/+3
2019-07-20Remove explicit return from last line of fnSantiago Pastorino-1/+1
2019-07-20Avoid cloning Place in codegen_placeSantiago Pastorino-40/+51
2019-07-20Implement Place::as_place_refSantiago Pastorino-6/+8
2019-07-20Avoid cloning place in LocalAnalyzer visitorSantiago Pastorino-56/+91
2019-07-20Migrate from Place enum to Place structSantiago Pastorino-790/+1461
2019-07-20Auto merge of #62008 - ia0:issues_61053, r=petrochenkovbors-68/+946
Add meta-variable checks in macro definitions This is an implementation of #61053. It is not sound (some errors are not reported) and not complete (reports may not be actual errors). This is due to the possibility to define macros in macros in indirect ways. See module documentation of `macro_check` for more details. What remains to be done: - [x] Migrate from an error to an allow-by-default lint. - [x] Add more comments in particular for the handling of nested macros. - [x] Add more tests if needed. - [x] Try to avoid cloning too much (one idea is to use lists on the stack). - [ ] Run crater with deny-by-default lint (measure rate of false positives). - [ ] Remove extra commit for deny-by-default lint - [x] Create a PR to remove the old `question_mark_macro_sep` lint #62160
2019-07-19Auto merge of #62705 - petrochenkov:oh-bye-mark, r=matthewjasperbors-372/+378
libsyntax: Rename `Mark` into `ExpnId` "`Mark`" is an ID that identifies both a macro invocation (`foo!()`), and expansion process, and expansion result of that macro invocation. The problem is that it's pretty hard to infer that from its name. This PR renames it into `ExpnId` reflecting its meaning in most contexts. (The contexts where it's meaning is closer to "macro invocation ID" are rarer.) I've kept "mark" in the names of functions that add or remove marks to/from syntactic contexts, those marks are not just expansion IDs, but something more complex.
2019-07-19Implement checks for meta-variables in macrosJulien Cretin-47/+913
2019-07-19Remember the span of the Kleene operator in macrosJulien Cretin-21/+33
This is needed for having complete error messages where reporting macro variable errors. Here is what they would look like: error: meta-variable repeats with different kleene operator --> $DIR/issue-61053-different-kleene.rs:3:57 | LL | ( $( $i:ident = $($j:ident),+ );* ) => { $( $( $i = $j; )* )* }; | - expected repetition ^^ - conflicting repetition
2019-07-19Auto merge of #62690 - alexcrichton:azure-update, r=pietroalbinibors-13/+71
azure: Prepare configuration for 4-core machines This commit updates some of our assorted Azure/CI configuration to prepare for some 4-core machines coming online. We're still in the process of performance testing them to get final numbers, but some changes are worth landing ahead of this. The updates here are: * Use `C:/` instead of `D:/` for submodule checkout since it should have plenty of space and the 4-core machines won't have `D:/` * Update `lzma-sys` to 0.1.14 which has support for VS2019, where 0.1.10 doesn't. * Update `src/ci/docker/run.sh` to work when it itself is running inside of a docker container (see the comment in the file for more info) * Print step timings on the `try` branch in addition to the `auto` branch in. The logs there should be seen by similarly many humans (not many) and can be useful for performance analysis after a `try` build runs. * Install the WIX and InnoSetup tools manually on Windows instead of relying on pre-installed copies on the VM. This gives us more control over what's being used on the Azure cloud right now (we control the version) and in the 4-core machines these won't be pre-installed. Note that on AppVeyor we actually already were installing InnoSetup, we just didn't carry that over on Azure!
2019-07-19azure: Prepare configuration for 4-core machinesAlex Crichton-13/+71
This commit updates some of our assorted Azure/CI configuration to prepare for some 4-core machines coming online. We're still in the process of performance testing them to get final numbers, but some changes are worth landing ahead of this. The updates here are: * Use `C:/` instead of `D:/` for submodule checkout since it should have plenty of space and the 4-core machines won't have `D:/` * Update `lzma-sys` to 0.1.14 which has support for VS2019, where 0.1.10 doesn't. * Update `src/ci/docker/run.sh` to work when it itself is running inside of a docker container (see the comment in the file for more info) * Print step timings on the `try` branch in addition to the `auto` branch in. The logs there should be seen by similarly many humans (not many) and can be useful for performance analysis after a `try` build runs. * Install the WIX and InnoSetup tools manually on Windows instead of relying on pre-installed copies on the VM. This gives us more control over what's being used on the Azure cloud right now (we control the version) and in the 4-core machines these won't be pre-installed. Note that on AppVeyor we actually already were installing InnoSetup, we just didn't carry that over on Azure!
2019-07-19Auto merge of #62679 - Xanewok:after-expansion, r=Zoxcbors-8/+20
Add an `after_expansion` callback in the driver To format a given file RLS needs to know the Rust edition associated with it. It's not enough to look at the `edition` key in Cargo.toml - each crate target can have a different edition associated with it so the sure way to fetch a correct edition is to scan the input files used to compile a given crate target. Right now this was done in the `after_analysis` callback of our shim, however this leads to other problems - if a crate cannot be successfully compiled (e.g. it has a type error) then a callback would not be invoked meaning we can't populate the files -> edition mapping. However, doing this only after parsing is not enough, since expansion can pull in additional source files (e.g. by invoking `macro_rules! include_my_mod { () => { mod some_mod; }; }`). Without copy-pasting the entire driver setup it's also not possible to expand the crate ourselves in the `after_parsing` callback - to expand crate we'd need to register plugins and initialize session ourselves. However, this is done normally after executing the callback itself, thus triggering the `Once::set` assertions in `Session::init_features`. r? @Zoxc cc @RalfJung @oli-obk this affects public driver interface used by Miri and Clippy
2019-07-19hygiene: Tweak naming some moreVadim Petrochenkov-64/+65
2019-07-19Adjust other names after the `Mark` renamingVadim Petrochenkov-192/+196
2019-07-19libsyntax: Remove `Mark` into `ExpnId`Vadim Petrochenkov-182/+183
2019-07-19Auto merge of #62694 - lundibundi:help-infer-fn-ret, r=eddybbors-42/+125
rustc_typeck: improve diagnostics for -> _ fn return type This should implement IIUC the mentioned issue. ~~I'm not sure if there is a better way than `get_infer_ret_ty` to get/check the return type without code duplication.~~ ~~Also, is this unwrap be okay `ty::Binder::bind(*tables.liberated_fn_sigs().get(hir_id).unwrap())`?~~ r? @eddyb Closes: https://github.com/rust-lang/rust/issues/56132
2019-07-19Auto merge of #62684 - petrochenkov:scopevisit, r=davidtwcobors-1271/+1170
resolve: Improve candidate search for unresolved macro suggestions Use same scope visiting machinery for both collecting suggestion candidates and actually resolving the names. The PR is better read in per-commit fashion with whitespace changes ignored (the first commit in particular moves some code around). This should be the last pre-requisite for https://github.com/rust-lang/rust/pull/62086. r? @davidtwco
2019-07-18Auto merge of #61749 - davidtwco:rfc-2203-const-array-repeat-exprs, r=eddybbors-142/+659
rustc/rustc_mir: Implement RFC 2203. This PR implements RFC 2203, allowing constants in array repeat expressions. Part of #49147. r? @eddyb
2019-07-18Auto merge of #62782 - Mark-Simulacrum:rollup-1hz5ya6, r=Mark-Simulacrumbors-299/+319
Rollup of 15 pull requests Successful merges: - #61926 (Fix hyperlinks in From impls between Vec and VecDeque) - #62615 ( Only error about MSVC + PGO + unwind if we're generating code) - #62696 (Check that trait is exported or public before adding hint) - #62712 (Update the help message on error for self type) - #62728 (Fix repeated wording in slice documentation) - #62730 (Consolidate hygiene tests) - #62732 (Remove last use of mem::uninitialized from std::io::util) - #62740 (Add missing link to Infallible in TryFrom doc) - #62745 (update data_layout and features for armv7-wrs-vxworks) - #62749 (Document link_section arbitrary bytes) - #62752 (Disable Z3 in LLVM build) - #62764 (normalize use of backticks in compiler messages for librustc/lint) - #62774 (Disable simd_select_bitmask test on big endian) - #62777 (Self-referencial type now called a recursive type) - #62778 (Emit artifact notifications for dependency files) Failed merges: - #62746 ( do not use mem::uninitialized in std::io) r? @ghost
2019-07-18Rollup merge of #62778 - jsgf:notify-dep-info, r=petrochenkovMark Rousskov-6/+14
Emit artifact notifications for dependency files Emit `dep-info` artifact notifications for `.d` files.
2019-07-18Rollup merge of #62777 - gilescope:self-referencial-to-recursion, r=eddybMark Rousskov-18/+36
Self-referencial type now called a recursive type As per Boat's suggestion - #62539, this makes the error message clearer.
2019-07-18Rollup merge of #62774 - smaeul:pr/simd-tests, r=petrochenkovMark Rousskov-0/+4
Disable simd_select_bitmask test on big endian Per #59356 it is expected that the interpretation of the bitmask depends on target endianness. Closes #59356
2019-07-18Rollup merge of #62764 - ↵Mark Rousskov-177/+177
fakenine:normalize_use_of_backticks_compiler_messages_p7, r=alexreg normalize use of backticks in compiler messages for librustc/lint https://github.com/rust-lang/rust/issues/60532
2019-07-18Rollup merge of #62752 - nikic:llvm-disable-z3, r=alexcrichtonMark Rousskov-0/+1
Disable Z3 in LLVM build Avoid building LLVM with Z3 if it happens to be installed. Fixes #62750. r? @alexcrichton