about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
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-01Rollup merge of #92332 - GuillaumeGomez:where-clause-order, r=jshaMatthias Krüger-0/+15
Add test for where clause order I didn't use ``@snapshot`` because of the ` ` characters, it's much simpler doing it through rustdoc-gui testsuite. r? `@camelid`
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-01Auto merge of #92419 - erikdesjardins:coldland, r=nagisabors-0/+52
Mark drop calls in landing pads `cold` instead of `noinline` Now that deferred inlining has been disabled in LLVM (#92110), this shouldn't cause catastrophic size blowup. I confirmed that the test cases from https://github.com/rust-lang/rust/issues/41696#issuecomment-298696944 still compile quickly (<1s) after this change. ~Although note that I wasn't able to reproduce the original issue using a recent rustc/llvm with deferred inlining enabled, so those tests may no longer be representative. I was also unable to create a modified test case that reproduced the original issue.~ (edit: I reproduced it on CI by accident--the first commit timed out on the LLVM 12 builder, because I forgot to make it conditional on LLVM version) r? `@nagisa` cc `@arielb1` (this effectively reverts #42771 "mark calls in the unwind path as !noinline") cc `@RalfJung` (fixes #46515) edit: also fixes #87055
2022-01-01Update mixed doc comments testGuillaume Gomez-0/+10
2022-01-01Add test for where clause orderGuillaume Gomez-0/+15
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-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-108/+73
During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2021-12-31Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jshaMatthias Krüger-0/+10
Fix mobile toggles position Before: ![Screenshot from 2021-12-29 18-53-33](https://user-images.githubusercontent.com/3050060/147764842-082f6fa2-b631-4c47-ba34-ced76fe8494f.png) After: ![Screenshot from 2021-12-29 18-52-48](https://user-images.githubusercontent.com/3050060/147764853-13046330-2442-4fad-b26a-84c167711b54.png) r? `@jsha`
2021-12-31Rollup merge of #92405 - bjorn3:more_needs_inline_asm, r=lqdMatthias Krüger-0/+2
Add a couple needs-asm-support headers to tests This will allow them to be ignored by codegen backends that don't support inline asm.
2021-12-31Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomezMatthias Krüger-9/+7
rustdoc: use smaller number of colors to distinguish items This reduces visual distractions when reading method signatures. As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen): - method, function (ochre `#AD7C37`) - trait, trait alias (dark slate blue `#6E4FC9`) - enum, struct, type alias, union, primitive (maroon `#AD378A`) - static, module, keyword, associated type, foreign type (steel blue `#3873AD`) - macro (green `#068000`) - generic params, self, Self (unmarked black `#000000`) I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed"). The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types. Demo: https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-31Rollup merge of #90383 - tmiasko:union-validity, r=RalfJungMatthias Krüger-0/+92
Extend check for UnsafeCell in consts to cover unions A validity companion to changes from #90373. `@rust-lang/wg-const-eval`
2021-12-31[rustc_builtin_macros] add indices to ↵David Renshaw-0/+19
format_foreign::printf::Substitution::Escape
2021-12-31Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillotbors-0/+44
Import `SourceFile`s from crate before decoding foreign `Span` Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by enconding the `SourceFile`'s `CrateNum` when we encode a `Span`. During decoding, we call `imported_source_files()` when we encounter a foreign `CrateNum`, which ensure that all `SourceFile`s from that crate are imported into the current session.
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-30Fix display of toggles on mobileGuillaume Gomez-0/+10
2021-12-30Auto merge of #92434 - matthiaskrgr:rollup-m8wuq0v, r=matthiaskrgrbors-13/+45
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-13/+13
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-30add test for noop drop in landing padErik Desjardins-3/+18
2021-12-30keep noinline for system llvm < 14Erik Desjardins-1/+2
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/+89
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-29Mark drop calls in landing pads cold instead of noinlineErik Desjardins-0/+36
Now that deferred inlining has been disabled in LLVM, this shouldn't cause catastrophic size blowup.
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-4/+2
2021-12-29Fix spacing of pretty printed const item without bodyDavid Tolnay-15/+17
2021-12-29Fix spacing and ordering of words in pretty printed ImplDavid Tolnay-2/+2
2021-12-29Add a pretty printer test of impl<T> const TraitDavid Tolnay-0/+6
2021-12-29Fix double space in pretty printed TryBlockDavid Tolnay-1/+1
2021-12-29Add a couple needs-asm-support headers to testsbjorn3-0/+2
This will allow them to be ignored by codegen backends that don't support inline asm.
2021-12-29Suggest while let x = y when encountering while x = yametisf-0/+54
Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2021-12-29Rollup merge of #92372 - dtolnay:fntype, r=jackh726Matthias Krüger-1/+1
Print space after formal generic params in fn type Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($ty:ty) => { stringify!($ty) }; } fn main() { println!("{}", repro!(for<'a> fn(&'a u8))); } ``` Before:&ensp;`for<'a>fn(&'a u8)` After:&ensp;`for<'a> fn(&'a u8)` The pretty printer's `print_formal_generic_params` already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space. https://github.com/rust-lang/rust/blob/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/compiler/rustc_ast_pretty/src/pprust/state.rs#L1394-L1400
2021-12-29Rollup merge of #92371 - dtolnay:attrblock, r=oli-obkMatthias Krüger-12/+12
Remove pretty printer space inside block with only outer attrs Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(#[attr] {})); } ``` Before:&ensp;`#[attr] { }` After:&ensp;`#[attr] {}`
2021-12-29Rollup merge of #92351 - TmLev:master, r=GuillaumeGomezMatthias Krüger-0/+21
Add long error explanation for E0227 Part of the #61137.
2021-12-29Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomezMatthias Krüger-0/+11
rustdoc: Start cleaning up search index generation I'm trying to simplify and clean up the code, partly to make #90779 easier. r? `@GuillaumeGomez`
2021-12-29Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillotMatthias Krüger-0/+46
Visit expressions in-order when resolving pattern bindings [edited:] Visit the pattern's sub-expressions before defining any bindings. Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked. Fixes #92100
2021-12-29Rollup merge of #92118 - jackh726:type-alias-position-error, r=petrochenkovMatthias Krüger-0/+77
Parse and suggest moving where clauses after equals for type aliases ~Mostly the same as #90076, but doesn't make any syntax changes.~ Whether or not we want to land the syntax changes, we should parse the invalid where clause position and suggest moving. r? `@nikomatsakis` cc `@petrochenkov` you might have thoughts on implementation
2021-12-28Added regression test for issue 92015chordtoll-0/+18
2021-12-28Add regression test for #92308ThePuzzlemaker-2/+42
This amends off of an existing test introduced in #81769, if you think I should make a separate test I will.
2021-12-28Add regression test for #59502Noah Lev-0/+11
This issue was fixed using a hacky recursion "fuel" argument, but the issue was never minimized nor was a regression test added. The underlying bug is still unfixed, so this test should help with fixing it and removing the `recurse` hack.