about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-05-29Auto merge of #111748 - nnethercote:Cow-DiagnosticMessage, r=WaffleLapkinbors-1/+1
Use `Cow` in `{D,Subd}iagnosticMessage`. Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile. r? `@WaffleLapkin`
2023-05-29Auto merge of #112055 - matthiaskrgr:rollup-y3exx8c, r=matthiaskrgrbors-6/+68
Rollup of 5 pull requests Successful merges: - #112029 (Recover upon mistyped error on typo'd `const` in const param def) - #112037 (Add details about `unsafe_op_in_unsafe_fn` to E0133) - #112039 (compiler: update solaris/illumos to enable tsan support.) - #112042 (Migrate GUI colors test to original CSS color format) - #112045 (Followup to #111973) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-29Rollup merge of #112042 - GuillaumeGomez:migrate-gui-test-color-8, r=notriddleMatthias Krüger-6/+6
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-05-29Rollup merge of #112029 - jieyouxu:typo-const-in-const-param-def, r=cjgillotMatthias Krüger-0/+62
Recover upon mistyped error on typo'd `const` in const param def And add machine-applicable fix for the typo'd `const` keyword. ### Before ``` error: expected one of `,`, `:`, `=`, or `>`, found `N` --> src/lib.rs:1:18 | 1 | pub fn bar<Const N: u8>() {} | ^ expected one of `,`, `:`, `=`, or `>` ``` ### After This PR ``` error: `const` keyword was mistyped as `Const` --> test.rs:1:8 | 1 | fn bar<Const N: u8>() {} | ^^^^^ | help: use the `const` keyword | 1 | fn bar<const N: u8>() {} | ~~~~~ ``` Fixes #111941.
2023-05-29Auto merge of #111963 - nnethercote:inline-derived-hash, r=lqdbors-0/+15
Inline derived `hash` Because most of the other derived functions are inlined: `clone`, `default`, `eq`, `partial_cmp`, `cmp`. The exception is `fmt`, but it tends to not be on hot paths as much. r? `@ghost`
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-28Auto merge of #111813 - scottmcm:pretty-mir, r=cjgillotbors-756/+754
MIR: opt-in normalization of `BasicBlock` and `Local` numbering This doesn't matter at all for actual codegen, but after spending some time reading pre-codegen MIR, I was wishing I didn't have to jump around so much in reading post-inlining code. So this add two passes that are off by default for every mir level, but can be enabled (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) for humans.
2023-05-28Migrate GUI colors test to original CSS color formatGuillaume Gomez-6/+6
2023-05-28Auto merge of #112026 - saethlin:misaligned-addrof, r=pnkfelixbors-0/+15
Don't check for misaligned raw pointer derefs inside Rvalue::AddressOf From https://github.com/rust-lang/rust/pull/112026#issuecomment-1565686697: rustc 1.70 (stable next week) added a Mir pass to add pointer alignment checks in debug mode. Adding these checks caused some crates to break, but that was expected, since they contain broken code (https://github.com/rust-lang/rust/issues/111487) for tracking that. However, the checks added are slightly more aggressive than they should have been. Specifically, they also check the place in an `addr_of!` expression. Whether lack of alignment there is or isn't UB is unclear. This PR modifies the pass to not affect those cases. I spot checked the crater regressions and the ones I saw were not the case that this PR is modifying. It still seems good to not land anything overaggressive though
2023-05-28Auto merge of #112001 - saethlin:enable-matchbranchsimplification, r=cjgillotbors-5/+42
Enable MatchBranchSimplification This pass is one of the small number of benefits from `-Zmir-opt-level=3` that has motivated rustc_codegen_cranelift to use it: https://github.com/rust-lang/rust/blob/19ed0aade60e1c1038fe40554bcd9d01b717effa/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs#L244-L246 Cranelift's motivation for this is _runtime_ performance improvements in debug builds. Lifting this pass all the way to `-Zmir-opt-level=1` seems to come without significant perf overhead, so that's what I'm suggesting here.
2023-05-28Recover upon encountering mistyped `Const` in const param def许杰友 Jieyou Xu (Joe)-0/+62
2023-05-28Auto merge of #112000 - wesleywiser:safestack, r=Amanieubors-0/+11
Add support for LLVM SafeStack Adds support for LLVM [SafeStack] which provides backward edge control flow protection by separating the stack into two parts: data which is only accessed in provable safe ways is allocated on the normal stack (the "safe stack") and all other data is placed in a separate allocation (the "unsafe stack"). SafeStack support is enabled by passing `-Zsanitizer=safestack`. [SafeStack]: https://clang.llvm.org/docs/SafeStack.html cc `@rcvalle` #39699
2023-05-28Auto merge of #111378 - jieyouxu:local-shadows-glob-reexport, r=petrochenkovbors-3/+87
Add warn-by-default lint when local binding shadows exported glob re-export item This PR introduces a warn-by-default rustc lint for when a local binding (a use statement, or a type declaration) produces a name which shadows an exported glob re-export item, causing the name from the exported glob re-export to be hidden (see #111336). ### Unresolved Questions - [x] ~~Is this approach correct? While it passes the UI tests, I'm not entirely convinced it is correct.~~ Seems to be ok now. - [x] ~~What should the lint be called / how should it be worded? I don't like calling `use x::*;` or `struct Foo;` a "local binding" but they are `NameBinding`s internally if I'm not mistaken.~~ ~~The lint is called `local_binding_shadows_glob_reexport` for now, unless a better name is suggested.~~ `hidden_glob_reexports`. Fixes #111336.
2023-05-27Add a test for misaligned pointer derefs inside addr_of!Ben Kimock-0/+15
2023-05-27Rollup merge of #111181 - bvanjoi:fix-issue-111148, r=davidtwcoMatthias Krüger-0/+10
fix(parse): return unpected when current token is EOF close https://github.com/rust-lang/rust/issues/111148 #111148 panic occurred because [FatalError.raise()](https://github.com/bvanjoi/rust/blob/master/compiler/rustc_parse/src/parser/mod.rs#LL540C3-L540C3) was encountered which caused by `Eof` and `Pound`(the last token) had same span, when parsing `#` in `fn a<<i<Y<w<>#`. <img width="825" alt="image" src="https://user-images.githubusercontent.com/30187863/236612589-9e2c6a0b-18cd-408c-b636-c12a51cbcf1c.png"> There are a few ways to solve this problem: - Change the action assign for [self.last_unexpected_token_span](https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/parser/diagnostics.rs#L592), for example, if current token is `Eof`, then return Error directly. - Avoid triggering the `FatalError` when the current token is `Eof`. I have chosen the second option because executing `expected_one_of_not_found` when the token is `Eof` but not in `ediable` seems reasonable.
2023-05-27Try enabling MatchBranchSimplificationBen Kimock-5/+42
2023-05-27Auto merge of #110975 - Amanieu:panic_count, r=joshtriplettbors-1/+29
Rework handling of recursive panics This PR makes 2 changes to how recursive panics works (a panic while handling a panic). 1. The panic count is no longer used to determine whether to force an immediate abort. This allows code like the following to work without aborting the process immediately: ```rust struct Double; impl Drop for Double { fn drop(&mut self) { // 2 panics are active at once, but this is fine since it is caught. std::panic::catch_unwind(|| panic!("twice")); } } let _d = Double; panic!("once"); ``` Rustc already generates appropriate code so that any exceptions escaping out of a `Drop` called in the unwind path will immediately abort the process. 2. Any panics while the panic hook is executing will force an immediate abort. This is necessary to avoid potential deadlocks like #110771 where a panic happens while holding the backtrace lock. We don't even try to print the panic message in this case since the panic may have been caused by `Display` impls. Fixes #110771
2023-05-27Rework handling of recursive panicsAmanieu d'Antras-1/+29
2023-05-27Rollup merge of #112014 - notriddle:notriddle/intra-doc-weird-syntax, ↵Guillaume Gomez-3/+416
r=GuillaumeGomez,fmease rustdoc: get unnormalized link destination for suggestions Fixes #110111 This bug, and the workaround in this PR, is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of link components. In particular, pulldown-cmark doesn't provide the offsets of the contents of a link. To work around this, rustdoc parser parts of a link definition itself. [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-27Rollup merge of #111997 - GuillaumeGomez:re-export-doc-hidden-macros, ↵Guillaume Gomez-3/+44
r=notriddle Fix re-export of doc hidden macro not showing up It's part of the follow-up of https://github.com/rust-lang/rust/pull/109697. Re-exports of doc hidden macros should be visible. It was the only kind of re-export of doc hidden item that didn't show up. r? `@notriddle`
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-17/+11
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-27Add warn-by-default lint for local binding shadowing exported glob re-export ↵许杰友 Jieyou Xu (Joe)-3/+87
item
2023-05-27Auto merge of #111928 - c410-f3r:dqewdas, r=eholkbors-80/+17
[RFC-2011] Expand more expressions cc #44838 Expands `if`, `let`, `match` and also makes `generic_assert_internals` an allowed feature when using `assert!`. `#![feature(generic_assert)]` is still needed to activate everything. ```rust #![feature(generic_assert)] fn fun(a: Option<i32>, b: Option<i32>, c: Option<i32>) { assert!( if a.is_some() { 1 } else { 2 } == 3 && if let Some(elem) = b { elem == 4 } else { false } && match c { Some(_) => true, None => false } ); } fn main() { fun(Some(1), None, Some(2)); } // Assertion failed: assert!( // if a.is_some() { 1 } else { 2 } == 3 // && if let Some(elem) = b { elem == 4 } else { false } // && match c { Some(_) => true, None => false } // ); // // With captures: // a = Some(1) // b = None // c = Some(2) ```
2023-05-27Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, ↵bors-4/+7
r=albertlarsan68,oli-obk new tool `rustdoc-gui-test` Implements new tool `rustdoc-gui-test` that allows using compiletest headers for `rustdoc-gui` tests.
2023-05-26rustdoc: get unnormalized link destination for suggestionsMichael Howell-3/+416
Fixes #110111 This bug, and the workaround in this commit, is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of link components. In particular, pulldown-cmark doesn't provide the offsets of the contents of a link. To work around this, rustdoc parser parts of a link definition itself. [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-27Auto merge of #111245 - fee1-dead-contrib:temp-fix-tuple-struct-field, r=lcnrbors-0/+109
fix for `Self` not respecting tuple Ctor privacy This PR fixes #111220 by checking the privacy of tuple constructors using `Self`, so the following code now errors ```rust mod my { pub struct Foo(&'static str); } impl AsRef<str> for my::Foo { fn as_ref(&self) -> &str { let Self(s) = self; // previously compiled, now errors correctly s } } ```
2023-05-27Correctly handle multiple re-exports of bang macros at the same levelGuillaume Gomez-1/+43
2023-05-27Rollup merge of #111991 - BoxyUwU:change_error_term_display, r=compiler-errorsMatthias Krüger-7/+7
Change ty and const error's pretty printing to be in braces `[const error]` and `[type error]` are slightly confusing since they look like either a slice with an error type for the element ty or a slice with a const argument as the type ???. This PR changes them to display as `{const error}` and `{type error}` similar to `{integer}`. This does not update the `Debug` impls for them which is done in #111988. I updated some error logic to avoid printing the substs of trait refs when unable to resolve an assoc item for them, this avoids emitting errors with `{type error}` in them. The substs are not relevant for these errors since we don't take into account the substs when resolving the assoc item. r? ``@compiler-errors``
2023-05-27Rollup merge of #111954 - asquared31415:unknown_ptr_type_error, ↵Matthias Krüger-2/+57
r=compiler-errors improve error message for calling a method on a raw pointer with an unknown pointee The old error message had very confusing wording. Also added some more test cases besides the single edition test. r? `@compiler-errors`
2023-05-27Rollup merge of #111714 - cjgillot:lint-expect-confusion, r=wesleywiserMatthias Krüger-0/+7
Stop confusing specification levels when computing expectations. Fixes https://github.com/rust-lang/rust/issues/111682
2023-05-26Add SafeStack support to rustcWesley Wiser-0/+11
Adds support for LLVM [SafeStack] which provides backward edge control flow protection by separating the stack into two parts: data which is only accessed in provable safe ways is allocated on the normal stack (the "safe stack") and all other data is placed in a separate allocation (the "unsafe stack"). SafeStack support is enabled by passing `-Zsanitizer=safestack`. [SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-05-26Auto merge of #103291 - ink-feather-org:typeid_no_struct_match, r=dtolnaybors-7/+17
Remove structural match from `TypeId` As per https://github.com/rust-lang/rust/pull/99189#issuecomment-1203720442. > Removing the structural equality might make sense, but is a breaking change that'd require a libs-api FCP. https://github.com/rust-lang/rust/pull/99189#issuecomment-1197545482 > Landing this PR now (well, mainly the "remove structural equality" part) would unblock `const fn` `TypeId::of`, since we only postponed that because we were guaranteeing too much. See also #99189, #101698
2023-05-26improve error message for calling a method on a raw pointer with an unknown ↵asquared31415-2/+57
pointee, and add some tests
2023-05-26Update tests for re-exports of doc hidden macrosGuillaume Gomez-3/+2
2023-05-26print const and type errors in braces not square bracketsBoxy-7/+7
2023-05-26Blesses UI tests, add known bug to typeid-equality-by-subtypingonestacked-7/+17
2023-05-26Rollup merge of #111951 - cjgillot:uninh-comment, r=NadrierilMatthias Krüger-76/+177
Correct comment on privately uninhabited pattern. Follow-up to https://github.com/rust-lang/rust/pull/111624#discussion_r1204767933 r? `@Nadrieril`
2023-05-26Rollup merge of #111947 - obeis:issue-111943, r=compiler-errorsMatthias Krüger-0/+38
Add test for RPIT defined with different hidden types with different substs Close #111943
2023-05-26fix for `Self` not respecting tuple Ctor privacyDeadbeef-0/+109
This fixes #111220 by checking the privacy of tuple constructors using `Self`, so the following code now errors ```rust mod my { pub struct Foo(&'static str); } impl AsRef<str> for my::Foo { fn as_ref(&self) -> &str { let Self(s) = self; // previously compiled, now errors correctly s } } ```
2023-05-26Add test for RPIT defined with different hidden types with different substsObei Sideg-0/+38
2023-05-25Rollup merge of #111945 - GuillaumeGomez:migrate-gui-test-color-7, r=notriddleMichael Goulet-42/+42
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? ``@notriddle``
2023-05-25Rollup merge of #111929 - compiler-errors:no-newline-apit, r=wesleywiserMichael Goulet-0/+44
Don't print newlines in APITs This is kind of a hack, but it gets the job done because the only "special" formatting that (afaict) `rustc_ast_pretty` does is break with newlines sometimes. Fixes rust-lang/measureme#207
2023-05-25Rollup merge of #111831 - clubby789:capture-slice-pat, r=cjgillotMichael Goulet-85/+196
Always capture slice when pattern requires checking the length Fixes #111751 cc ``@zirconium-n,`` I see you were assigned to this but I've fixed some similar issues in the past and had an idea on how to investigate this.
2023-05-25Rollup merge of #111757 - lowr:fix/lint-attr-on-match-arm, r=eholkMichael Goulet-39/+131
Consider lint check attributes on match arms Currently, lint check attributes on match arms have no effect for some lints. This PR makes some lint passes to take those attributes into account. - `LateContextAndPass` for late lint doesn't update `last_node_with_lint_attrs` when it visits match arms. This leads to lint check attributes on match arms taking no effects on late lints that operate on the arms' pattern: ```rust match value { #[deny(non_snake_case)] PAT => {} // `non_snake_case` only warned due to default lint level } ``` To be honest, I'm not sure whether this is intentional or just an oversight. I've dug the implementation history and searched up issues/PRs but couldn't find any discussion on this. - `MatchVisitor` doesn't update its lint level when it visits match arms. This leads to check lint attributes on match arms taking no effect on some lints handled by this visitor, namely: `bindings_with_variant_name` and `irrefutable_let_patterns`. This seems to be a fallout from #108504. Before 05082f57afbf5d2e8fd7fb67719336d78b58e759, when the visitor operated on HIR rather than THIR, check lint attributes for the said lints were effective. [This playground][play] compiles successfully on current stable (1.69) but fails on current beta and nightly. I wasn't sure where best to place the test for this. Let me know if there's a better place. [play]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=38432b79e535cb175f8f7d6d236d29c3 [play-match]: https://play.rust-lang.org/?version=beta&mode=debug&edition=2021&gist=629aa71b7c84b269beadeba664e2221d
2023-05-25Rollup merge of #111152 - lukas-code:markdown-parsers-are-hard, r=GuillaumeGomezMichael Goulet-10/+35
update `pulldown-cmark` to `0.9.3` This PR updates `pulldown-cmark` to version `0.9.3`, which does two main things: * Pulls in https://github.com/raphlinus/pulldown-cmark/pull/643 to fix https://github.com/rust-lang/rust/issues/111117 * Allows parsing strikethrough with single tildes, e.g. `~foo~` -> ~foo~. This matches the [GFM spec](https://github.github.com/gfm/#strikethrough-extension-). Full changelog: https://github.com/raphlinus/pulldown-cmark/pull/646
2023-05-26Inline derived `hash` function.Nicholas Nethercote-0/+15
Because most of the other derived functions are inlined: `clone`, `default`, `eq`, `partial_cmp`, `cmp`. The exception is `fmt`, but it tends to not be on hot paths as much.
2023-05-25Add NOTE annotations.Camille GILLOT-75/+141
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-17/+11
2023-05-25Always capture slice when pattern requires checking the lengthclubby789-85/+196
2023-05-25Add inter-crate test.Camille GILLOT-40/+75