summary refs log tree commit diff
path: root/src/librustc_ast
AgeCommit message (Collapse)AuthorLines
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-1/+2
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-1/+2
2020-05-29Revert "Move functions to librustc_parse"Aaron Hill-0/+177
This reverts commit 7a4c1865fb2f58c57e3f09645515dec8be3022c6.
2020-05-29Revert "Recursively expand nonterminals"Aaron Hill-0/+2
This reverts commit 2af0218bf1ffca0750a352554f20a07b760a30a8.
2020-05-29Revert "Fix rebase fallout"Aaron Hill-0/+2
This reverts commit 5685e4dd90ad2f4978c63b9097f0b568e4ce6e5c.
2020-05-24Collect tokens for `ast::Expr`Aaron Hill-2/+6
2020-05-22Fix rebase falloutAaron Hill-2/+0
2020-05-22Recursively expand nonterminalsAaron Hill-2/+0
2020-05-22Move functions to librustc_parseAaron Hill-177/+0
2020-05-19Use a fixed-point iteration when breaking tokensAaron Hill-5/+40
Some tokens need to be broken in a loop until we reach 'unbreakable' tokens.
2020-05-19Break tokens before checking if they are 'probably equal'Aaron Hill-2/+32
Fixes #68489 When checking two `TokenStreams` to see if they are 'probably equal', we ignore the `IsJoint` information associated with each `TokenTree`. However, the `IsJoint` information determines whether adjacent tokens will be 'glued' (if possible) when construction the `TokenStream` - e.g. `[Gt Gt]` can be 'glued' to `BinOp(Shr)`. Since we are ignoring the `IsJoint` information, 'glued' and 'unglued' tokens are equivalent for determining if two `TokenStreams` are 'probably equal'. Therefore, we need to 'unglue' all tokens in the stream to avoid false negatives (which cause us to throw out the cached tokens, losing span information).
2020-05-18Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_astAmanieu d'Antras-2/+55
2020-05-18Add asm! to ASTAmanieu d'Antras-1/+99
2020-05-16Rollup merge of #72047 - ↵Ralf Jung-33/+42
Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov Literal error reporting cleanup While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up. This PR is probably best reviewed commit by commit. I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now. I could open a PR for Rust-Analyzer when this one lands. But how do I open a PR for clippy? (Git submodules are frustrating to work with)
2020-05-13Replace some usages of the old `unescape_` functions in AST, clippy and tests.Julian Wollersberger-33/+42
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-30/+30
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-08Work around ICEs during cross-compilationCameron Taggart-0/+4
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-30/+30
2020-05-01Rollup merge of #71762 - tshepang:typo, r=jonas-schievinkDylan DPC-1/+1
doc: this resulted in a link pointing to a non-existent target
2020-05-01doc: this resulted in a link pointing to a non-existent targetTshepang Lekhonkhobe-1/+1
2020-05-01doc: reference does not exist, probably a typoTshepang Lekhonkhobe-1/+1
2020-04-20Rollup merge of #71284 - JOE1994:serialize_id, r=petrochenkovDylan DPC-4/+4
fix -Zast-json to output correct JSON form fixes #71086 (Reverts some of the changes made in #70215) JSON output (from an empty library) after fix has something for **"id"** field ```shell lonelyjoe@lonelyjoe-desktop:~/workspace/empty_lib/src$ rustc lib.rs -Zast-json ``` ```json { "module":{ "inner":{ "lo":0, "hi":94 }, "items":[ { "attrs":[ { "kind":{ "variant":"Normal", "fields":[ { "path":{ "span":{ "lo":0, "hi":0 }, "segments":[ { "ident":{ "name":"prelude_import", "span":{ "lo":0, "hi":0 } }, "id":3, "args":null } ] }, "args":"Empty" } ] }, "id":null, "style":"Outer", "span":{ "lo":0, "hi":0 } } ], "id":4, "span":{ "lo":0, "hi":0 }, "vis":{ "node":"Inherited", "span":{ "lo":0, "hi":0 } }, "ident":{ "name":"", "span":{ "lo":0, "hi":0 } }, "kind":{ "variant":"Use", "fields":[ { "prefix":{ "span":{ "lo":0, "hi":0 }, "segments":[ { "ident":{ "name":"{{root}}", "span":{ "lo":0, "hi":0 } }, "id":5, "args":null }, { "ident":{ "name":"std", "span":{ "lo":0, "hi":0 } }, "id":6, "args":null }, { "ident":{ "name":"prelude", "span":{ "lo":0, "hi":0 } }, "id":7, "args":null }, { "ident":{ "name":"v1", "span":{ "lo":0, "hi":0 } }, "id":8, "args":null } ] }, "kind":"Glob", "span":{ "lo":0, "hi":0 } } ] }, "tokens":null }, { "attrs":[ { "kind":{ "variant":"Normal", "fields":[ { "path":{ "span":{ "lo":0, "hi":0 }, "segments":[ { "ident":{ "name":"macro_use", "span":{ "lo":0, "hi":0 } }, "id":9, "args":null } ] }, "args":"Empty" } ] }, "id":null, "style":"Outer", "span":{ "lo":0, "hi":0 } } ], "id":10, "span":{ "lo":0, "hi":0 }, "vis":{ "node":"Inherited", "span":{ "lo":0, "hi":0 } }, "ident":{ "name":"std", "span":{ "lo":0, "hi":0 } }, "kind":{ "variant":"ExternCrate", "fields":[ null ] }, "tokens":null } ], "inline":true }, "attrs":[ ], "span":{ "lo":0, "hi":94 }, "proc_macros":[ ] } ```
2020-04-19fix decode logic for 'AttrId' to be symmetric with encode logicJOE1994-2/+2
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-6/+8
2020-04-18Move `MapInPlace` to rustc_data_structuresYuki Okushi-112/+1
2020-04-17fix -Zast-json to properly output the 'id' fieldJOE1994-2/+2
2020-04-06Rollup merge of #70519 - estebank:constraints-before-args-spans, r=CentrilMazdak Farrokhzad-2/+2
Tweak output of type params and constraints in the wrong order r? @Centril @varkor
2020-04-05Stop importing int/float modules in librustc_*Linus Färnstrand-1/+0
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-3/+3
2020-03-29Suggest correct order for arguments when encountering early constraintsEsteban Küber-2/+2
When encountering constraints before type arguments or lifetimes, suggest the correct order.
2020-03-27parse: move constraint/arg restriction to ast_validation.Mazdak Farrokhzad-15/+30
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-17/+17
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-25make bit_width return u64, consistently with other sizes in the compilerRalf Jung-3/+3
2020-03-23Split long derive lists into two derive attributes.Ana-Maria Mihalache-65/+10
2020-03-23Auto merge of #70296 - Centril:rollup-wvfmb3n, r=Centrilbors-1/+1
Rollup of 9 pull requests Successful merges: - #69251 (#[track_caller] in traits) - #69880 (miri engine: turn error sanity checks into assertions) - #70207 (Use getentropy(2) on macos) - #70227 (Only display definition when suggesting a typo) - #70236 (resolve: Avoid "self-confirming" import resolutions in one more case) - #70248 (parser: simplify & remove unused field) - #70249 (handle ConstKind::Unresolved after monomorphizing) - #70269 (remove redundant closures (clippy::redundant_closure)) - #70270 (Clean up E0449 explanation) Failed merges: r? @ghost
2020-03-23Auto merge of #70204 - Centril:unshackled-lowering, r=Zoxcbors-0/+36
Liberate `rustc_ast_lowering` from `rustc` The whole point of this PR is the very last commit, in which we remove `rustc` as one of `rustc_ast_lowering`'s dependencies, thereby improving `./x.py` parallelism and working towards https://github.com/rust-lang/rust/issues/65031. Noteworthy: - From `rustc::arena` we move logic into `arena`, in particular `declare_arena!`. This is then used in `rustc_ast_lowering` so that lowering has its own separate arena. - Some linting code is unfortunately moved to `rustc_session::lint` cause its used both in `rustc_lint` and `rustc_ast_lowering`, and this is their common dependency. - `rustc_session::CrateDisambiguator` is moved into `rustc_ast` so that `rustc::hir::map::definitions` can be moved into `rustc_hir`, so that `rustc_ast_lowering` can stop referring to `rustc::hir`. r? @Zoxc
2020-03-22remove redundant closures (clippy::redundant_closure)Matthias Krüger-1/+1
2020-03-21move CrateDisambiguator -> rustc_astMazdak Farrokhzad-0/+36
2020-03-21ast: Compress `AttrId` from `usize` to `u32`Vadim Petrochenkov-18/+12
Also stop encoding/decoding it entirely
2020-03-20can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-5/+14
2020-03-18Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obkMazdak Farrokhzad-1/+3
Make methods declared by `newtype_index` macro `const` Crates that use the macro to define an `Idx` type need to enable `#![feature(const_if_match, const_panic)]`.
2020-03-18de-fatalize outline module parsingMazdak Farrokhzad-1/+1
2020-03-17Add requisite feature gates for const assertDylan MacKenzie-0/+2
2020-03-17Rename `from_u32_const` -> `from_u32`Dylan MacKenzie-1/+1
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-2/+2
2020-03-15Rollup merge of #69988 - petrochenkov:nomacrodef, r=CentrilMazdak Farrokhzad-1/+1
rustc_metadata: Remove `rmeta::MacroDef` And other related cleanups. Follow-up to https://github.com/rust-lang/rust/pull/66364. r? @Centril
2020-03-15Rollup merge of #69589 - petrochenkov:maccall, r=CentrilMazdak Farrokhzad-46/+46
ast: `Mac`/`Macro` -> `MacCall` It's now obvious that these refer to macro calls rather than to macro definitions. It's also a single name instead of two different names in different places. `rustc_expand` usually calls macro calls in a wide sense (including attributes and derives) "macro invocations", but structures and variants renamed in this PR are only relevant to fn-like macros, so it's simpler and clearer to just call them calls. cc https://github.com/rust-lang/rust/pull/63586#discussion_r314232513 r? @eddyb
2020-03-14rustc_metadata: Remove `rmeta::MacroDef`Vadim Petrochenkov-1/+1
Use `ast::MacroDef` instead. Also remove `Session::imported_macro_spans`, external macros have spans now.
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-46/+46
2020-03-12Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbiniMazdak Farrokhzad-3/+3
Rename rustc guide This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470 Needs to be merged after we actually rename the guide. Have used this to rename: `git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'` `git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'` `git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`