about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-03-09Rollup merge of #82799 - bugadani:codegen-tests, r=nagisaMara Bos-0/+27
Add regression test for #75525
2021-03-09Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkovMara Bos-275/+457
or-patterns: disallow in `let` bindings ~~Blocked on https://github.com/rust-lang/rust/pull/81869~~ Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription. r? ``@petrochenkov``
2021-03-08Rollup merge of #82881 - Manishearth:crate-root, r=estebankMara Bos-7/+105
diagnostics: Be clear about "crate root" and `::foo` paths in resolve diagnostics Various changes to make sure the diagnostics are clear about the differences in `::foo` paths across editions: - `::foo` will say "crate root" in 2015 and "list of imported crates" in 2018 - `crate::` will never reference imported crates in 2018 Fixes https://github.com/rust-lang/rust/issues/82876
2021-03-08Rollup merge of #82874 - erikdesjardins:cgtests, r=nagisaMara Bos-0/+76
Add codegen tests for some issues closed by LLVM 12 Namely #73031, #75546, and #77812
2021-03-08Rollup merge of #82854 - estebank:issue-82827, r=oli-obkMara Bos-222/+176
Account for `if (let pat = expr) {}` Fix #82827.
2021-03-08Rollup merge of #82829 - JohnTitor:handle-neg-val, r=estebankMara Bos-1/+2
Handle negative literals in cast overflow warning Closes #48535 r? `@estebank`
2021-03-08Rollup merge of #82800 - jyn514:group-rustdoc-tests, r=Mark-SimulacrumMara Bos-0/+3
Move rustdoc UI tests into a subdirectory Helps with https://github.com/rust-lang/rust/issues/73494.
2021-03-08Move rustdoc UI tests into a subdirectoryJoshua Nelson-0/+3
This also adds a little leeway to the test limit.
2021-03-08Rollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievinkDylan DPC-147/+255
Disable destination propagation on all mir-opt-levels The new `// compile-flags: -Zunsound-mir-opts` are inserted without an extra newline to avoid introducing a large mir-opt diff.
2021-03-08Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011Dylan DPC-0/+196
Implement built-in attribute macro `#[cfg_eval]` + some refactoring This PR implements a built-in attribute macro `#[cfg_eval]` as it was suggested in https://github.com/rust-lang/rust/pull/79078 to avoid `#[derive()]` without arguments being abused as a way to configure input for other attributes. The macro is used for eagerly expanding all `#[cfg]` and `#[cfg_attr]` attributes in its input ("fully configuring" the input). The effect is identical to effect of `#[derive(Foo, Bar)]` which also fully configures its input before passing it to macros `Foo` and `Bar`, but unlike `#[derive]` `#[cfg_eval]` can be applied to any syntax nodes supporting macro attributes, not only certain items. `cfg_eval` was the first name suggested in https://github.com/rust-lang/rust/pull/79078, but other alternatives are also possible, e.g. `cfg_expand`. ```rust #[cfg_eval] #[my_attr] // Receives `struct S {}` as input, the field is configured away by `#[cfg_eval]` struct S { #[cfg(FALSE)] field: u8, } ``` Tracking issue: https://github.com/rust-lang/rust/issues/82679
2021-03-08Rollup merge of #82415 - petrochenkov:modin3, r=davidtwcoDylan DPC-15/+32
expand: Refactor module loading This is an accompanying PR to https://github.com/rust-lang/rust/pull/82399, but they can be landed independently. See individual commits for more details. Anyone should be able to review this equally well because all people actually familiar with this code left the project.
2021-03-07Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelixbors-96/+94
Let a portion of DefPathHash uniquely identify the DefPath's crate. This allows to directly map from a `DefPathHash` to the crate it originates from, without constructing side tables to do that mapping -- something that is useful for incremental compilation where we deal with `DefPathHash` instead of `DefId` a lot. It also allows to reliably and cheaply check for `DefPathHash` collisions which allows the compiler to gracefully abort compilation instead of running into a subsequent ICE at some random place in the code. The following new piece of documentation describes the most interesting aspects of the changes: ```rust /// A `DefPathHash` is a fixed-size representation of a `DefPath` that is /// stable across crate and compilation session boundaries. It consists of two /// separate 64-bit hashes. The first uniquely identifies the crate this /// `DefPathHash` originates from (see [StableCrateId]), and the second /// uniquely identifies the corresponding `DefPath` within that crate. Together /// they form a unique identifier within an entire crate graph. /// /// There is a very small chance of hash collisions, which would mean that two /// different `DefPath`s map to the same `DefPathHash`. Proceeding compilation /// with such a hash collision would very probably lead to an ICE and, in the /// worst case, to a silent mis-compilation. The compiler therefore actively /// and exhaustively checks for such hash collisions and aborts compilation if /// it finds one. /// /// `DefPathHash` uses 64-bit hashes for both the crate-id part and the /// crate-internal part, even though it is likely that there are many more /// `LocalDefId`s in a single crate than there are individual crates in a crate /// graph. Since we use the same number of bits in both cases, the collision /// probability for the crate-local part will be quite a bit higher (though /// still very small). /// /// This imbalance is not by accident: A hash collision in the /// crate-local part of a `DefPathHash` will be detected and reported while /// compiling the crate in question. Such a collision does not depend on /// outside factors and can be easily fixed by the crate maintainer (e.g. by /// renaming the item in question or by bumping the crate version in a harmless /// way). /// /// A collision between crate-id hashes on the other hand is harder to fix /// because it depends on the set of crates in the entire crate graph of a /// compilation session. Again, using the same crate with a different version /// number would fix the issue with a high probability -- but that might be /// easier said then done if the crates in questions are dependencies of /// third-party crates. /// /// That being said, given a high quality hash function, the collision /// probabilities in question are very small. For example, for a big crate like /// `rustc_middle` (with ~50000 `LocalDefId`s as of the time of writing) there /// is a probability of roughly 1 in 14,750,000,000 of a crate-internal /// collision occurring. For a big crate graph with 1000 crates in it, there is /// a probability of 1 in 36,890,000,000,000 of a `StableCrateId` collision. ``` Given the probabilities involved I hope that no one will ever actually see the error messages. Nonetheless, I'd be glad about some feedback on how to improve them. Should we create a GH issue describing the problem and possible solutions to point to? Or a page in the rustc book? r? `@pnkfelix` (feel free to re-assign)
2021-03-07diagnostics: Don't mention external crates when hitting import errors on ↵Manish Goregaokar-5/+5
crate imports in 2018
2021-03-07Remove notes, increase S/N ratioEsteban Küber-3/+0
2021-03-07add codegen tests for some issues closed by LLVM 12Erik Desjardins-0/+76
2021-03-07Add help for `matches` for `if let` in arm guardEsteban Küber-0/+2
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-8/+48
diagnostics for ::foo::Bar
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-4/+62
diagnostics (for bare `::foo`)
2021-03-07Add help suggesting `matches` to `let_chains` lintEsteban Küber-0/+48
2021-03-07Account for `if (let pat = expr) {}`Esteban Küber-222/+129
Partially address #82827.
2021-03-07Rollup merge of #82803 - jyn514:unversioned-files, r=GuillaumeGomezYuki Okushi-0/+19
rustdoc: Add an unstable option to print all unversioned files This allows sharing those files between different doc invocations without having to know their names ahead of time. Helps with https://github.com/rust-lang/docs.rs/issues/1302. r? ````@GuillaumeGomez```` cc ````@pietroalbini```` ````@Nemo157````
2021-03-07Rollup merge of #82793 - JohnTitor:move-ui-tests, r=petrochenkovYuki Okushi-45/+0
Move some tests to more suitable subdirs ## The results from classifui (The full results can be found here: https://gist.github.com/JohnTitor/c9e00840990b5e4a8fc562ec3571e427) - [lint-expr-stmt-attrs-for-early-lints.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint-expr-stmt-attrs-for-early-lints.rs) <sup>unknown</sup>: lint (1.566), feature-gates (-0.632), numbers-arithmetic (-0.955) - [try-block.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/try-block.rs) <sup>unknown</sup>: binding (1.385), try-block (-0.097), lint (-0.932) - [backtrace-debuginfo.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/backtrace-debuginfo.rs) <sup>unknown</sup>: macros (1.365), cfg (-0.279), drop (-0.291) - [issues/issue-3521.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-3521.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/3521)</sup>: consts (1.298), enum (-0.872), in-band-lifetimes (-0.978) - [impl-bounds-checking.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-bounds-checking.rs) <sup>unknown</sup>: traits (1.243), for (-0.999), shadowed (-0.999) - [issues/issue-17718.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-17718.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/17718)</sup>: binding (1.236), consts (0.315), extern (-0.779) - [issue-6157.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issue-6157.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/6157)</sup>: regions (1.213), unboxed-closures (-0.285), traits (-0.510) - [issues/issue-44373.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-44373.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/44373)</sup>: consts (1.187), nll (0.427), borrowck (-0.704) - [nullable-pointer-ffi-compat.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/nullable-pointer-ffi-compat.rs) <sup>unknown</sup>: regions (1.184), consts (0.650), traits (-0.571) - [issues/issue-52992.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-52992.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/52992)</sup>: nll (1.132), associated-types (-0.628), parser (-0.893) - [issues/issue-2330.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-2330.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/2330)</sup>: traits (1.116), directory_ownership (-0.691), compare-method (-0.981) - [issue-74047.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issue-74047.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/74047)</sup>: async-await (1.109), impl-trait (-0.629), resolve (-0.781) - [issues/issue-33140.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-33140.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/33140)</sup>: traits (1.063), coherence (-0.832), codemap_tests (-0.944) - [issues/issue-28576.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-28576.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/28576)</sup>: traits (1.062), associated-types (-0.333), impl-trait (-0.697) - [issues/issue-7222.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-7222.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/7222)</sup>: binding (1.062), consts (-0.226), numbers-arithmetic (-0.294) - [tup.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/tup.rs) <sup>unknown</sup>: structs-enums (1.061), threads-sendsync (-0.550), moves (-0.790) - [issues/issue-15261.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-15261.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/15261)</sup>: consts (1.052), where-clauses (-0.833), macros (-0.862) - [issues/issue-76179.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-76179.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/76179)</sup>: associated-types (1.048), process (-0.887), rfc-2457 (-0.984) - [issues/issue-42344.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-42344.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/42344)</sup>: borrowck (1.043), macros (-0.481), specialization (-0.966) - [issues/issue-18661.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-18661.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/18661)</sup>: unboxed-closures (1.038), mir (-0.648), higher-rank-trait-bounds (-0.688) - [issues/issue-2633.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-2633.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/2633)</sup>: structs-enums (1.020), functions-closures (-0.722), lint (-0.967) Some notes: - If there are related tests (e.g. it's for the same issue), they are moved along with it. - Moved try-block.rs to the `try-block` dir. - Moved tup.rs to the `tuple` dir. - Moved some tests that classified as consts to the `statics` dir, as it seems they have statics actually. - Skipped backtrace-debuginfo.rs because I think classifui overrates their helper macros. cc #73494 r? ```@petrochenkov```
2021-03-07Rollup merge of #82720 - henryboisdequin:fix-79040, r=oli-obkYuki Okushi-25/+28
Fix diagnostic suggests adding type `[type error]` Fixes #79040 ### Unresolved questions: <del>Why does this change output the diagnostic twice (`src/test/ui/79040.rs`)?</del> Thanks `````@oli-obk`````
2021-03-07Rollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomezYuki Okushi-10/+51
Cleanup rustdoc warnings ## Clean up error reporting for deprecated passes Using `error!` here goes all the way back to the original commit, https://github.com/rust-lang/rust/pull/8540. I don't see any reason to use logging; rustdoc should use diagnostics wherever possible. See https://github.com/rust-lang/rust/pull/81932#issuecomment-785291244 for further context. - Use spans for deprecated attributes - Use a proper diagnostic for unknown passes, instead of error logging - Add tests for unknown passes - Improve some wording in diagnostics ## Report that `doc(plugins)` doesn't work using diagnostics instead of `eprintln!` This also adds a test for the output. This was added in https://github.com/rust-lang/rust/pull/52194. I don't see any particular reason not to use diagnostics here, I think it was just missed in https://github.com/rust-lang/rust/pull/50541.
2021-03-06Implement built-in attribute macro `#[cfg_eval]`Vadim Petrochenkov-0/+196
2021-03-06Move some tests to more suitable subdirsYuki Okushi-45/+0
2021-03-06Handle negative literals in cast overflow warningYuki Okushi-1/+2
2021-03-06address commentsHenry Boisdequin-12/+9
2021-03-06Disable destination propagation on all mir-opt-levelsTomasz Miąsko-147/+255
2021-03-05Rollup merge of #82797 - henryboisdequin:name-issue-num, r=XanewokGuillaume Gomez-1/+1
Update tests names to start with `issue-` See ``@JohnTitor's`` [comment](https://github.com/rust-lang/rust/pull/82720#discussion_r586488083) ``@rustbot`` label +C-cleanup
2021-03-05Rollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obkGuillaume Gomez-72/+72
Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default r? `@oli-obk`
2021-03-05Rollup merge of #82714 - estebank:missing-braces, r=oli-obkGuillaume Gomez-0/+222
Detect match arm body without braces Fix #82524.
2021-03-05Rollup merge of #82708 - GuillaumeGomez:doc-test-attr-check, r=ManishearthGuillaume Gomez-16/+94
Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint Part of #82672. This PR does multiple things: * Create a new `INVALID_DOC_ATTRIBUTE` lint which is also "future incompatible", allowing us to use it as a warning for the moment until it turns (eventually) into a hard error. * Use this link when `#![doc(test(...))]` isn't used at the crate level. * Make #82702 use this new lint as well. r? ``@jyn514``
2021-03-05bless mir-inlining warning messageSantiago Pastorino-1/+1
2021-03-05Add an unstable option to print all unversioned filesJoshua Nelson-0/+19
This allows sharing those files between different doc invocations without having to know their names ahead of time.
2021-03-05Bump mir-opt-level from 2 to 3 in testsSantiago Pastorino-41/+41
2021-03-05Bump mir-opt-level from 3 to 4 in testsSantiago Pastorino-30/+30
2021-03-05use pat<no_top_alt> for patterns in let bindingsmark-275/+457
2021-03-05Add regression test for #75525Dániel Buga-0/+27
2021-03-05Make invalid_doc_attribute lint pluralGuillaume Gomez-4/+4
2021-03-05Auto merge of #82795 - m-ou-se:rollup-uzx0b92, r=m-ou-sebors-24/+153
Rollup of 10 pull requests Successful merges: - #80723 (Implement NOOP_METHOD_CALL lint) - #80763 (resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint) - #81136 (Improved IO Bytes Size Hint) - #81939 (Add suggestion `.collect()` for iterators in iterators) - #82289 (Fix underflow in specialized ZipImpl::size_hint) - #82728 (Avoid unnecessary Vec construction in BufReader) - #82764 (Add {BTreeMap,HashMap}::try_insert) - #82770 (Add assert_matches macro.) - #82773 (Add diagnostic item to `Default` trait) - #82787 (Remove unused code from main.js) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-05Update tests names to start with `issue-`Henry Boisdequin-1/+1
See @JohnTitor's [comment](https://github.com/rust-lang/rust/pull/82720#discussion_r586488083) @rustbot label +C-cleanup
2021-03-05Rollup merge of #81939 - kper:fixing-81584-allocate-in-iter, r=davidtwcoMara-0/+32
Add suggestion `.collect()` for iterators in iterators Closes #81584 ``` error[E0515]: cannot return value referencing function parameter `y` --> main3.rs:4:38 | 4 | ... .map(|y| y.iter().map(|x| x + 1)) | -^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `y` is borrowed here | help: Maybe use `.collect()` to allocate the iterator ``` Added the suggestion: `help: Maybe use `.collect()` to allocate the iterator`
2021-03-05Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebankMara-24/+27
resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint This lint was deny-by-default since July 2017, crater showed 7 uses on crates.io back then (https://github.com/rust-lang/rust/pull/42894#issuecomment-311921147). Unfortunately, the construction `pub use foo as bar` where `foo` is `extern crate foo;` was used by an older version `bitflags`, so turning it into an error causes too many regressions. So, this PR reduces the scope of the lint instead of turning it into a hard error, and only turns some more rarely used components of it into errors.
2021-03-05Rollup merge of #80723 - rylev:noop-lint-pass, r=estebankMara-0/+94
Implement NOOP_METHOD_CALL lint Implements the beginnings of https://github.com/rust-lang/lang-team/issues/67 - a lint for detecting noop method calls (e.g, calling `<&T as Clone>::clone()` when `T: !Clone`). This PR does not fully realize the vision and has a few limitations that need to be addressed either before merging or in subsequent PRs: * [ ] No UFCS support * [ ] The warning message is pretty plain * [ ] Doesn't work for `ToOwned` The implementation uses [`Instance::resolve`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/instance/struct.Instance.html#method.resolve) which is normally later in the compiler. It seems that there are some invariants that this function relies on that we try our best to respect. For instance, it expects substitutions to have happened, which haven't yet performed, but we check first for `needs_subst` to ensure we're dealing with a monomorphic type. Thank you to ```@davidtwco,``` ```@Aaron1011,``` and ```@wesleywiser``` for helping me at various points through out this PR ❤️.
2021-03-05Auto merge of #82777 - GuillaumeGomez:rollup-etcsupl, r=GuillaumeGomezbors-5/+58
Rollup of 5 pull requests Successful merges: - #76716 (Don't warn for `missing_doc_examples` when item is #[doc(hidden)]) - #82088 (Shorten html::render) - #82690 (Update rustdoc documentation) - #82752 (Add a regression test for issue-81712) - #82765 (Fix polymorphization ICE on associated types in trait decls using const generics in bounds) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-05Auto merge of #71481 - estebank:inherit-stability, r=nikomatsakisbors-149/+212
Inherit `#[stable(..)]` annotations in enum variants and fields from its item Lint changes for #65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
2021-03-05expand: Introduce enum for module loading errors and make module loading ↵Vadim Petrochenkov-4/+4
speculative
2021-03-05expand: Move module file path stack from global session to expansion dataVadim Petrochenkov-11/+13
Also don't push the paths on the stack directly in `fn parse_external_mod`, return them instead.
2021-03-05expand: Remove obsolete `DirectoryOwnership::UnownedViaMod`Vadim Petrochenkov-0/+15
This ownership kind is only constructed in the case of path attributes like `#[path = ".."]` without a file name segment, which always represent some kind of directories and will produce and error on attempt to parse them as a module file.