summary refs log tree commit diff
path: root/tests/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
2023-10-25Work around the fact that `check_mod_type_wf` may spuriously return ↵Oli Scherer-2/+30
`ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types`
2023-10-12Add a comment to `tests/ui/proc-macro/issue-75930-derive-cfg.rs`.Nicholas Nethercote-386/+416
Explaining something in the output that surprised me.
2023-10-05Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, ↵Matthias Krüger-0/+22
r=compiler-errors,estebank Add a note to duplicate diagnostics Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-0/+22
2023-10-04Point to where missing return type should goMichael Goulet-6/+6
2023-09-26Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, ↵bors-0/+149
r=compiler-errors Properly print cstr literals in `proc_macro::Literal::to_string` Previously we printed the contents of the string, rather than the actual string literal (e.g. `the c string` instead of `c"the c string"`). Fixes #112820 cc #105723
2023-09-24Add a test for printing literals via `proc-macro`Maybe Waffle-0/+149
2023-09-23implement Literal::byte_characterEmil Gardström-0/+5
without this, the only way to create a `LitKind::Byte` is by doing `"b'a'".parse::<Literal>()`, this solves that by enabling `Literal::byte_character(b'a')`
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+6
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-1/+1
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-08-09Rollup merge of #111891 - rustbox:feat/riscv-isr-cconv, r=jackh726Matthias Krüger-11/+17
feat: `riscv-interrupt-{m,s}` calling conventions Similar to prior support added for the mips430, avr, and x86 targets this change implements the rough equivalent of clang's [`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling e.g. ```rust static mut CNT: usize = 0; pub extern "riscv-interrupt-m" fn isr_m() { unsafe { CNT += 1; } } ``` to produce highly effective assembly like: ```asm pub extern "riscv-interrupt-m" fn isr_m() { 420003a0: 1141 addi sp,sp,-16 unsafe { CNT += 1; 420003a2: c62a sw a0,12(sp) 420003a4: c42e sw a1,8(sp) 420003a6: 3fc80537 lui a0,0x3fc80 420003aa: 63c52583 lw a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0> 420003ae: 0585 addi a1,a1,1 420003b0: 62b52e23 sw a1,1596(a0) } } 420003b4: 4532 lw a0,12(sp) 420003b6: 45a2 lw a1,8(sp) 420003b8: 0141 addi sp,sp,16 420003ba: 30200073 mret ``` (disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`) This outcome is superior to hand-coded interrupt routines which, lacking visibility into any non-assembly body of the interrupt handler, have to be very conservative and save the [entire CPU state to the stack frame][full-frame-save]. By instead asking LLVM to only save the registers that it uses, we defer the decision to the tool with the best context: it can more accurately account for the cost of spills if it knows that every additional register used is already at the cost of an implicit spill. At the LLVM level, this is apparently [implemented by] marking every register as "[callee-save]," matching the semantics of an interrupt handler nicely (it has to leave the CPU state just as it found it after its `{m|s}ret`). This approach is not suitable for every interrupt handler, as it makes no attempt to e.g. save the state in a user-accessible stack frame. For a full discussion of those challenges and tradeoffs, please refer to [the interrupt calling conventions RFC][rfc]. Inside rustc, this implementation differs from prior art because LLVM does not expose the "all-saved" function flavor as a calling convention directly, instead preferring to use an attribute that allows for differentiating between "machine-mode" and "superivsor-mode" interrupts. Finally, some effort has been made to guide those who may not yet be aware of the differences between machine-mode and supervisor-mode interrupts as to why no `riscv-interrupt` calling convention is exposed through rustc, and similarly for why `riscv-interrupt-u` makes no appearance (as it would complicate future LLVM upgrades). [clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v [full-frame-save]: https://github.com/esp-rs/esp-riscv-rt/blob/9281af2ecffe13e40992917316f36920c26acaf3/src/lib.rs#L440-L469 [implemented by]: https://github.com/llvm/llvm-project/blob/b7fb2a3fec7c187d58a6d338ab512d9173bca987/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp#L61-L67 [callee-save]: https://github.com/llvm/llvm-project/blob/973f1fe7a8591c7af148e573491ab68cc15b6ecf/llvm/lib/Target/RISCV/RISCVCallingConv.td#L30-L37 [rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-08fix(test): improve sensitivity of hygene testsSeth Pellegrino-11/+17
The change in 07f855d7817aa53af8adbb385407f6c2cacc2702 introduced a trailing numeral of some kind after the `extern crate compiler_builtins`, which appears to have caused at least two false negatives (654b924 and 657fd24). Instead, this change normalizes the test output to ignore the number (of symbols rustc recognizes?) to avoid needing to re-`--bless` these two tests for unrelated changes.
2023-08-09Auto merge of #114470 - ↵bors-0/+33
pnkfelix:dont-export-no-mangle-from-proc-macros-issue-99978, r=bjorn3 Restrict linker version script of proc-macro crates to just its two symbols Restrict linker version script of proc-macro crates to just the two symbols of each proc-macro crate. The main known effect of doing this is to stop including `#[no_mangle]` symbols in the linker version script. Background: The combination of a proc-macro crate with an import of another crate that itself exports a no_mangle function was broken for a period of time, because: * In PR #99944 we stopped exporting no_mangle symbols from proc-macro crates; proc-macro crates have a very limited interface and are meant to be treated as a blackbox to everything except rustc itself. However: he constructed linker version script still referred to them, but resolving that discrepancy was left as a FIXME in the code, tagged with issue #99978. * In PR #108017 we started telling the linker to check (via the`--no-undefined-version` linker invocation flag) that every symbol referenced in the "linker version script" is provided as linker input. So the unresolved discrepancy from #99978 started surfacing as a compile-time error (e.g. #111888). Fix #111888 Fix #99978.
2023-08-08fix proc-macro test added here to solely be exercised as a build product for ↵Felix S. Klock II-0/+4
the host. thus we should no longer see test failures for e.g. wasm32 target.
2023-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-2/+2
2023-08-04Auto merge of #112117 - bryangarza:track-caller-feature-gate, r=compiler-errorsbors-2/+2
Add separate feature gate for async fn track caller This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-08-04Update tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs Felix S Klock II-1/+1
fix to test as proposed by wesleywiser Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2023-08-04regression test for issue 111888.Felix S. Klock II-0/+29
2023-08-02Add separate feature gate for async fn track callerBryan Garza-2/+2
This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-1/+1
2023-08-02Fix #107113, avoid suggest for macro attributesyukang-0/+37
2023-07-29Change default panic handler message format.Mara Bos-1/+2
2023-07-29Rollup merge of #114124 - Enselic:proc-fixme, r=cjgillotMatthias Krüger-8/+8
tests/ui/proc-macro/*: Migrate FIXMEs to check-pass proc-macros are processed early in the compiler pipeline. There is no need to involve codegen. So change to check-pass. I have also looked through each changed test and to me it is sufficiently clear that codegen is not needed for the purpose of the test. I skipped changing `tests/ui/proc-macro/no-missing-docs.rs` in this commit because it was not clear to me that it can be changed to check-pass. Part of #62277
2023-07-27tests/ui/proc-macro/*: Migrate FIXMEs to check-passMartin Nordholts-8/+8
proc-macros are processed early in the compiler pipeline. There is no need to involve codegen. So change to check-pass. I have also looked through each changed test and to me it is sufficiently clear that codegen is not needed for the purpose of the test. I skipped changing tests/ui/proc-macro/no-missing-docs.rs in this commit because it was not clear to me that it can be changed to check-pass.
2023-07-25Add `sym::iter_mut` + `sym::as_mut_ptr`blyxyas-2/+2
2023-07-14Hide `compiler_builtins` in the preludeAmanieu d'Antras-335/+329
This crate is a private implementation detail. We only need to insert it into the crate graph for linking and should not expose any of its public API. Fixes #113533
2023-06-29resolve: Remove artificial import ambiguity errorsVadim Petrochenkov-21/+2
2023-06-28Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-seDylan DPC-14/+4
Implement proposed API for `proc_macro_span` As proposed in [#54725 (comment)](https://github.com/rust-lang/rust/issues/54725#issuecomment-1546918161). I have omitted the byte-level API as it's already available as [`Span::byte_range`](https://doc.rust-lang.org/nightly/proc_macro/struct.Span.html#method.byte_range). `@rustbot` label +A-proc-macros r? `@m-ou-se`
2023-06-27Rollup merge of #112454 - ferrocene:pa-compiletest-dynamic-linking, r=davidtwcoMatthias Krüger-0/+1
Make compiletest aware of targets without dynamic linking Some parts of the compiletest internals and some tests require dynamic linking to work, which is not supported by all targets. Before this PR, this was handled by if branches matching on the target name. This PR loads whether a target supports dynamic linking or not from the target spec, and adds a `// needs-dynamic-linking` attribute for tests that require it. Note that I was not able to replace all the old conditions based on the target name, as some targets have `dynamic_linking: true` in their spec but pretend they don't have it in compiletest. Also, to get this to work I had to *partially* revert #111472 (cc `@djkoloski` `@tmandry` `@bjorn3).` On one hand, only the target spec contains whether a target supports dynamic linking, but on the other hand a subset of the fields can be overridden through `-C` flags (as far as I'm aware only `-C panic=$strategy`). The solution I came up with is to take the target spec as the base, and then override the panic strategy based on `--print=cfg`. Hopefully that should not break y'all again.
2023-06-22Tweak privacy errors to account for reachable itemsEsteban Küber-2/+2
Suggest publicly accessible paths for items in private mod: When encountering a path in non-import situations that are not reachable due to privacy constraints, search for any public re-exports that the user could use instead. Track whether an import suggestion is offering a re-export. When encountering a path with private segments, mention if the item at the final path segment is not publicly accessible at all. Add item visibility metadata to privacy errors from imports: On unreachable imports, record the item that was being imported in order to suggest publicly available re-exports or to be explicit that the item is not available publicly from any path. In order to allow this, we add a mode to `resolve_path` that will not add new privacy errors, nor return early if it encounters one. This way we can get the `Res` corresponding to the final item in the import, which is used in the privacy error machinery.
2023-06-20Merge proc_macro_span_shrink and proc_macro_spanJacob Pratt-1/+1
2023-06-20Fix testsJacob Pratt-15/+5
2023-06-20add support for needs-dynamic-linkingPietro Albini-0/+1
2023-06-10Auto merge of #112452 - MU001999:fix/issue-112439, r=petrochenkovbors-4/+8
Make "consider importing" consistent for macros Fixes #112439
2023-06-10Make "consider importing" consistent for macrosMu001999-4/+8
2023-06-05Don't mention already set fieldsMichael Goulet-1/+1
2023-04-24Rollup merge of #110255 - clubby789:proc-macro-test-help, r=jackh726Matthias Krüger-0/+26
Suggest using integration tests for test crate using own proc-macro cc #110247
2023-04-17Suggest using integration tests for proc-macrosclubby789-0/+26
2023-04-15Add some reasons why tests are ignored.Eric Huss-6/+6
2023-04-12Special-case item attributes in the suggestion outputEsteban Küber-4/+0
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-4/+8
2023-04-12Rollup merge of #110153 - DaniPopes:compiler-typos, r=NilstriebMatthias Krüger-4/+4
Fix typos in compiler I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory. Refs #110150
2023-04-10Auto merge of #109638 - NotStirred:suggest/non-derive, r=davidtwcobors-0/+16
Add suggestion to remove `derive()` if invoked macro is non-derive Adds to the existing `expected derive macro, found {}` error message: ``` help: remove the surrounding "derive()": --> $DIR/macro-path-prelude-fail-4.rs:1:3 | LL | #[derive(inline)] | ^^^^^^^ ^ ``` This suggestion will either fix the issue, in the case that the macro was valid, or provide a better error message if not Not ready for merge yet, as the highlighted span is only valid for trivial formatting. Is there a nice way to get the parent span of the macro path within `smart_resolve_macro_path`? Closes #109589
2023-04-10Fix typos in compilerDaniPopes-4/+4
2023-04-07Rewrite added diagnostics as translatableTom Martin-4/+4
Start messages with lowercase
2023-04-03remove invalid ignore-prettyPietro Albini-1/+0
2023-04-01BlessTom Martin-8/+12
2023-03-30Update non-derive macro error message to match suggestionTom Martin-12/+12
It's now split between two errors, one to remove the invalid derive macro and one suggesting adding a new non-derive macro
2023-03-26Add suggestion to remove derive() if invoked macro is non-deriveTom Martin-0/+12
2023-03-14Tighter spansMichael Goulet-18/+18