about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-02-22Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obkbors-247/+337
MIR-OPT: Pass to deduplicate blocks This pass finds basic blocks that are completely equal, and replaces all uses with just one of them. ```bash $ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log ... $ cat log | wc -l 23875 ```
2021-02-22Auto merge of #82393 - JohnTitor:rollup-5c8jryl, r=JohnTitorbors-12/+525
Rollup of 9 pull requests Successful merges: - #82098 (Add internal `collect_into_array[_unchecked]` to remove duplicate code) - #82228 (Provide NonZero_c_* integers) - #82287 (Make "missing field" error message more natural) - #82351 (Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions) - #82353 (rustdoc: Remove unnecessary `Cell` around `param_env`) - #82367 (remove redundant option/result wrapping of return values) - #82372 (improve UnsafeCell docs) - #82379 (Fix sizes of repr(C) enums on hexagon) - #82382 (rustdoc: Remove `fake_def_ids` RefCell) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-22Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebankYuki Okushi-0/+475
Fix sizes of repr(C) enums on hexagon Enums on hexagon use a smallest size (but at least 1 byte) that fits all the enumeration values. This is unlike many other ABIs where enums are at least 32 bits. Fixes #82100
2021-02-22Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514Yuki Okushi-0/+38
Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions Partially addresses #82283.
2021-02-22Rollup merge of #82287 - r00ster91:field_name_and, r=petrochenkovYuki Okushi-12/+12
Make "missing field" error message more natural ```rust struct A { x: i32, y: i32, z: i32, } fn main() { A { }; } ``` ``` error[E0063]: missing fields `x`, `y`, `z` in initializer of `A` --> src/main.rs:8:5 | 8 | A { }; | ^ missing `x`, `y`, `z` ``` This error is now: ``` error[E0063]: missing fields `x`, `y` and `z` in initializer of `A` --> src/main.rs:8:5 | 8 | A { }; | ^ missing `x`, `y` and `z` ``` I thought it looked nicer and more natural this way. Also, if there is >3 fields missing, there is an "and" as well ("missing \`x\`, \`y\`, \`z\` *and* 1 other field"), but for <=3 there is not. As such it improves consistency too. As for the implementation, originally I ended up with a chunky `push_str` algorithm but then I figured I could just do the formatting manually since it's just 3 field names at maximum. It is comparatively readable. As a sidenote, one thing I was wondering about is, isn't there more cases where you have a list of things like field names? Maybe this whole thing can at some point later be made into a more general function to be used in multiple areas.
2021-02-22Auto merge of #79979 - GuillaumeGomez:rustdoc-gui-tests, r=Mark-Simulacrumbors-0/+100
Rustdoc gui tests This is a reopening of #70533. For this first version, there will be no screenshot comparison. Also, a big change compared to the previous version: the tests are now hosted in the rust repository directly. Since there is no image, it's pretty lightweight to say the least. So now, only remains the nodejs script to run the tests and the tests themselves. Just one thing is missing: where should I put the documentation for these tests? I'm not sure where would be the best place for that. The doc will contain important information like the documentation of the framework used and how to install it (`npm install browser-ui-test`, but still needs to be put somewhere so no one is lost). We'd also need to install the package when running the CI too. For now, it runs as long as we have nodejs installed, but I think we don't it to run in all nodejs targets? cc `@jyn514` r? `@Mark-Simulacrum`
2021-02-22Auto merge of #82295 - jyn514:feature-gate, r=Manishearthbors-0/+8
[intra-doc links] Don't check feature gates of items re-exported across crates It should be never break another crate to re-export a public item. Note that this doesn't check the feature gate at *all* for other crates: - Feature-gates aren't currently serialized, so the only way to check the gate is with ad-hoc attribute checking. - Checking the feature gate twice (once when documenting the original crate and one when documenting the current crate) seems not great. This should still catch using the feature most of the time though, since people tend to document their own crates. Closes https://github.com/rust-lang/rust/issues/82284. r? `@Manishearth`
2021-02-22Fix sizes of repr(C) enums on hexagonSimonas Kazlauskas-0/+475
Enums on hexagon use a smallest size (but at least 1 byte) that fits all the enumeration values. This is unlike many other ABIs where enums are at least 32 bits.
2021-02-21New pass to deduplicate blocksSimon Vandel Sillesen-1/+115
2021-02-21Make MatchBranchSimplification clean up after itselfSimon Vandel Sillesen-246/+222
2021-02-21Update src/test/rustdoc/description.rsMichael Howell-0/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21Update src/test/rustdoc/description.rsMichael Howell-0/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21Add rustdoc gui testsGuillaume Gomez-0/+100
2021-02-21Auto merge of #82359 - JohnTitor:rollup-6puemik, r=JohnTitorbors-8/+4
Rollup of 11 pull requests Successful merges: - #81300 (BTree: share panicky test code & test panic during clear, clone) - #81706 (Document BinaryHeap unsafe functions) - #81833 (parallelize x.py test tidy) - #81966 (Add new `rustc` target for Arm64 machines that can target the iphonesimulator) - #82154 (Update RELEASES.md 1.50 to include methods stabilized in #79342) - #82177 (Do not delete bootstrap.exe on Windows during clean) - #82181 (Add check for ES5 in CI) - #82229 (Add [A-diagnostics] bug report template) - #82233 (try-back-block-type test: Use TryFromSliceError for From test) - #82302 (Remove unsafe impl Send for CompletedTest & TestResult) - #82349 (test: Print test name only once on timeout) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-21Rollup merge of #82233 - ijackson:try-block-type-test, r=Mark-SimulacrumYuki Okushi-8/+4
try-back-block-type test: Use TryFromSliceError for From test Using `i32` is rather fragile because it has many implementations. Recently in an early draft of another MR (#82228) I did something that introduced a new `i32 as From<something>` impl and this test broke. TryFromSliceError is nice because it doesn't seem likely to grow new conversions. We still have one conversion, from Infallible. My other MR is going to be reworked and won't need this any more but having done it I thought I would submit it rather than just throw it away. Sorry for the tiny MR.
2021-02-21Auto merge of #79100 - a1phyr:better_assert_eq, r=m-ou-sebors-816/+230
Improve assert_eq! and assert_ne! This PR improves `assert_eq!` and `assert_ne!` by moving the panicking code in an external function. It does not change the fast path, but the move of the formatting in the cold path (the panic) may have a positive effect on in instruction cache use and with inlining. Moreover, the use of trait objects instead of generic may improve compile times for `assert_eq!`-heavy code. Godbolt link: ~~https://rust.godbolt.org/z/TYa9MT~~ \ Updated: https://rust.godbolt.org/z/bzE84x
2021-02-20Use has for non-regexesMichael Howell-6/+6
2021-02-20Fix formatting for description rustdoc UI testsMichael Howell-9/+14
2021-02-20Add rustdoc UI tests for new description behaviourMichael Howell-0/+31
2021-02-20Rollup merge of #82332 - GuillaumeGomez:no-src-link-on-dummy-spans, r=jyn514Guillaume Gomez-0/+12
Don't generate src link on dummy spans Just realized that the "auto trait impls" had `[src]` links were leading to the crate root because they were dummy spans. This PR fixes this issue. cc `@jyn514` r? `@camelid`
2021-02-20Rollup merge of #81991 - osa1:issue81839, r=estebankGuillaume Gomez-6/+56
Fix panic in 'remove semicolon' when types are not local It's not possible to check if removing a semicolon fixes the type error when checking match arms and one or both of the last arm's and the current arm's return types are imported "opaque" types. In these cases we don't generate a "consider removing semicolon" suggestions. Fixes #81839 --- I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?
2021-02-20Add test for no src links on dummy spansGuillaume Gomez-0/+12
2021-02-20Make "missing field" error message more naturalr00ster91-12/+12
2021-02-19Add tests for !Sized trait displayGuillaume Gomez-0/+17
2021-02-19[intra-doc links] Don't check feature gates of items re-exported across cratesJoshua Nelson-0/+8
It should be never break another crate to re-export a public item. Note that this doesn't check the feature gate at *all* for other crates: - Feature-gates aren't currently serialized, so the only way to check the gate is with ad-hoc attribute checking. - Checking the feature gate twice (once when documenting the original crate and one when documenting the current crate) seems not great. This should still catch using the feature most of the time though, since people tend to document their own crates.
2021-02-19Rollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514Dylan DPC-0/+48
rustdoc: Support argument files Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.: rustdoc `@argfile` This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments. The feature was stabilized for `rustc` in #66172.
2021-02-19Rollup merge of #82259 - osa1:issue82156, r=petrochenkovDylan DPC-0/+12
Fix popping singleton paths in when generating E0433 Fixes #82156 --- This was introduced with #72923, so pinging `@Patryk27` for reviews.
2021-02-19Rollup merge of #82245 - estebank:issue-78653, r=matthewjasperDylan DPC-0/+28
Do not ICE when evaluating locals' types of invalid `yield` When a `yield` is outside of a generator, check its value regardless to avoid an ICE while trying to get all locals' types in writeback. Fix #78653.
2021-02-19Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011Dylan DPC-6/+4
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2021-02-19Rollup merge of #81496 - guswynn:expected_async_block, r=oli-obkDylan DPC-0/+65
name async generators something more human friendly in type error diagnostic fixes #81457 Some details: 1. I opted to load the generator kind from the hir in TyCategory. I also use 1 impl in the hir for the descr 2. I named both the source of the future, in addition to the general type (`future`), not sure what is preferred 3. I am not sure what is required to make sure "generator" is not referred to anywhere. A brief `rg "\"generator\"" showed me that most diagnostics correctly distinguish from generators and async generator, but the `descr` of `DefKind` is pretty general (not sure how thats used) 4. should the descr impl of AsyncGeneratorKind use its display impl instead of copying the string?
2021-02-19rustdoc: Support argument filesMiguel Ojeda-0/+48
Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.: rustdoc @argfile This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments. The feature was stabilized for `rustc` in #66172. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-18Add explanations and suggestions to `irrefutable_let_patterns` lintCamelid-5/+54
2021-02-18Fix popping singleton paths in when generating E0433Ömer Sinan Ağacan-0/+12
Fixes #82156
2021-02-18Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, ↵Dylan DPC-1/+1
r=GuillaumeGomez Add long explanation for E0549 Helps with #61137
2021-02-18Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkorDylan DPC-33/+33
Replace if-let and while-let with `if let` and `while let` This pull request replaces if-let and while-let with `if let` and `while let`. closes https://github.com/rust-lang/rust/issues/82205
2021-02-18Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkovDylan DPC-1/+21
In some limited cases, suggest `where` bounds for non-type params Partially address #81971.
2021-02-18Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkorDylan DPC-0/+34
const_generics: Dont evaluate array length const when handling yet another error Same ICE as #82009 except triggered by a different error. cc ``@lcnr`` r? ``@varkor``
2021-02-18Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726Dylan DPC-76/+300
Ensure valid TraitRefs are created for GATs This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`. r? ````@jackh726````
2021-02-18Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-SimulacrumDylan DPC-0/+23
[libtest] Run the test synchronously when hitting thread limit libtest currently panics if it hits the thread limit. This often results in spurious test failures (<code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }'</code> ... `error: test failed, to rerun pass '--lib'`). This PR makes it continue to run the test synchronously if it runs out of threads. Closes #78165. ``@rustbot`` label: A-libtest T-libs
2021-02-18Add regression testÖmer Sinan Ağacan-0/+53
2021-02-18Update 'match-prev-arm-needing-semi'Ömer Sinan Ağacan-6/+3
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-6/+4
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-18Auto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitorbors-31/+87
Rollup of 8 pull requests Successful merges: - #82055 (Add diagnostics for specific cases for const/type mismatch err) - #82155 (Use !Sync std::lazy::OnceCell in usefulness checking) - #82202 (add specs for riscv32/riscv64 musl targets) - #82203 (Move some tests to more reasonable directories - 4) - #82211 (make `suggest_setup` help messages better) - #82212 (Remove redundant rustc_data_structures path component) - #82240 (remove useless ?s (clippy::needless_question_marks)) - #82243 (Add more intra-doc links to std::io) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-18Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPCYuki Okushi-17/+3
Move some tests to more reasonable directories - 4 cc #81941
2021-02-18Rollup merge of #82055 - JulianKnodt:ty_where_const, r=estebankYuki Okushi-14/+84
Add diagnostics for specific cases for const/type mismatch err For now, this adds at least more information so better diagnostics can be emitted for const mismatch errors. I'm not sure what exactly we want to emit, so I've left notes there temporarily, also to see if this is the right approach r? ```@lcnr``` cc: ```@estebank```
2021-02-18Add long explanation for E0549Jesus Rubio-1/+1
2021-02-17Do not ICE when evaluating locals' types of invalid `yield`Esteban Küber-0/+28
When a `yield` is outside of a generator, check its value regardless to avoid an ICE while trying to get all locals' types in writeback. Fix #78653.
2021-02-18Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obkbors-0/+1
Implement RFC 2580: Pointer metadata & VTable RFC: https://github.com/rust-lang/rfcs/pull/2580 ~~Before merging this PR:~~ * [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278). * [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513 * [x] Update `#[unstable]` attributes in the PR with the tracking issue number ---- This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound. For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated. This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`: ```rust pub trait Pointee { /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>` type Metadata: Copy + Send + Sync + Ord + Hash + Unpin; } pub trait Thin = Pointee<Metadata = ()>; pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {} pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {} pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {} impl<T: ?Sized> NonNull<T> { pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {} /// Convenience for `(ptr.cast(), metadata(ptr))` pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {} } impl<T: ?Sized> *const T { pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {} } impl<T: ?Sized> *mut T { pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {} } /// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>` pub struct DynMetadata<Dyn: ?Sized> { // Private pointer to vtable } impl<Dyn: ?Sized> DynMetadata<Dyn> { pub fn size_of(self) -> usize {} pub fn align_of(self) -> usize {} pub fn layout(self) -> crate::alloc::Layout {} } unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {} unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {} ``` API differences from the RFC, in areas noted as unresolved questions in the RFC: * Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc. * Added `to_raw_parts`
2021-02-17Rollup merge of #82021 - csmoe:issue-78600, r=tmandryDylan DPC-0/+23
Spell out nested Self type in lint message Closes #78600 r? `@tmandry`
2021-02-17Rollup merge of #82007 - sexxi-goose:reborrow, r=nikomatsakisDylan DPC-46/+346
Implement reborrow for closure captures The strategy for captures is detailed here with examples: https://hackmd.io/PzxYMPY4RF-B9iH9uj9GTA Key points: - We only need to reborrow a capture in case of move closures. - If we mutate something via a `&mut` we store it as a `MutBorrow`/`UniqueMuBorrow` of the path containing the `&mut`, - Similarly, if it's read via `&` ref we just store it as a `ImmBorrow` of the path containing the `&` ref. - If a path doesn't deref a `&mut`, `&`, then that path is captured by Move. - If the use of a path results in a move when the closure is called, then that path is truncated before any deref and the truncated path is moved into the closure. - In the case of non-move closure if a use of a path results in a move, then the path is truncated before any deref and the truncated path is moved into the closure. Note that the implementation differs a bit from the document to allow for truncated path to be used in the ClosureKind analysis that happens as part of the first capture analysis pass. Closes: https://github.com/rust-lang/project-rfc-2229/issues/31 r? ````@nikomatsakis````