about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
AgeCommit message (Collapse)AuthorLines
2022-02-24Inline a hot closure in `from_lit_token`.Nicholas Nethercote-17/+23
The change looks big because `rustfmt` rearranges things, but the only real change is the inlining annotation.
2022-02-23Rollup merge of #94128 - mqy:master, r=Dylan-DPCMatthias Krüger-1/+1
rustdoc: several minor fixes ``@rustbot`` label A-docs
2022-02-22Delete Decoder::read_unitMark Rousskov-2/+1
2022-02-19rustdoc: several minor fixesmqy-1/+1
2022-02-18Rollup merge of #93634 - matthiaskrgr:clippy_complexity_jan_2022, r=oli-obkMatthias Krüger-1/+1
compiler: clippy::complexity fixes useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-02-15Auto merge of #93752 - eholk:drop-tracking-break-continue, r=nikomatsakisbors-1/+1
Generator drop tracking: improve break and continue handling This PR fixes two related issues. One, sometimes break or continue have a block target instead of an expression target. This seems to mainly happen with try blocks. Since the drop tracking analysis only works on expressions, if we see a block target for break or continue, we substitute the last expression of the block as the target instead. Two, break and continue were incorrectly being treated as the same, so continue would also show up as an exit from the loop or block. This patch corrects the way continue is handled by keeping a stack of loop entry points and uses those to find the target of the continue. Fixes #93197 r? `@nikomatsakis`
2022-02-07Drop tracking: improve break and continue handlingEric Holk-1/+1
This commit fixes two issues. One, sometimes break or continue have a block target instead of an expression target. This seems to mainly happen with try blocks. Since the drop tracking analysis only works on expressions, if we see a block target for break or continue, we substitute the last expression of the block as the target instead. Two, break and continue were incorrectly being treated as the same, so continue would also show up as an exit from the loop or block. This patch corrects the way continue is handled by keeping a stack of loop entry points and uses those to find the target of the continue.
2022-02-07Add test for block doc comments horizontal trimGuillaume Gomez-14/+6
2022-02-07Fix horizontal trim for block doc commentsGuillaume Gomez-6/+38
2022-02-03compiler: clippy::complexity fixesMatthias Krüger-1/+1
useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-7/+8
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-22Rename `Decoder::read_nil` and `read_unit`.Nicholas Nethercote-1/+1
Because `()` is called "unit" and it makes it match `Encoder::emit_unit`.
2022-01-21Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrumbors-0/+14
Emit simpler code from format_args I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code. <br> `println!("rust")` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &match () { _args => [], })); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); }; ``` `println!("{}", x)` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &match (&x,) { _args => [::core::fmt::ArgumentV1::new( _args.0, ::core::fmt::Display::fmt, )], }, )); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)], )); }; ```
2022-01-20Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddleMatthias Krüger-11/+43
Fix star handling in block doc comments Fixes #92872. Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in: ```rust /// he /** * hello */ #[doc = "boom"] ``` We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars. r? `@camelid`
2022-01-19Correctly handle starts in block doc commentsGuillaume Gomez-11/+43
2022-01-18Rollup merge of #93018 - pierwill:rm-unused-ord, r=davidtwcoMatthias Krüger-2/+2
Remove some unused `Ord` derives based on `Span` Remove some `Ord`, `PartialOrd` derivations that rely on underlying ordering of `Span`. These ordering traits appear to be unused right now. If we're going to attempt to remove ordering traits from `Span` as suggested in https://github.com/rust-lang/rust/issues/90317#issuecomment-1013980591, we might want to slowly remove code that depends on this ordering (as opposed to the all-at-once approach in https://github.com/rust-lang/rust/pull/90749 and https://github.com/rust-lang/rust/pull/90408). cc `@tmiasko` `@cjgillot`
2022-01-17Rm some unused ord implspierwill-2/+2
2022-01-17Emit simpler code from format_argsDavid Tolnay-0/+14
2022-01-17Add termkadmin-8/+29
Instead of having a separate enum variant for types and consts have one but have either a const or type.
2022-01-17add eq constraints on associated constantskadmin-28/+23
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-63/+1
2022-01-10Rollup merge of #92357 - GuillaumeGomez:fix-doc-comment-backline-removal, ↵Matthias Krüger-7/+0
r=camelid Fix invalid removal of newlines from doc comments Fixes https://github.com/rust-lang/rust/issues/91201. Before: ![Screenshot from 2021-12-28 17-02-11](https://user-images.githubusercontent.com/3050060/147585187-c8e67531-c1b4-457d-9d30-d5b44bf91fea.png) After: ![Screenshot from 2021-12-28 17-02-25](https://user-images.githubusercontent.com/3050060/147585190-30aa0398-1fc7-4fe7-9e8b-5c475d4f9613.png) r? `@camelid`
2022-01-07expand: Refactor `InvocationCollector` visitor for better code reuseVadim Petrochenkov-3/+38
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-3/+7
This makes it more uniform with other expanded nodes
2022-01-01Auto merge of #92294 - Kobzol:rustdoc-meta-kind, r=GuillaumeGomezbors-4/+25
Add Attribute::meta_kind The `AttrItem::meta` function is being called on a lot of places, however almost always the caller is only interested in the `kind` of the result `MetaItem`. Before, the `path` had to be cloned in order to get the kind, now it does not have to be. There is a larger related "problem". In a lot of places, something wants to know contents of attributes. This is accessed through `Attribute::meta_item_list`, which calls `AttrItem::meta` (now `AttrItem::meta_kind`), among other methods. When this function is called, the meta item list has to be recreated from scratch. Everytime something asks a simple question (like is this item/list of attributes `#[doc(hidden)]`?), the tokens of the attribute(s) are cloned, parsed and the results are allocated on the heap. That seems really unnecessary. What would be the best way to cache this? Turn `meta_item_list` into a query perhaps? Related PR: https://github.com/rust-lang/rust/pull/92227 r? rust-lang/rustdoc
2021-12-30Rollup merge of #91519 - petrochenkov:cratexp2, r=Aaron1011Matthias Krüger-12/+116
ast: Avoid aborts on fatal errors thrown from mutable AST visitor Set the node to some dummy value and rethrow the error instead. When using the old aborting `visit_clobber` in `InvocationCollector::visit_crate` the next tests abort due to fatal errors: ``` ui\modules\path-invalid-form.rs ui\modules\path-macro.rs ui\modules\path-no-file-name.rs ui\parser\issues\issue-5806.rs ui\parser\mod_file_with_path_attr.rs ``` Follow up to https://github.com/rust-lang/rust/pull/91313.
2021-12-28Fix invalid removal of backlines from doc commentsGuillaume Gomez-7/+0
2021-12-26Add Attribute::meta_kindJakub Beránek-4/+25
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-15Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Rollup merge of #91774 - surechen:fix_typo_1, r=wesleywiserMatthias Krüger-1/+1
Fix typo for MutVisitor Fix typo for MutVisitor.
2021-12-12Auto merge of #90207 - BoxyUwU:stabilise_cg_defaults, r=lcnrbors-9/+2
Stabilise `feature(const_generics_defaults)` `feature(const_generics_defaults)` is complete implementation wise and has a pretty extensive test suite so I think is ready for stabilisation. needs stabilisation report and maybe an RFC :sweat_smile: r? `@lcnr` cc `@rust-lang/project-const-generics`
2021-12-11fix typosurechen-1/+1
2021-12-10remove feature gate and cleanup codeEllen-9/+2
2021-12-09Remove redundant [..]sest31-1/+1
2021-12-04ast: Avoid aborts on fatal errors thrown from mutable AST visitorVadim Petrochenkov-12/+116
Set the node to some dummy value and rethwor the error instead.
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-1/+2
2021-11-28expand: Turn `ast::Crate` into a first class expansion targetVadim Petrochenkov-31/+15
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-0/+15
Fix #84946
2021-11-12Auto merge of #89316 - asquared31415:multiple-clobber-abi, r=Amanieubors-2/+2
Add support for specifying multiple clobber_abi in `asm!` r? `@Amanieu` cc #72016 `@rustbot` label: +A-inline-assembly +F-asm
2021-11-10Rollup merge of #90742 - est31:add_assign, r=davidtwcoMatthias Krüger-1/+1
Use AddAssign impl
2021-11-10Add support for specifying multiple clobber_abi in `asm!`asquared31415-2/+2
Allow multiple clobber_abi in asm Update docs Fix aarch64 test Combine abis Emit duplicate ABI error, empty ABI list error multiple clobber_abi
2021-11-09Use AddAssign implest31-1/+1
2021-11-08Rollup merge of #90657 - GuillaumeGomez:one-char-last-line-removed, r=jyn514Guillaume Gomez-1/+1
Fix bug with `#[doc]` string single-character last lines Fixes #90618. This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-64/+134
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-06Rollup merge of #90642 - matthiaskrgr:clippy_matches, r=cjgillotMatthias Krüger-4/+4
use matches!() macro in more places
2021-11-06Fix last doc code comment being removed if it only had one characterGuillaume Gomez-1/+1
2021-11-06Auto merge of #90559 - rusticstuff:optimize-bidi-detection, r=davidtwcobors-0/+37
Optimize bidi character detection. Should fix most of the performance regression of the bidi character detection (#90514), to be confirmed with a perf run.