about summary refs log tree commit diff
path: root/src/librustc_ast_lowering/expr.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-1789/+0
2020-08-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-2/+2
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-2/+2
2020-08-16hir: introduce `QPath::LangItem`David Wood-101/+60
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-06Fix ICE when using asm! on an unsupported architectureAmanieu d'Antras-1/+1
Fixes #75220
2020-07-26Hygiene serialization implementationAaron Hill-1/+2
2020-07-14Suggest borrowing in more unsized fn param casesEsteban Küber-1/+1
2020-06-26Explain move errors that occur due to method calls involving `self`Aaron Hill-3/+14
This is a re-attempt of #72389 (which was reverted in #73594) Instead of using `ExpnKind::Desugaring` to represent operators, this PR checks the lang item directly.
2020-06-26Rollup merge of #73588 - Amanieu:thumb-fp, r=nagisaManish Goregaokar-0/+1
Fix handling of reserved registers for ARM inline asm `r6` is now disallowed as an operand since LLVM sometimes uses it as a base pointer. The check against using the frame pointer as an operand now takes the platform into account and will block either `r7` or `r11` as appropriate. Fixes #73450 cc @cbiffle
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-19/+5
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-21Fix handling of reserved registers for ARM inline asmAmanieu d'Antras-0/+1
2020-06-11Explain move errors that occur due to method calls involving `self`Aaron Hill-5/+19
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-2/+2
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-2/+2
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-09Fix more clippy warningsMatthias Krüger-4/+2
Fixes more of: clippy::unused_unit clippy::op_ref clippy::useless_format clippy::needless_return clippy::useless_conversion clippy::bind_instead_of_map clippy::into_iter_on_ref clippy::redundant_clone clippy::nonminimal_bool clippy::redundant_closure clippy::option_as_ref_deref clippy::len_zero clippy::iter_cloned_collect clippy::filter_next
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-26Update src/librustc_ast_lowering/expr.rsAmanieu d'Antras-1/+1
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-05-26Eagerly lower asm sub-expressions to HIR even if there is an errorAmanieu d'Antras-33/+35
Fixes #72570
2020-05-20Rollup merge of #72275 - marmeladema:fix-issue-71104-2, r=ecstatic-morseDylan DPC-1/+0
Continue lowering for unsupported async generator instead of returning an error. This way the hir is "valid" and we can remove one more call to `opt_node_id_to_hir_id` but an error is still emitted. This is another partial fix for #71104 r? @eddyb
2020-05-18Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_astAmanieu d'Antras-2/+2
2020-05-18Implement att_syntax optionAmanieu d'Antras-0/+9
2020-05-18Implement AST lowering for asm!Amanieu d'Antras-2/+294
2020-05-16Continue lowering for unsupported async generator instead of returning an error.marmeladema-1/+0
This way the hir is "valid" and we can remove one more call to `opt_node_id_to_hir_id` but an error is still emitted. This is another partial fix for #71104
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-1/+1
2020-05-02Move ensure_sufficient_stack to data_structuresSimonas Kazlauskas-1/+1
We anticipate this to have uses in all sorts of crates and keeping it in `rustc_data_structures` enables access to it from more locations without necessarily pulling in the large `librustc` crate.
2020-05-02Prevent stack overflow for deeply recursive codeOliver Scherer-176/+191
2020-04-24Use correct span on while (let) loweringflip1995-6/+2
2020-04-16Auto merge of #70831 - sfackler:shrink-future-stack, r=matthewjasperbors-11/+34
Remove a stack frame from .await calls The stack frames when `.await`ing one async fn from another currently look like this: ``` 12: foo::b::{{closure}} at src/main.rs:2 13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:66 14: core::future::poll_with_context at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:84 15: foo::a::{{closure}} at src/main.rs:6 ``` Since the move away from using TLS to pass the Context around, it's now easy to remove frame 14 by removing poll_with_context in favor of calling Future::poll directly. This still leaves the `GenFuture` frame, but that seems significantly harder to deal with. It also improves diagnostics a bit since they no longer talk about the private poll_with_context function.
2020-04-13Use clearer message when obligation is caused by await exprTyler Mandry-2/+2
2020-04-05Remove a stack frame from .await callsSteven Fackler-11/+34
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-6/+6
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-21lowering: bug! -> panic!Mazdak Farrokhzad-2/+1
2020-03-17Don't create AST fragments when lowering to HIRJonas Schievink-29/+33
2020-03-17Split up large `FnDecl` expressionJonas Schievink-14/+13
2020-03-17Improve comments in HIR lowering codeJonas Schievink-2/+3
2020-03-17FormatJonas Schievink-7/+3
2020-03-17Make async/await lowering use resume argumentsJonas Schievink-19/+76
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-1/+1
2020-03-01Rollup merge of #69580 - matthiaskrgr:map_clone, r=CentrilYuki Okushi-1/+1
use .copied() instead of .map(|x| *x) on iterators
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-4/+4
2020-02-29use .copied() instead of .map(|x| *x) on iteratorsMatthias Krüger-1/+1
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-4/+3
example: let s: String = format!("hello").into();
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-4/+4
2020-02-13IsAsync -> enum Async { Yes { span: Span, .. }, No }Mazdak Farrokhzad-1/+1
use new span for better diagnostics.
2020-02-04Update error message with too many parametersJonas Schievink-1/+1
2020-02-02Allow 0 or 1 explicit generator parametersJonas Schievink-2/+2
2020-01-21lowering: cleanup some hofsMazdak Farrokhzad-12/+3
2020-01-18remove rustc_error_codes deps except in rustc_driverMazdak Farrokhzad-1/+0
2020-01-16don't clone types that are copyMatthias Krüger-3/+3
found via clippy