Commit Graph

79 Commits

Author SHA1 Message Date
Aaron Hill b9b2546417
Unconditionally capture tokens for attributes.
This allows us to avoid synthesizing tokens in `prepend_attr`, since we
have the original tokens available.

We still need to synthesize tokens when expanding `cfg_attr`,
but this is an unavoidable consequence of the syntax of `cfg_attr` -
the user does not supply the `#` and `[]` tokens that a `cfg_attr`
expands to.
2020-10-21 18:57:29 -04:00
Mara Bos 0f193d1a62 Small cleanups in assert!() and panic_fmt lint.
(From the PR feedback.)

Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-10-19 21:14:05 +02:00
Mara Bos 3beb2e95a9 Expand assert!(expr) to panic() function instead of panic!() macro.
The panic message might contain braces which should never be
interpreted as format placeholders, which panic!() will do in a future
edition.
2020-10-18 22:30:16 +02:00
est31 4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
Yuki Okushi e40ae080ac
Rollup merge of #77831 - LingMan:use_std, r=jonas-schievink
Use std methods on char instead of open coding them
2020-10-13 04:08:03 +09:00
LingMan a56b0e96d0 Simplify using is_ascii_alphabetic and is_ascii_alphanumeric 2020-10-11 22:27:21 +02:00
LingMan e533bb73bc Don't duplicate char::is_ascii_digit 2020-10-11 22:27:20 +02:00
Tomasz Miąsko 50da126557 Remove unnecessary unsafe block around calls to discriminant_value
Since 63793 the discriminant_value intrinsic is safe to call. Remove
unnecessary unsafe block around calls to this intrinsic in built-in
derive macros.
2020-10-11 00:00:00 +00:00
bors a14bf4862d Auto merge of #77595 - petrochenkov:asmident, r=oli-obk
builtin_macros: Fix use of interpolated identifiers in `asm!`

Fixes https://github.com/rust-lang/rust/issues/77584
2020-10-07 11:51:51 +00:00
Vadim Petrochenkov 219c66c55c rustc_parse: Make `Parser::unexpected` public and use it in built-in macros 2020-10-06 00:23:36 +03:00
Vadim Petrochenkov 299136b9c7 builtin_macros: Fix use of interpolated identifiers in `asm!` 2020-10-06 00:18:03 +03:00
Robin Schoonover 5ab19676ed Remove extra indirection in LitKind::ByteStr 2020-10-04 15:52:15 -06:00
Vadim Petrochenkov 85ef265dbe expand: Stop un-interpolating `NtIdent`s before passing them to built-in macros
This was a big hack, and built-in macros should be able to deal with `NtIdents` in the input by themselves like any other parser code.
2020-09-28 23:10:44 +03:00
bors 6f9a8a7f9b Auto merge of #76485 - estebank:format_arg_capture_spans, r=davidtwco
Point at named argument not found when using `format_args_capture` instead of whole format string
2020-09-26 10:05:49 +00:00
Jonas Schievink 6f3da3d53f
Rollup merge of #77121 - duckymirror:html-root-url, r=jyn514
Updated html_root_url for compiler crates

Closes #77103

r? @jyn514
2020-09-25 02:29:45 +02:00
Erik Hofmayer 138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
LingMan d76b80768c
Merge two almost identical match arms 2020-09-23 01:09:24 +02:00
Matthias Krüger 40dddd3305 use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
Aaron Hill 156ef2bee8
Attach tokens to `ast::Stmt`
We currently only attach tokens when parsing a `:stmt` matcher for a
`macro_rules!` macro. Proc-macro attributes on statements are still
unstable, and need additional work.
2020-09-10 17:33:06 -04:00
Aaron Hill c1011165e6
Attach `TokenStream` to `ast::Visibility`
A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill 3815e91ccd
Attach tokens to `NtMeta` (`ast::AttrItem`)
An `AttrItem` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill 1823dea7df
Attach `TokenStream` to `ast::Ty`
A `Ty` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:05 -04:00
Aaron Hill de4bd9f0f8
Attach `TokenStream` to `ast::Block`
A `Block` does not have outer attributes, so we only capture tokens when
parsing a `macro_rules!` matcher
2020-09-10 17:33:05 -04:00
Matthias Krüger 9bb10cc907 use push(char) instead of push_str(&str) to add single chars to strings
clippy::single-char-push-str
2020-09-10 13:58:41 +02:00
Esteban Küber 2ac89ff994 Point at named argument not found when using `format_args_capture` instead of whole format string 2020-09-08 10:10:45 -07:00
Sasha 3524c3ef43 Improve recovery on malformed format call
If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.
2020-09-02 13:18:19 +02:00
Sasha f6d18db402 Use string literal directly when available in format
Previous implementation used the `Parser::parse_expr` function in order
to extract the format expression. If the first comma following the
format expression was mistakenly replaced with a dot, then the next
format expression was eaten by the function, because it looked as a
syntactically valid expression, which resulted in incorrectly spanned
error messages.

The way the format expression is exctracted is changed: we first look at
the first available token in the first argument supplied to the
`format!` macro call. If it is a string literal, then it is promoted as
a format expression immediatly, otherwise we fall back to the original
`parse_expr`-related method.

This allows us to ensure that the parser won't consume too much tokens
when a typo is made.

A test has been created so that it is ensured that the issue is properly
fixed.
2020-08-30 22:09:58 +02:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00