about summary refs log tree commit diff
path: root/src/test/ui/macros
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-16460/+0
2023-01-04Move testsCaio-0/+33
2023-01-04Rollup merge of #106361 - clubby789:int-literal-too-large, r=estebankMatthias Krüger-0/+2
Note maximum integer literal for `IntLiteralTooLarge` Closes #105908 `@rustbot` label +A-diagnostics
2023-01-02Print correct base for too-large literalsclubby789-0/+2
Also update tests
2023-01-02maybegimbles-7/+7
2023-01-01Verbose suggestionsEsteban Küber-2/+4
2022-12-29Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, ↵Matthias Krüger-1/+1
r=compiler-errors Rename `Rptr` to `Ref` in AST and HIR The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-28Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errorsMatthias Krüger-0/+32
Properly calculate best failure in macro matching Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream. We now try to properly use the location in the token stream. This needs a little cleanup as the `best_failure` field is getting out of hand but it should be mostly good to go. I hope I didn't violate too many abstraction boundaries..
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-1/+1
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-23Move testsCaio-0/+32
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-21/+4
available
2022-12-12Properly calculate best failure in macro matchingNilstrieb-0/+32
Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream. We now try to properly use the location in the token stream.
2022-12-11Move testsCaio-0/+91
2022-12-10Migrate parts of `rustc_expand` to session diagnosticsnils-3/+5
This migrates everything but the `mbe` and `proc_macro` modules. It also contains a few cleanups and drive-by/accidental diagnostic improvements which can be seen in the diff for the UI tests.
2022-12-06Rollup merge of #105098 - lyming2007:issue-103869-fix, r=eholkMatthias Krüger-0/+1
propagate the error from parsing enum variant to the parser and emit out While parsing enum variant, the error message always disappear Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case https://github.com/rust-lang/rust/issues/103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix https://github.com/rust-lang/rust/issues/103869
2022-12-03parser: fix ICE with invalid variable declaration in macro callYutaro Ohno-0/+52
Fix ICE on parsing an invalid variable declaration as a statement like: ``` macro_rules! m { ($s:stmt) => {} } m! { var x } ```
2022-12-01While parsing enum variant, the error message always disappearYiming Lei-0/+1
Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case #103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix #103869
2022-12-01Rollup merge of #105078 - TaKO8Ki:fix-105011, r=nnethercoteMatthias Krüger-0/+11
Fix `expr_to_spanned_string` ICE Fixes #105011
2022-11-30report literal errors when `token_lit` has errorsTakayuki Maeda-0/+11
2022-11-30Fix an ICE parsing a malformed literal in `concat_bytes!`.Nicholas Nethercote-0/+24
Fixes #104769.
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-1/+21
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-15Only do parser recovery on retried macro matchingNilstrieb-0/+31
This prevents issues with eager parser recovery during macro matching.
2022-11-14Show a note where a macro failed to matchNilstrieb-0/+167
This shows a small note on what the macro matcher was currently processing to aid with "no rules expected the token X" errors.
2022-11-13Ensure codegen_fn_attrs during collection.Camille GILLOT-1/+21
2022-11-03Move some tests from `src/test/ui` to more reasonable placesDeadbeef-0/+35
2022-10-31resolve: Turn the binding from `#[macro_export]` into a proper `Import`Vadim Petrochenkov-3/+24
2022-10-26Rollup merge of #95710 - ↵Dylan DPC-1/+1
fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett Stabilize arbitrary_enum_discriminant, take 2 Documentation has been updated in https://github.com/rust-lang/reference/pull/1055. cc #86860 for previous stabilization report. Not yet marks https://github.com/rust-lang/rust/issues/60553 as done: need documentation in the rust reference.
2022-10-25Pinning tests for some macro_rules things discussed in the lang meetingScott McMurray-0/+28
2022-10-22Stabilize arbitrary_enum_discriminant, take 2Deadbeef-1/+1
2022-10-16Account for hygiene when suggesting typos.Camille GILLOT-1/+1
2022-10-11Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwcoMatthias Krüger-0/+70
Fix ICE #102878 Fixes #102878
2022-10-11fix #102878Takayuki Maeda-0/+70
2022-10-08Stabilize half_open_range_patternsUrgau-1/+0
2022-10-05Delay function resolution error until typeckMichael Goulet-22/+22
2022-10-03Rollup merge of #101040 - ↵Matthias Krüger-1/+32
danielhenrymantilla:no-bounds-for-default-annotated-derive, r=joshtriplett Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds That is, given something like: ```rs // #[default] on a generic enum does not add `Default` bounds to the type params. #[derive(Default)] enum MyOption<T> { #[default] None, Some(T), } ``` then `MyOption<T> : Default`_as currently implemented_ only holds when `T : Default`, as reported by ```@5225225``` [over Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.23.5Bderive.28Default.29.5D.20for.20enums.20with.20fields). This is contrary to [what the accepted RFC proposes](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html#generated-bounds) (_i.e._, that `T` be allowed not to be itself `Default`), and indeed seems to be a rather unnecessary limitation.
2022-10-01bless ui testsMaybe Waffle-14/+14
2022-09-27Update tests.Mara Bos-141/+141
2022-09-27Rewrite and refactor format_args!() builtin macro.Mara Bos-1/+1
2022-09-23Restore ignore tagFlorian Bartels-1/+0
This test case actually requires std::process.
2022-09-22Rollup merge of #102033 - andrewpollack:add-unwind-on-pretty, r=tmandryYuki Okushi-0/+3
Adding needs-unwind to nicer-assert-messages compiler ui tests Tests where unwind is required for asserting on contents of error message cc. ``@djkoloski`` r? ``@tmandry``
2022-09-19Adding needs-unwind to nicer-assert-messages compiler ui testsAndrew Pollack-0/+3
2022-09-15Future-proof against loose bounds if default variant is non-exhaustive.Daniel Henry-Mantilla-1/+32
Co-Authored-By: Mark Rousskov <mark.simulacrum@gmail.com>
2022-09-13Emit an error instead of reconstructing token stream.Camille GILLOT-1/+8
2022-09-13Manually cleanup token stream when macro expansion aborts.Camille GILLOT-0/+41
2022-08-23Stabilize `#![feature(label_break_value)]`Joshua Nelson-1/+0
# Stabilization proposal The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now). There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`. There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed). 1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234 2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176 3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630 Many different examples of code that's simpler using this feature have been provided: - A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014 - A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize). - Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395 - Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733 - An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569 - Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006 Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249 nrc later resolved their concern, mostly because of the aforementioned macro problems. joshtriplett suggested that macros could be able to generate IR directly (https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs, and the design space seems rather speculative. joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804 withoutboats has regrettably left the language team. joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353 [issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+ ## Report + Feature gate: - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs + Diagnostics: - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629 - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749 - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001 - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254 - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079 - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569 + Tests: - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs ## Interactions with other features Labels follow the hygiene of local variables. label-break-value is permitted within `try` blocks: ```rust let _: Result<(), ()> = try { 'foo: { Err(())?; break 'foo; } }; ``` label-break-value is disallowed within closures, generators, and async blocks: ```rust 'a: { || break 'a //~^ ERROR use of unreachable label `'a` //~| ERROR `break` inside of a closure } ``` label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]: ```rust fn labeled_match() { match false 'b: { //~ ERROR block label not supported here _ => {} } } macro_rules! m { ($b:block) => { 'lab: $b; //~ ERROR cannot use a `block` macro fragment here unsafe $b; //~ ERROR cannot use a `block` macro fragment here |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here } } fn foo() { m!({}); } ``` [_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html [_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-17Reenable early feature-gates as future-compat warningsChristopher Durham-0/+7
2022-08-09Stringify non-shorthand visibility correctlyJacob Pratt-2/+3
2022-08-09Rollup merge of #100228 - luqmana:suggestion-ice, r=estebankDylan DPC-0/+49
Don't ICE while suggesting updating item path. When an item isn't found, we may suggest an appropriate import to `use`. Along with that, we also suggest updating the path to work with the `use`. Unfortunately, if the code in question originates from a macro, the span used to indicate which part of the path needs updating may not be suitable and cause an ICE (*). Since, such code is not adjustable directly by the user without modifying the macro, just skip the suggestion in such cases. (*) The ICE happens because the emitter want to indicate to the user what code to delete by referencing a certain span. But in this case, said span has `lo == hi == 0` which means it thinks it's a dummy span. Adding a space before the proc macro attribute is enough to stop it from ICE'ing but even then the suggestion doesn't really make any sense: ``` help: if you import `DataStore`, refer to it directly | 1 - #[dbstruct::dbstruct] 1 + #[dbstruct::dbstruct] ``` Since suggestions are best-effort, I just gated this one on `can_be_used_for_suggestions` which catches cases like this. Fixes #100199
2022-08-07Add UI test for #100199Luqman Aden-0/+49
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-0/+2