Commit graph

223 commits

Author SHA1 Message Date
bors
03360be6b7 Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisa
Support [x; n] expressions in concat_bytes!

Currently trying to use `concat_bytes!` with a repeating array value like `[42; 5]` results in an error:
```
error: expected a byte literal
 --> src/main.rs:3:27
  |
3 |     let x = concat_bytes!([3; 4]);
  |                           ^^^^^^
  |
  = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()`
```

This makes it so repeating array syntax can be used the same way normal arrays can be. The RFC doesn't explicitly mention repeat expressions, but it seems reasonable to allow them as well, since normal arrays are allowed.

It is possible to make the compiler get stuck compiling forever with `concat_bytes!([3; 999999999])`, but I don't think that's much of an issue since you can do that already with `const X: [u8; 999999999] = [3; 999999999];`.

Contributes to #87555.
2022-01-02 12:38:41 +00:00
David Renshaw
4a7f276cb6 update tests 2021-12-31 12:51:27 -05:00
David Renshaw
a661671ae3 [rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape 2021-12-31 12:42:15 -05:00
Smitty
9702348957 Clarify that repeat count must be positive 2021-12-27 12:31:40 -05:00
Caleb Cartwright
63c2edefda rustc_builtin_macros: make asm mod public for rustfmt 2021-12-21 11:52:40 -06:00
bors
a41a6925ba Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
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-19 09:31:37 +00:00
Smitty
31731511c0 Support [x; n] expressions in concat_bytes!
Contributes to #87555.
2021-12-18 08:50:01 -05:00
Matthias Krüger
fd445ddf96
Rollup merge of #92016 - calebcartwright:expose-asm-args-parsing, r=Amanieu
builtin_macros: allow external consumers for AsmArgs parsing

As discussed in Zulip (https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/parsing.20of.20AsmArgs.20for.20inline.20assembly), we need a function entry point that rustfmt can leverage from a pre-expansion context to get a more structured representation of the asm args without having to duplicate/maintain the token stream parsing

r? ```@Amanieu``` and/or ```@joshtriplett```
2021-12-18 08:16:31 +01:00
Caleb Cartwright
78a8e0092f builtin_macros: allow external consumers for AsmArgs parsing 2021-12-16 18:40:38 -06:00
Matthias Krüger
7407c4e37d
Rollup merge of #91172 - Ethiraric:ethiraric/fix90979, r=petrochenkov
Warn when a `#[test]`-like built-in attribute macro is present multiple times.

Fixes #90979.
2021-12-16 17:23:07 +01:00
Ethiraric
2be94d4301 Add a lint for duplicated attributes. 2021-12-15 23:43:13 +01:00
Nicholas Nethercote
056d48a2c9 Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
Matthias Krüger
4e7497bda0
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15 01:28:08 +01:00
PFPoitras
304ede6bcc Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
Amanieu d'Antras
b3a55371a7 Remove automatic rustfix of asm! to llvm_asm!
This no longer works now that asm! needs an explicit import. Also, it's
been over a year since asm! landed, everyone should have transitioned by
now.
2021-12-12 11:20:03 +00:00
Matthias Krüger
40988591ec
Rollup merge of #91625 - est31:remove_indexes, r=oli-obk
Remove redundant [..]s
2021-12-10 22:40:36 +01:00
Matthias Krüger
6cfe9af6a0
Rollup merge of #91575 - compiler-errors:issue-91556, r=cjgillot
Fix ICE on format string of macro with secondary-label

This generalizes the fix #86104 to also correctly skip `Span::from_inner` for the `secondary_label` of a format macro parsing error as well.

We can alternatively skip the `span_label` diagnostic call for the secondary label as well, since that label probably only makes sense when the _proper_ span is computed.

Fixes #91556
2021-12-10 22:40:35 +01:00
Michael Goulet
99bd24e9a3 Fix span calculation on secondary_label as well 2021-12-09 09:09:39 -08:00
est31
15de4cbc4b Remove redundant [..]s 2021-12-09 00:01:29 +01:00
Smitty
eb56693a37 Implement concat_bytes!
The tracking issue for this is #87555.
2021-12-06 21:05:13 -05:00
Matthias Krüger
0311cfa88c
Rollup merge of #90519 - estebank:issue-84003, r=petrochenkov
Keep spans for generics in `#[derive(_)]` desugaring

Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-04 10:42:20 +01:00
Amanieu d'Antras
940b2eabad Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
Esteban Kuber
962b2197a5 Annotate derived spans and move span suggestion code
* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
  at the users' code
2021-12-03 18:41:40 +00:00
Esteban Kuber
8bee2b88c0 Remove some unnecessarily verbose code 2021-12-03 18:41:39 +00:00
Esteban Kuber
e70105f971 Keep spans for generics in #[derive(_)] desugaring
Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-03 18:41:39 +00:00
Matthias Krüger
519a842c50
Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011
expand: Turn `ast::Crate` into a first class expansion target

And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).

I haven't added token collection support for the whole crate in this PR, maybe later.
r? `@Aaron1011`
2021-12-01 20:57:43 +01:00
bors
2446a21595 Auto merge of #91324 - eggyal:avoid-uneccesary-clone-of-annotatable, r=Aaron1011
Avoid uneccessary clone of Annotatable

Addresses FIXME comment created in #82608

r? `@Aaron1011`
2021-12-01 06:18:39 +00:00
Matthias Krüger
7df49eff10
Rollup merge of #91327 - dtolnay:exact, r=michaelwoerister
Delete an unreachable codepath from format_args implementation
2021-11-29 10:41:36 +01:00
Matthias Krüger
9715724006
Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillot
Fix a format_args span to be expansion

I found this while exploring solutions for rust-lang/rust-clippy#7843.

r? `@m-ou-se`
2021-11-28 23:45:15 +01:00
David Tolnay
cc53f1356d
Delete an unreachable codepath from format_args implementation 2021-11-28 11:52:38 -08:00
Alan Egerton
d05e4d2c9b
Avoid uneccessary clone of Annotatable 2021-11-28 18:41:04 +00:00
Vadim Petrochenkov
141c6cc78e expand: Turn ast::Crate into a first class expansion target
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-28 15:48:55 +08:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
asquared31415
b233d3b5da Add support for specifying multiple clobber_abi in asm!
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-10 01:06:03 -05:00
bors
60952bc3da Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-se
Don't destructure args tuple in format_args!

This allows Clippy to parse the HIR more simply since `arg0` is changed to `_args.0`. (cc rust-lang/rust-clippy#7843). From rustc's perspective, I think this is something between a lateral move and a tiny improvement since there are fewer bindings.

r? `@m-ou-se`
2021-11-09 05:33:16 +00:00
bors
46b8e7488e Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514
more clippy fixes
2021-11-07 20:04:54 +00:00
Matthias Krüger
5c454551da more clippy fixes 2021-11-07 16:59:05 +01:00
Vadim Petrochenkov
2834f57c45 ast: Fix naming conventions in AST structures
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-07 21:38:17 +08:00
Cameron Steffen
9f6a58e86b Factor out some Vecs 2021-11-06 14:28:08 -05:00
Cameron Steffen
a9a24d5106 Don't destructure args tuple in format_args! 2021-11-06 14:28:08 -05:00
Cameron Steffen
4cfb7add77 Fix a format_args span to be expansion 2021-10-29 17:13:15 -05:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Vadim Petrochenkov
a6808335d4 rustc_span: Ident::invalid -> Ident::empty
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-17 23:20:30 +03:00
lcnr
00e5abe9b6 allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
Guillaume Gomez
836597a881
Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514
clippy::complexity fixes
2021-10-08 22:30:40 +02:00
Matthias Krüger
e6f77a1787 clippy::complexity fixes 2021-10-08 20:07:44 +02:00
Mara Bos
afe5335b97 Use correct edition for panic in [debug_]assert!() etc. 2021-10-07 14:27:08 +02:00
Hirochika Matsumoto
3818981ca1 Practice diagnostic message convention 2021-10-03 16:16:28 +09:00
bors
f03eb6bef8 Auto merge of #89341 - audunhalland:derive-type-params-with-bound-generic-params, r=jackh726
Deriving: Include bound generic params in type parameters for where clause

Fixes #89188.

The `derive` macro ignored the `for<'s>` needed with the `Fn` trait in that code example.

edit: I'm unsure if this might cause regressions. I'm not an experienced compiler developer so I'm not used to thinking about unwanted side effects code changes like this might have.
2021-10-02 18:46:27 +00:00