summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2022-02-12ignore test on wasm32The 8472-0/+1
A fix applied to std::Path::hash triggers a miscompilation/assert in LLVM in this test on wasm32. The miscompilation appears to pre-existing. Reverting some previous changes done std::Path also trigger it and slight modifications such as changing the test path from "a" to "ccccccccccc" also make it pass, indicating it's very flaky. Since the fix is for a higher-tier platform than wasm it takes precedence.
2022-02-11Take in account the unreachable! macro in the non_fmt_panic lintLoïc BRANSTETT-30/+137
2022-02-11Fix invalid special casing of the unreachable! macroLoïc BRANSTETT-8/+45
2022-02-11resolve lifetimes for const generic defaultsMichael Goulet-0/+36
2022-02-11Remove obsolete no-op #[main] attribute from compiler.Jeremy Banks-0/+35
2022-02-09Rollup merge of #93394 - m-ou-se:fix-93378, r=estebankMara Bos-0/+41
Don't allow {} to refer to implicit captures in format_args. Fixes #93378
2022-02-09Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-seMatthias Krüger-0/+36
Add links to the reference and rust by example for asm! docs and lints These were previously removed in #91728 due to broken links. cc ``@ehuss`` since this updates the rust-by-example submodule
2022-01-31Revert -Zbranch-protectionSimonas Kazlauskas-3/+0
This reverts commit d331cb710f0dd969d779510a49a3bafc7f78a54e, reversing changes made to 78fd0f633faaa5b6dd254fc1456735f63a1b1238. This is a fix for #92885 as discussed on Zulip[1]. [1] https://zulip-archive.rust-lang.org/stream/238009-t-compiler/meetings/topic/.5Bweekly.5D.202022-01-27.20.2354818.html#269588396
2022-01-06Rollup merge of #92417 - dtolnay:printimpl, r=jackh726Matthias Krüger-1/+7
Fix spacing and ordering of words in pretty printed Impl Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{}", repro!(impl<T> Struct<T> {})); println!("{}", repro!(impl<T> const Trait for T {})); } ``` Before:&ensp;`impl <T> Struct<T> {}` After:&ensp;`impl<T> Struct<T> {}` Before:&ensp;`impl const <T> Trait for T {}` :crying_cat_face: After:&ensp;`impl<T> const Trait for T {}`
2022-01-06Rollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726Matthias Krüger-0/+82
Delay remaining `span_bug`s in drop elaboration This follows changes from #67967 and converts remaining `span_bug`s into delayed bugs, since for const items drop elaboration might be executed on a MIR which failed borrowck. Fixes #81708. Fixes #91816.
2022-01-06Rollup merge of #92389 - chordtoll:test-92015, r=Mark-SimulacrumMatthias Krüger-0/+18
Regression test for borrowck ICE #92015 This issue has come up a few times. Creating a regression test. Closes #92015.
2022-01-06Rollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwcoMatthias Krüger-0/+14
Some cleanups around check_argument_types Split out in ways from my rebase/continuation of #71827 Commits are mostly self-explanatory and these changes should be fairly straightforward
2022-01-05Rollup merge of #92575 - petrochenkov:cratenodeid, r=Aaron1011Matthias Krüger-2/+2
ast: Always keep a `NodeId` in `ast::Crate` This makes it more uniform with other expanded nodes. It makes generic code in https://github.com/rust-lang/rust/pull/92573 simpler in particular. This is another follow-up to https://github.com/rust-lang/rust/pull/91313. r? `@Aaron1011`
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-2/+2
This makes it more uniform with other expanded nodes
2022-01-05Auto merge of #92498 - camelid:ignore-flaky-test, r=Mark-Simulacrumbors-0/+4
Ignore flaky `panic-short-backtrace-windows-x86_64.rs` test for now Mitigates (but does not fix) #92000. It has been causing a lot of spurious test failures recently that slow down the bors queue.
2022-01-04Ignore flaky `panic-short-backtrace-windows-x86_64.rs` test for nowNoah Lev-0/+4
It has been causing a lot of spurious test failures recently that slow down the bors queue.
2022-01-04Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgrbors-18/+79
Rollup of 7 pull requests Successful merges: - #91587 (core::ops::unsize: improve docs for DispatchFromDyn) - #91907 (Allow `_` as the length of array types and repeat expressions) - #92515 (RustWrapper: adapt for an LLVM API change) - #92516 (Do not use deprecated -Zsymbol-mangling-version in bootstrap) - #92530 (Move `contains` method of Option and Result lower in docs) - #92546 (Update books) - #92551 (rename StackPopClean::None to Root) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-04Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwUMatthias Krüger-18/+79
Allow `_` as the length of array types and repeat expressions r? `@BoxyUwU` cc `@varkor`
2022-01-04Rollup merge of #92507 - chordtoll:suggest-single-quotes, r=petrochenkovMatthias Krüger-0/+105
Suggest single quotes when char expected, str provided If a type mismatch occurs where a char is expected and a string literal is provided, suggest changing the double quotes to single quotes. We already provide this suggestion in the other direction ( ' -> " ). Especially useful for new rust devs used to a language in which single/double quotes are interchangeable. Fixes #92479.
2022-01-03Suggest changing quotes when str/char type mismatchchordtoll-0/+105
2022-01-03Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplettMatthias Krüger-14/+10
Consolidate Result's and Option's methods into fewer impl blocks `Result`'s and `Option`'s methods have historically been separated up into `impl` blocks based on their trait bounds, with the bounds specified on type parameters of the impl block. I find this unhelpful because closely related methods, like `unwrap_or` and `unwrap_or_default`, end up disproportionately far apart in source code and rustdocs: <pre> impl&lt;T&gt; Option&lt;T&gt; { pub fn unwrap_or(self, default: T) -&gt; T { ... } <img alt="one eternity later" src="https://user-images.githubusercontent.com/1940490/147780325-ad4e01a4-c971-436e-bdf4-e755f2d35f15.jpg" width="750"> } impl&lt;T: Default&gt; Option&lt;T&gt; { pub fn unwrap_or_default(self) -&gt; T { ... } } </pre> I'd prefer for method to be in as few impl blocks as possible, with the most logical grouping within each impl block. Any bounds needed can be written as `where` clauses on the method instead: ```rust impl<T> Option<T> { pub fn unwrap_or(self, default: T) -> T { ... } pub fn unwrap_or_default(self) -> T where T: Default, { ... } } ``` *Warning: the end-to-end diff of this PR is computed confusingly by git / rendered confusingly by GitHub; it's practically impossible to review that way. I've broken the PR into commits that move small groups of methods for which git behaves better &mdash; these each should be easily individually reviewable.*
2022-01-03Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoeristerMatthias Krüger-4/+4
Fix spacing in pretty printed PatKind::Struct with no fields Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($pat:pat) => { stringify!($pat) }; } fn main() { println!("{}", repro!(Struct {})); } ``` Before:&ensp;<code>Struct&nbsp;{&nbsp;&nbsp;}</code> After:&ensp;<code>Struct&nbsp;{}</code>
2022-01-03Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obkMatthias Krüger-0/+54
Suggest while let x = y when encountering while x = y Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2022-01-03Auto merge of #92080 - Aaron1011:pattern-ice, r=cjgillotbors-4/+75
Move `PatKind::Lit` checking from ast_validation to ast lowering Fixes #92074 This allows us to insert an `ExprKind::Err` when an invalid expression is used in a literal pattern, preventing later stages of compilation from seeing an unexpected literal pattern.
2022-01-02Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, ↵bors-24/+24
r=wesleywiser Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0 This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. This does not change the default symbol-mangling-version. See https://github.com/rust-lang/rust/pull/89917 for a pull request changing the default. Rationale, from #89917: Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain . characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters A-Z, a-z, 0-9, and _. Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers). This pull request allows enabling the new v0 symbol-mangling-version. See #89917 for references to the implementation of v0, and for references to the tool changes to decode Rust symbols.
2022-01-02Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisabors-2/+70
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-02Auto merge of #92034 - petrochenkov:nolinknores, r=joshtriplettbors-10/+2
Remove effect of `#[no_link]` attribute on name resolution Previously it hid all non-macro names from other crates. This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors. I can kind of understand the possible reasoning behind the current behavior - if you can use names from a `no_link` crates then you can use, for example, functions too, but whether it will actually work or produce link-time errors will depend on random factors like inliner behavior. (^^^ This is not the actual reason why the current behavior exist, I've looked through git history and it's mostly accidental.) I think this risk is ok for such an obscure attribute, and we don't need to specifically prevent use of non-macro items from such crates. (I'm not actually sure why would anyone use `#[no_link]` on a crate, even if it's macro only, if you aware of any use cases, please share. IIRC, at some point it was used for crates implementing custom derives - the now removed legacy ones, not the current proc macros.) Extracted from https://github.com/rust-lang/rust/pull/91795.
2022-01-01Update references to `-Z symbol-mangling-version` to use `-C`Josh Triplett-24/+24
Replace `-Z symbol-mangling-version=v0` with `-C symbol-mangling-version=v0`. Replace `-Z symbol-mangling-version=legacy` with `-Z unstable-options -C symbol-mangling-version=legacy`.
2022-01-01Rollup merge of #92468 - NieDzejkob:silent-cfg, r=petrochenkovMatthias Krüger-0/+5
Emit an error for `--cfg=)` Fixes #73026 See also: #64467, #89468 The issue stems from a `FatalError` being silently raised in `panictry_buffer`. Normally this is not a problem, because `panictry_buffer` emits the causes of the error, but they are not themselves fatal, so they get filtered out by the silent emitter. To fix this, we use a parser entrypoint which doesn't use `panictry_buffer`, and we handle the error ourselves.
2022-01-01Move `PatKind::Lit` checking from ast_validation to ast loweringAaron Hill-4/+75
Fixes #92074 This allows us to insert an `ExprKind::Err` when an invalid expression is used in a literal pattern, preventing later stages of compilation from seeing an unexpected literal pattern.
2022-01-01Rollup merge of #92469 - joshtriplett:test-number-fix, r=Mark-SimulacrumMatthias Krüger-1/+1
Make tidy check for magic numbers that spell things Remove existing problematic cases. r? `@Mark-Simulacrum`
2022-01-01Rollup merge of #92460 - dwrensha:fix-92267, r=petrochenkovMatthias Krüger-0/+19
[rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape Fixes #92267. The problem was that the escape string "%%" does not need to appear at the very beginning of the format string, but the iterator implementation assumed that it did. The solution follows the pattern used by `format_foregin::shell::Subtitution::Escape`: https://github.com/rust-lang/rust/blob/8ed935e92dfb09ae388344b12284bf5110cf9265/compiler/rustc_builtin_macros/src/format_foreign.rs#L629
2022-01-01Rollup merge of #92420 - dtolnay:patrange, r=Mark-SimulacrumMatthias Krüger-12/+12
Fix whitespace in pretty printed PatKind::Range Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($pat:pat) => { stringify!($pat) }; } fn main() { println!("{}", repro!(0..=1)); } ``` Before:&ensp;`0 ..=1` After:&ensp;`0..=1` The canonical spacing applied by rustfmt has no space after the lower expr. Rustc's parser diagnostics also do not put a space there: https://github.com/rust-lang/rust/blob/df96fb166f59431e3de443835e50d5b8a7a4adb0/compiler/rustc_parse/src/parser/pat.rs#L754
2022-01-01Rollup merge of #92412 - dtolnay:tryspace, r=Mark-SimulacrumMatthias Krüger-1/+1
Fix double space in pretty printed TryBlock Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(try {})); } ``` Before:&ensp;<code>try&nbsp;&nbsp;{}</code> After:&ensp;<code>try&nbsp;{}</code> The `head` helper already appends a space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L654-L664 so doing `head` followed by `space` resulted in a double space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L2241-L2242
2021-12-31Make tidy check for magic numbers that spell thingsJosh Triplett-1/+1
Remove existing problematic cases.
2022-01-01Emit an error for `--cfg=)`Jakub Kądziołka-0/+5
Fixes #73026 See also: #64467, #89468 The issue stems from a `FatalError` being silently raised in `panictry_buffer`. Normally this is not a problem, because `panictry_buffer` emits the causes of the error, but they are not themselves fatal, so they get filtered out by the silent emitter. To fix this, we use a parser entrypoint which doesn't use `panictry_buffer`, and we handle the error ourselves.
2021-12-31[rustc_builtin_macros] add indices to ↵David Renshaw-0/+19
format_foreign::printf::Substitution::Escape
2021-12-31Extend check for UnsafeCell in consts to cover unionsTomasz Miąsko-0/+92
A validity companion to changes from #90373.
2021-12-30UI test updates for Result and Option method movesDavid Tolnay-14/+10
2021-12-30Auto merge of #92434 - matthiaskrgr:rollup-m8wuq0v, r=matthiaskrgrbors-3/+35
Rollup of 4 pull requests Successful merges: - #91519 (ast: Avoid aborts on fatal errors thrown from mutable AST visitor) - #92414 (Fix spacing of pretty printed const item without body) - #92423 (Add UI test for #92292) - #92427 (Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-30Rollup merge of #92423 - weirane:ui-92292, r=fee1-deadMatthias Krüger-0/+32
Add UI test for #92292 Closes #92292
2021-12-30Rollup merge of #92414 - dtolnay:constnoexpr, r=oli-obkMatthias Krüger-3/+3
Fix spacing of pretty printed const item without body Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{}", repro!(extern "C" { static S: i32; })); } ``` Before:&ensp;`extern "C" { static S: i32 ; }` After:&ensp;`extern "C" { static S: i32; }`
2021-12-30Auto merge of #89336 - Aaron1011:variance-struct-diag, r=cjgillotbors-0/+169
Refactor variance diagnostics to work with more types Instead of special-casing mutable pointers/references, we now support general generic types (currently, we handle `ty::Ref`, `ty::RawPtr`, and `ty::Adt`) When a `ty::Adt` is involved, we show an additional note explaining which of the type's generic parameters is invariant (e.g. the `T` in `Cell<T>`). Currently, we don't explain *why* a particular generic parameter ends up becoming invariant. In the general case, this could require printing a long 'backtrace' of types, so doing this would be more suitable for a follow-up PR. We still only handle the case where our variance switches to `ty::Invariant`.
2021-12-29Add UI test for #92292Wang Ruochen-0/+32
Closes #92292
2021-12-29Refactor variance diagnostics to work with more typesAaron Hill-0/+169
Instead of special-casing mutable pointers/references, we now support general generic types (currently, we handle `ty::Ref`, `ty::RawPtr`, and `ty::Adt`) When a `ty::Adt` is involved, we show an additional note explaining which of the type's generic parameters is invariant (e.g. the `T` in `Cell<T>`). Currently, we don't explain *why* a particular generic parameter ends up becoming invariant. In the general case, this could require printing a long 'backtrace' of types, so doing this would be more suitable for a follow-up PR. We still only handle the case where our variance switches to `ty::Invariant`.
2021-12-29Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisabors-0/+3
Add codegen option for branch protection and pointer authentication on AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets.
2021-12-29Fix whitespace in pretty printed PatKind::RangeDavid Tolnay-12/+12
2021-12-29Fix spacing in pretty printed PatKind::Struct with no fieldsDavid Tolnay-4/+4
2021-12-29Move equal sign back into head iboxDavid Tolnay-2/+1
2021-12-29Fix spacing of pretty printed const item without bodyDavid Tolnay-4/+5