about summary refs log tree commit diff
path: root/tests/ui/rust-2024
AgeCommit message (Collapse)AuthorLines
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-0/+2
2025-07-16future-incompat lints: don't link to the nightly edition-guide versiondianne-77/+77
2025-05-04Make attribute safety validation logic more obviousJieyou Xu-0/+43
2025-05-03Report the `unsafe_attr_outside_unsafe` lint at the closest nodeUrgau-0/+16
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-6/+6
2025-03-07fix rebaseEsteban Küber-2/+2
2025-03-07Refactor `emitter` to better account for unicode chars when trimmingEsteban Küber-1/+1
Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic.
2025-03-07On long spans, trim the middle of them to make them fit in the terminal widthEsteban Küber-2/+2
When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of #137680 (missing handling of the long suggestion). Fix #125581.
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-151/+0
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-5/+44
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-07Update tests.Mara Bos-10/+10
2024-12-21Properly record metavar spans for other expansions other than TTMichael Goulet-5/+44
2024-12-15Use links to edition guide for edition migrationsEric Huss-70/+71
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-1/+0
span rendering
2024-12-12Tweak multispan renderingEsteban Küber-2/+1
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-07Actually walk into lifetimes and attrs in EarlyContextAndPassMichael Goulet-5/+91
2024-11-28Update more 2024 tests to remove -Zunstable-optionsEric Huss-61/+40
2024-11-28Auto merge of #133540 - ehuss:compiletest-proc-macro, r=jieyouxubors-16/+5
Compiletest: add proc-macro header This adds a `proc-macro` header to simplify using proc-macros, and to reduce boilerplate. This header works similar to the `aux-build` header where you pass a path for a proc-macro to be built. This allows the `force-host`, `no-prefer-dynamic` headers, and `crate_type` attribute to be removed. Additionally it uses `--extern` like `aux_crate` (allows implicit `extern crate` in 2018) and `--extern proc_macro` (to place in the prelude in 2018). ~~This also includes a secondary change which defaults the edition of proc-macros to 2024. This further reduces boilerplate (removing `extern crate proc_macro;`), and allows using modern Rust syntax. I was a little on the fence including this. I personally prefer it, but I can imagine it might be confusing to others.~~ EDIT: Removed Some tests were changed so that when there is a chain of dependencies A→B→C, that the `@ proc-macro` is placed in `B` instead of `A` so that the `--extern` flag works correctly (previously it depended on `-L` to find `C`). I think this is better to make the dependencies more explicit. None of these tests looked like the were actually testing this behavior. There is one test that had an unexplained output change: `tests/ui/macros/same-sequence-span.rs`. I do not know why it changed, but it didn't look like it was particularly important. Perhaps there was a normalization issue? This is currently not compatible with the rustdoc `build-aux-docs` header. It can probably be fixed, I'm just not feeling motivated to do that right now. ### Implementation steps - [x] Document this new behavior in rustc-dev-guide once we figure out the specifics. https://github.com/rust-lang/rustc-dev-guide/pull/2149
2024-11-28Rollup merge of #133487 - pitaj:reserve-guarded-strings, r=fee1-deadGuillaume Gomez-97/+97
fix confusing diagnostic for reserved `##` Closes #131615
2024-11-27Update tests to use new proc-macro headerEric Huss-16/+5
2024-11-27Auto merge of #133274 - ehuss:macro_rules-edition-from-pm, r=compiler-errorsbors-0/+39
Use edition of `macro_rules` when compiling the macro This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition. This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions. This is partially related to https://github.com/rust-lang/rust/issues/132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.
2024-11-25fix confusing diagnostic for reserved `##`Peter Jaszkowiak-97/+97
2024-11-22Stabilize the 2024 editionEric Huss-25/+21
2024-11-20Use edition of `macro_rules` when compiling the macroEric Huss-19/+1
2024-11-20Add tests for the edition of macro_rules from a proc-macroEric Huss-0/+57
2024-10-11Remove unadornedMichael Goulet-14/+14
2024-10-08Reserve guarded string literals (RFC 3593)Peter Jaszkowiak-0/+1261
2024-09-17Store raw ident span for raw lifetimeMichael Goulet-0/+8
2024-09-06Lint against keyword lifetimes in keyword_identsMichael Goulet-2/+25
2024-08-17Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercotebors-14/+9
Stabilize `unsafe_attributes` # Stabilization report ## Summary This is a tracking issue for the RFC 3325: unsafe attributes We are stabilizing `#![feature(unsafe_attributes)]`, which makes certain attributes considered 'unsafe', meaning that they must be surrounded by an `unsafe(...)`, as in `#[unsafe(no_mangle)]`. RFC: rust-lang/rfcs#3325 Tracking issue: #123757 ## What is stabilized ### Summary of stabilization Certain attributes will now be designated as unsafe attributes, namely, `no_mangle`, `export_name`, and `link_section` (stable only), and these attributes will need to be called by surrounding them in `unsafe(...)` syntax. On editions prior to 2024, this is simply an edition lint, but it will become a hard error in 2024. This also works in `cfg_attr`, but `unsafe` is not allowed for any other attributes, including proc-macros ones. ```rust #[unsafe(no_mangle)] fn a() {} #[cfg_attr(any(), unsafe(export_name = "c"))] fn b() {} ``` For a table showing the attributes that were considered to be included in the list to require unsafe, and subsequent reasoning about why each such attribute was or was not included, see [this comment here](https://github.com/rust-lang/rust/pull/124214#issuecomment-2124753464) ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-attributes` and `tests/ui/attributes/unsafe`.
2024-08-14CommandExt::before_exec: deprecate safety in edition 2024Ralf Jung-0/+28
2024-08-13`#[deprecated_safe_2024]`: Also use the `// TODO:` hint in the compiler errorTobias Bucher-2/+2
This doesn't work for translated compiler error messages.
2024-08-13Allow to customize `// TODO:` comment for deprecated safe autofixTobias Bucher-2/+2
Relevant for the deprecation of `CommandExt::before_exit` in #125970.
2024-08-07Stabilize `unsafe_attributes`carbotaniuman-14/+9
2024-08-03Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, ↵Matthias Krüger-46/+64
r=compiler-errors Stabilize unsafe extern blocks (RFC 3484) # Stabilization report ## Summary This is a tracking issue for the RFC 3484: Unsafe Extern Blocks We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](https://github.com/rust-lang/rfcs/pull/3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use. RFC: https://github.com/rust-lang/rfcs/pull/3484 Tracking issue: #123743 ## What is stabilized ### Summary of stabilization We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results. ```rust unsafe extern { // sqrt (from libm) may be called with any `f64` pub safe fn sqrt(x: f64) -> f64; // strlen (from libc) requires a valid pointer, // so we mark it as being an unsafe fn pub unsafe fn strlen(p: *const c_char) -> usize; // this function doesn't say safe or unsafe, so it defaults to unsafe pub fn free(p: *mut core::ffi::c_void); pub safe static IMPORTANT_BYTES: [u8; 256]; pub safe static LINES: SyncUnsafeCell<i32>; } ``` ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`. ## History - https://github.com/rust-lang/rust/pull/124482 - https://github.com/rust-lang/rust/pull/124455 - https://github.com/rust-lang/rust/pull/125077 - https://github.com/rust-lang/rust/pull/125522 - https://github.com/rust-lang/rust/issues/126738 - https://github.com/rust-lang/rust/issues/126749 - https://github.com/rust-lang/rust/issues/126755 - https://github.com/rust-lang/rust/pull/126757 - https://github.com/rust-lang/rust/pull/126758 - https://github.com/rust-lang/rust/issues/126756 - https://github.com/rust-lang/rust/pull/126973 - https://github.com/rust-lang/rust/pull/127535 - https://github.com/rust-lang/rustfmt/pull/6204 ## Unresolved questions I am not aware of any unresolved questions.
2024-07-28Rollup merge of #125889 - Nilstrieb:migrate-into-the-future, r=compiler-errorsMatthias Krüger-0/+342
Add migration lint for 2024 prelude additions This adds the migration lint for the newly ambiguous methods `poll` and `into_future`. When these methods are used on types implementing the respective traits, it will be ambiguous in the future, which can lead to hard errors or behavior changes depending on the exact circumstances. tracked by #121042 <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> r? compiler-errors as the method prober
2024-07-28Add migration lint for 2024 prelude additionsNilstrieb-0/+342
This adds the migration lint for the newly ambiguous methods `poll` and `into_future`. When these methods are used on types implementing the respective traits, it will be ambiguous in the future, which can lead to hard errors or behavior changes depending on the exact circumstances.
2024-07-23Stabilize unsafe extern blocks (RFC 3484)Santiago Pastorino-46/+64
2024-07-22Rollup merge of #125990 - tbu-:pr_unsafe_env_lint_name, r=ehussTrevor Gross-4/+4
Rename `deprecated_safe` lint to `deprecated_safe_2024` Create a lint group `deprecated_safe` that includes `deprecated_safe_2024`. Addresses https://github.com/rust-lang/rust/issues/124866#issuecomment-2142814375. r? `@ehuss`
2024-07-18Don't allow unsafe statics outside of extern blocksMichael Goulet-2/+17
2024-07-17Rename `deprecated_safe` lint to `deprecated_safe_2024`Tobias Bucher-4/+4
Create a lint group `deprecated_safe` that includes `deprecated_safe_2024`. Addresses https://github.com/rust-lang/rust/issues/124866#issuecomment-2142814375.
2024-07-03Add parse fail test using safe trait/impl traitSantiago Pastorino-0/+47
2024-06-26Rollup merge of #126973 - ↵Matthias Krüger-12/+53
chenyukang:yukang-fix-126756-unsafe-suggestion-error, r=spastorino Fix bad replacement for unsafe extern block suggestion Fixes #126756 r? ``@spastorino`` link #123743
2024-06-26Fix bad replacement for unsafe extern block suggestionyukang-12/+53
2024-06-26Fix a span in `parse_ty_bare_fn`.Nicholas Nethercote-2/+2
It currently goes one token too far. Example: line 259 of `tests/ui/abi/compatibility.rs`: ``` test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32); ``` This commit changes the span for the second element from `fn(),` to `fn()`, i.e. removes the extraneous comma.
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-0/+282
2024-06-21Do not allow safe usafe on static and fn itemsSantiago Pastorino-0/+143
2024-06-12Add TODO comment to unsafe env modificationTobias Bucher-4/+8
Addresses https://github.com/rust-lang/rust/pull/124636#issuecomment-2132119534. I think that the diff display regresses a little, because it's no longer showing the `+` to show where the `unsafe {}` is added. I think it's still fine.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-0/+311
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fnsTobias Bucher-11/+77
Fixes #125875.