Commit Graph

330 Commits

Author SHA1 Message Date
Vadim Petrochenkov
2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
Nicholas Nethercote
6b367a0532 Avoid producing NoDelim values in MacArgs::delim(). 2022-04-27 08:15:12 +10:00
bors
7417110cef Auto merge of #96246 - SparrowLii:bound_contxet, r=compiler-errors
Add `BoundKind` in `visit_param_bounds` to check questions in bounds

From the FIXME in the impl of `AstValidator`. Better bound checks by adding `BoundCtxt` type parameter to `visit_param_bound`

cc `@ecstatic-morse`
2022-04-25 10:46:58 +00:00
bors
b04c5329e1 Auto merge of #96210 - nnethercote:speed-up-TokenCursor, r=petrochenkov
Speed up `TokenCursor`

Plus a few related clean-ups.

r? `@petrochenkov`
2022-04-21 15:42:50 +00:00
Nicholas Nethercote
643e9f707e Introduced Cursor::next_with_spacing_ref.
This lets us clone just the parts within a `TokenTree` that need
cloning, rather than the entire thing. This is a surprisingly large
performance win, up to 4% on `async-std-1.10.0`.
2022-04-21 13:49:40 +10:00
SparrowLii
38bd4fbdbd rename to BoundKind and add comments 2022-04-21 10:09:32 +08:00
SparrowLii
4375b36117 Add BoundCtxt in visit_param_bounds to check questions in bounds 2022-04-20 19:06:32 +08:00
Nicholas Nethercote
5b653c1a43 Inline Cursor::next_with_spacing. 2022-04-20 12:43:25 +10:00
Vadim Petrochenkov
e2d3a4f631 rustc_metadata: Store a flag telling whether an item may have doc links in its attributes
This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily
2022-04-19 22:53:46 +03:00
Nicholas Nethercote
aefbbeec34 Inline and remove TokenTree::{open_tt,close_tt}.
They both have a single call site.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
ad566b78f2 Tweak Cursor::next_with_spacing.
This makes it more like `CursorRef::next_with_spacing`. There is no
performance effect, just a consistency improvement.
2022-04-19 17:02:48 +10:00
bors
1ec2c136b3 Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov
Report undeclared lifetimes during late resolution.

First step in https://github.com/rust-lang/rust/pull/91557

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
2022-04-17 12:56:19 +00:00
bors
af68f7182e Auto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillot
Remove last vestiges of skippng ident span hashing

This removes a comment that no longer applies, and properly hashes
the full ident for path segments.
2022-04-17 10:31:52 +00:00
Camille GILLOT
e47f66dc0d Visit generics inside visit_fn. 2022-04-17 11:03:33 +02:00
bors
080d5452e1 Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
2022-04-16 04:46:01 +00:00
Dylan DPC
20bf34f8c5
Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix
Create (unstable) 2024 edition

[On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition.

This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024.

For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical.

````@rustbot```` label +T-lang +S-waiting-on-review

Not sure on the relevant team, to be honest.
2022-04-15 20:50:43 +02:00
Amanieu d'Antras
dc345d8bff Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
Aaron Hill
002a4e1bd5
Remove last vestiges of skippng ident span hashing
This removes a comment that no longer applies, and properly hashes
the full ident for path segments.
2022-04-13 11:25:22 -04:00
Josh Stone
2d5eda8fb0 Use const Box::default in P::<[T]>::new 2022-04-11 12:14:18 -07:00
Michael Goulet
b65265b5e1 better error for binder on associated type bound 2022-04-10 16:41:15 -07:00
Guillaume Gomez
43d0497824 Fix invalid array access in beautify_doc_string 2022-04-08 15:30:37 +02:00
Nicholas Nethercote
d9592c2d9f Shrink Nonterminal.
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`.
This slightly reduces cumulative and peak allocation amounts, most
notably on `deep-vector`.
2022-04-07 12:51:50 +10:00
Jacob Pratt
6b75406f5a
Create 2024 edition 2022-04-02 02:45:49 -04:00
Dylan DPC
1b7d6dbd30
Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31 04:57:28 +02:00
Dylan DPC
86388f6171
Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay
Reduce max hash in raw strings from u16 to u8

[Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)
2022-03-31 00:26:31 +02:00
Yuri Astrakhan
5160f8f843 Spellchecking compiler comments
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30 15:14:15 -04:00
Nicholas Nethercote
364b908d57 Remove Nonterminal::NtTT.
It's only needed for macro expansion, not as a general element in the
AST. This commit removes it, adds `NtOrTt` for the parser and macro
expansion cases, and renames the variants in `NamedMatch` to better
match the new type.
2022-03-28 10:03:02 +11:00
Grisha Vartanyan
b51f20eaf5 Update syntax tree definition 2022-03-23 23:44:16 +01:00
bors
95561b336c Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber
More robust fallback for `use` suggestion

Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.

But this was fragile, as illustrated in issue #87613

This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.

Fix #87613
2022-03-15 03:56:33 +00:00
Caio
8073a88f35 Implement macro meta-variable expressions 2022-03-09 16:46:23 -03:00
Jack Huey
d16ec7b9d1 Ignore 2022-03-05 21:20:12 -05:00
Jack Huey
9dc05f3832 Add commment covering the case with no where clause 2022-03-05 13:15:00 -05:00
Jack Huey
2b151fd5c8 Review changes 2022-03-05 13:15:00 -05:00
Jack Huey
c20b4f5584 Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
Felix S. Klock II
d37da1e332 Adjusted diagnostic output so that if there is no use in a item sequence,
then we just suggest the first legal position where you could inject a use.

To do this, I added `inject_use_span` field to `ModSpans`, and populate it in
parser (it is the span of the first token found after inner attributes, if any).
Then I rewrote the use-suggestion code to utilize it, and threw out some stuff
that is now unnecessary with this in place. (I think the result is easier to
understand.)

Then I added a test of issue 87613.
2022-03-03 18:58:37 -05:00
Felix S. Klock II
b82795244e Associate multiple with a crate too. 2022-03-03 18:45:25 -05:00
Felix S. Klock II
e9035f7bef refactor: prepare to associate multiple spans with a module. 2022-03-03 14:38:50 -05:00
Caio
ef5601b321 2 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-02-26 13:45:43 -03:00
Dylan DPC
ec44d48ae3
Rollup merge of #94316 - nnethercote:improve-string-literal-unescaping, r=petrochenkov
Improve string literal unescaping

Some easy wins that affect a few popular crates.

r? ```@matklad```
2022-02-24 21:42:18 +01:00
Matthias Krüger
ae27c4ab1f
Rollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercote
Cleanup a few Decoder methods

This is just some simple follow up to #93839.

r? `@nnethercote`
2022-02-24 07:48:09 +01:00
Nicholas Nethercote
44308dc348 Inline a hot closure in from_lit_token.
The change looks big because `rustfmt` rearranges things, but the only
real change is the inlining annotation.
2022-02-24 17:07:49 +11:00
Matthias Krüger
0c676a8a84
Rollup merge of #94128 - mqy:master, r=Dylan-DPC
rustdoc: several minor fixes

``@rustbot`` label A-docs
2022-02-23 12:26:40 +01:00
Mark Rousskov
f1bcb0f3af Delete Decoder::read_unit 2022-02-22 18:14:51 -05:00
mqy
997492538b rustdoc: several minor fixes 2022-02-19 03:47:41 +08:00
Matthias Krüger
a144ea1c4b
Rollup merge of #93634 - matthiaskrgr:clippy_complexity_jan_2022, r=oli-obk
compiler: clippy::complexity fixes

useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
2022-02-18 16:23:33 +01:00
bors
0c3f0cddde Auto merge of #93752 - eholk:drop-tracking-break-continue, r=nikomatsakis
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-15 02:27:37 +00:00
Eric Holk
c37a906db5 Drop tracking: improve break and continue handling
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-07 16:30:30 -08:00
Guillaume Gomez
33cbf8908d Add test for block doc comments horizontal trim 2022-02-07 17:07:53 +01:00
Guillaume Gomez
e3942874a0 Fix horizontal trim for block doc comments 2022-02-07 16:50:45 +01:00
Matthias Krüger
b80057d08d compiler: clippy::complexity fixes
useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
2022-02-03 23:16:03 +01:00