about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-02-08Remove obsolete no-op #[main] attribute from compiler.Jeremy Banks-0/+35
2022-02-07Drop tracking: improve break and continue handlingEric Holk-0/+19
This commit fixes two issues. One, sometimes break or continue have a block target instead of an expression target. This seems to mainly happen with try blocks. Since the drop tracking analysis only works on expressions, if we see a block target for break or continue, we substitute the last expression of the block as the target instead. Two, break and continue were incorrectly being treated as the same, so continue would also show up as an exit from the loop or block. This patch corrects the way continue is handled by keeping a stack of loop entry points and uses those to find the target of the continue.
2022-02-07Drop tracking: track borrows of projectionsEric Holk-0/+12
Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs.
2022-02-07Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakisbors-1611/+2149
Lazy type-alias-impl-trait Previously opaque types were processed by 1. replacing all mentions of them with inference variables 2. memorizing these inference variables in a side-table 3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing. This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around. Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing * https://github.com/rust-lang/rfcs/pull/2515 much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities). r? `@nikomatsakis` fixes #93411 fixes #88236
2022-02-07Fix hover effects in sidebarJacob Hoffman-Andrews-5/+5
The dark and ayu themes have a menu-like highlight on sidebar items. The light theme used to, but it was accidentally lost in the sidebar unification. The change brings back the hover effect in the light theme. It also makes the hover effect apply consistently to all links in the sidebar, including headings. It also simplifies the "In _path_" heading so it's one big link. The breadcrumbs are still readily available at the top of the page.
2022-02-07Change inference var check to be in project_typeJack Huey-21/+16
2022-02-07Don't match any projection predicates when the obligation has inference ↵Jack Huey-0/+52
types or consts in GAT substs
2022-02-07Update rustdoc testGuillaume Gomez-1/+1
2022-02-07Add test for block doc comments horizontal trimGuillaume Gomez-0/+21
2022-02-07Add a test showing that we don't infer across multiple uses of the same ↵Oli Scherer-0/+27
opaque type but with a different order of generic arguments
2022-02-07Print opaque types from type aliases via their pathOli Scherer-58/+138
2022-02-07Auto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-sebors-183/+167
Rollup of 13 pull requests Successful merges: - #88313 (Make the pre-commit script pre-push instead) - #91530 (Suggest 1-tuple parentheses on exprs without existing parens) - #92724 (Cleanup c_str.rs) - #93208 (Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> for rust 1.60.0) - #93394 (Don't allow {} to refer to implicit captures in format_args.) - #93416 (remove `allow_fail` test flag) - #93487 (Fix linking stage1 toolchain in `./x.py setup`) - #93673 (Linkify sidebar headings for sibling items) - #93680 (Drop json::from_reader) - #93682 (Update tracking issue for `const_fn_trait_bound`) - #93722 (Use shallow clones for submodules managed by rustbuild, not just bootstrap.py) - #93723 (Rerun bootstrap's build script when RUSTC changes) - #93737 (bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG') Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-07Rollup merge of #93682 - ↵Mara Bos-18/+18
PatchMixolydic:where-in-the-world-is-const_fn_trait_bound, r=oli-obk Update tracking issue for `const_fn_trait_bound` It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). This tracking issue doesn't mention anything about `const_fn_trait_bound`(the only occurrence of "trait bound" is for the now-removed `?const Trait` syntax), which can be confusing to people who want to find out more about trait bounds on `const fn`s. This pull request changes the tracking issue to one meant specifically for `const_fn_trait_bound`, #93706, which can help collect information on this feature's stabilization and point users towards `const_trait_impl` if they're looking for const-in-const-contexts trait bounds. Fixes #93679. `````@rustbot````` modify labels +A-const-fn +F-const_trait_impl
2022-02-07Rollup merge of #93673 - jsha:linkify-sidebar-headings, r=GuillaumeGomezMara Bos-1/+8
Linkify sidebar headings for sibling items Also adjust CSS so this doesn't produce excess padding/margin. Note: I tried and failed to write a test with browser-UI-test. First I tried to `assert-property: (".block.mod h3 a", {"href": "index.html#macros"})`. But the `href` that gets read out is the fully-quallified URL, starting with `file:///`. That URL will differ depending on what path the test is run from, so that doesn't work. Next I tried clicking on the appropriate sidebar link, and verifying that the appropriate heading on the next page is highlighted with the right background color. However, that also didn't work: according to browser-UI-test, the targeted heading was plain white. However, running with no-headless, I could see that it actually was yellow. I suspect this is a bug in the older version of Chromium used with browser-UI-test's bundled puppeteer, since it doesn't reproduce on latest Chrome. Fixes #92957 Demo: https://rustdoc.crud.net/jsha/linkify-sidebar-headings/std/string/trait.ToString.html r? ``@GuillaumeGomez``
2022-02-07Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-seMara Bos-150/+18
remove `allow_fail` test flag close #93345
2022-02-07Rollup 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-07Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelidMara Bos-14/+82
Suggest 1-tuple parentheses on exprs without existing parens A follow-on from #86116, split out from #90677. This alters the suggestion to add a trailing comma to create a 1-tuple - previously we would only apply this if the relevant expression was parenthesised. We now make the suggestion regardless of parentheses, which reduces the fragility of the check (w.r.t formatting). e.g. ```rust let a: Option<(i32,)> = Some(3); ``` gets the below suggestion: ```rust let a: Option<(i32,)> = Some((3,)); // ^ ^^ ``` This change also improves the suggestion in other ways, such as by only making the suggestion if the types would match after the suggestion is applied and making the suggestion a multipart suggestion.
2022-02-07Auto merge of #93719 - scottmcm:core-as-2021-everywhere, r=Mark-Simulacrumbors-1/+1
Build libcore as 2021 in a few more places The `Cargo.toml` has `edition = "2021"` (as of #92068), so that's what these command lines should use too.
2022-02-07Add `#[no_coverage]` tests for nested functionsArpad Borsos-9/+109
2022-02-07add fut/back compat tests for implied trait boundslcnr-0/+98
2022-02-06apply noundef explicitly in all cases instead of relying on dereferenceable ↵Erik Desjardins-14/+14
implying it
2022-02-06test that MaybeUninit<bool> is not noundefErik Desjardins-0/+8
2022-02-06rustdoc: Special-case macro lookups lessJoshua Nelson-0/+9
Previously, rustdoc had 3 fallbacks it used: 1. `resolve_macro_path` 2. `all_macros` 3. `resolve_str_path_error` Ideally, it would only use `resolve_str_path_error`, to be consistent with other namespaces. Unfortunately, that doesn't consider macros that aren't defined at module scope; consider for instance ```rust { struct S; macro_rules! mac { () => {} } // `mac`'s scope starts here /// `mac` <- `resolve_str_path_error` won't see this struct Z; //`mac`'s scope ends here } ``` This changes it to only use `all_macros` and `resolve_str_path_error`, and gives `resolve_str_path_error` precedence over `all_macros` in case there are two macros with the same name in the same module. This also adds a failing test case which will catch trying to remove `all_macros`.
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-43/+187
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-07add tests and fix commentscynecx-0/+38
2022-02-06Build libcore as 2021 in a few more placesScott McMurray-1/+1
The `Cargo.toml` has `edition = "2021"`, so that's what these command lines should use too.
2022-02-06Fix tracking issue for `const_fn_trait_bound`Ruby Lazuli-18/+18
It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). `const_fn_trait_bounds` weren't mentioned here, so this commit changes its tracking issue to a new one.
2022-02-06Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obkMatthias Krüger-8/+28
Require const stability attribute on all stable functions that are `const` This PR requires all stable functions (of all kinds) that are `const fn` to have a `#[rustc_const_stable]` or `#[rustc_const_unstable]` attribute. Stability was previously implied if omitted; a follow-up PR is planned to change the fallback to be unstable.
2022-02-05Linkify sidebar headings for sibling itemsJacob Hoffman-Andrews-1/+8
Also adjust CSS so this doesn't produce excess padding/margin.
2022-02-06Rollup merge of #93669 - compiler-errors:const-generic-args, r=lcnrMatthias Krüger-0/+36
Resolve lifetimes for const generic defaults We weren't visiting the const generic default argument in `rustc_resolve::late::lifetimes`. This seems to fix the issue, and we deny any non-`'static` lifetimes anyways. Fixes #93647
2022-02-06Rollup merge of #93649 - WaffleLapkin:regression_test_80309, r=oli-obkMatthias Krüger-0/+31
Add regression tests for issue 80309 Closes #80309 😝 I'm not sure where to put the tests, is `ui/issues` the right place for this kind of tests?
2022-02-06Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillotMatthias Krüger-22/+23
Change struct expr pretty printing to match rustfmt style This PR backports trailing comma support from https://github.com/dtolnay/prettyplease into rustc_ast_pretty and uses it to improve the formatting of struct expressions. Example: ```rust macro_rules! stringify_expr { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", stringify_expr!(Struct { a: Struct { b, c }, })); println!("{}", stringify_expr!(Struct { aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct { cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE, }, })); } ``` 🤮 Before: ```console Struct{a: Struct{b, c,},} Struct{aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct{cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE,},} ``` After: ```console Struct { a: Struct { b, c } } Struct { aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct { cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE, }, } ```
2022-02-06Rollup merge of #92651 - jsha:impl-spacing, r=GuillaumeGomezMatthias Krüger-5/+2
Remove "up here" arrow on item-infos Use spacing to distinguish what is related to a given heading. This was originally introduced in #53043, in response to #51387. The arrow is a little distracting, and leads the item-info to not be aligned properly with the text below it. Demo: https://rustdoc.crud.net/jsha/impl-spacing/std/string/struct.String.html r? ``@GuillaumeGomez``
2022-02-06Rollup merge of #91939 - GKFX:feature-91866, r=cjgillotMatthias Krüger-0/+24
Clarify error on casting larger integers to char Closes #91836 with changes to E0604.md and a `span_help`.
2022-02-05Auto merge of #93539 - petrochenkov:doclink, r=camelid,michaelwoeristerbors-0/+19
rustdoc: Collect traits in scope for foreign inherent impls Inherent impls can be inlined for variety of reasons (impls of reexported types, impls available through `Deref`, impls inlined for unclear reasons like in https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480). If an impl is inlined, then doc links in its comments are resolved and we may need the set of traits that are in scope at that impl's definition point. So in this PR we simply collect traits in scope for *all* inherent impls from other crates if their `Self` type is public, which is very similar for the strategy for trait impls previously used in https://github.com/rust-lang/rust/pull/88679. Fixes https://github.com/rust-lang/rust/issues/93476 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1026520300 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480
2022-02-05Auto merge of #93597 - GuillaumeGomez:update-browser-ui-test, r=jshabors-0/+1
Update browser-ui-test version The puppeteer version update is limited because new versions has some "interesting" flaws. r? `@jsha`
2022-02-05resolve lifetimes for const generic defaultsMichael Goulet-0/+36
2022-02-05Apply noundef attribute to &T, &mut T, Box<T>, boolErik Desjardins-19/+34
This doesn't handle `char` because it's a bit awkward to distinguish it from u32 at this point in codegen. Note that for some types (like `&Struct` and `&mut Struct`), we already apply `dereferenceable`, which implies `noundef`, so the IR does not change.
2022-02-04Specify min llvm version for issue 80309 regression testsMaybe Waffle-0/+2
2022-02-04Rollup merge of #93576 - jsha:fix-rustdoc-html, r=GuillaumeGomezMatthias Krüger-98/+99
Emit more valid HTML from rustdoc Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute. We can suppress those warnings with flags to tidy, and get a run that returns 0 (success): ``` tidy -o /dev/null -quiet --drop-empty-elements no --warn-proprietary-attributes no build/x86_64-unknown-linux-gnu/doc/std/string/trait.ToString.html ``` Note: this requires the latest version of tidy-html5, built from https://github.com/htacg/tidy-html5. Older versions (including the default version on Ubuntu 21.10) think `<section>` can't occur inside `<summary>`. Demo: https://rustdoc.crud.net/jsha/fix-rustdoc-html/std/string/struct.String.html r? `@GuillaumeGomez`
2022-02-04Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, ↵Matthias Krüger-14/+14
r=wesleywiser Stabilize `-Z instrument-coverage` as `-C instrument-coverage` (Tracking issue for `instrument-coverage`: https://github.com/rust-lang/rust/issues/79121) This PR stabilizes support for instrumentation-based code coverage, previously provided via the `-Z instrument-coverage` option. (Continue supporting `-Z instrument-coverage` for compatibility for now, but show a deprecation warning for it.) Many, many people have tested this support, and there are numerous reports of it working as expected. Move the documentation from the unstable book to stable rustc documentation. Update uses and documentation to use the `-C` option. Addressing questions raised in the tracking issue: > If/when stabilized, will the compiler flag be updated to -C instrument-coverage? (If so, the -Z variant could also be supported for some time, to ease migrations for existing users and scripts.) This stabilization PR updates the option to `-C` and keeps the `-Z` variant to ease migration. > The Rust coverage implementation depends on (and automatically turns on) -Z symbol-mangling-version=v0. Will stabilizing this feature depend on stabilizing v0 symbol-mangling first? If so, what is the current status and timeline? This stabilization PR depends on https://github.com/rust-lang/rust/pull/90128 , which stabilizes `-C symbol-mangling-version=v0` (but does not change the default symbol-mangling-version). > The Rust coverage implementation implements the latest version of LLVM's Coverage Mapping Format (version 4), which forces a dependency on LLVM 11 or later. A compiler error is generated if attempting to compile with coverage, and using an older version of LLVM. Given that LLVM 13 has now been released, requiring LLVM 11 for coverage support seems like a reasonable requirement. If people don't have at least LLVM 11, nothing else breaks; they just can't use coverage support. Given that coverage support currently requires a nightly compiler and LLVM 11 or newer, allowing it on a stable compiler built with LLVM 11 or newer seems like an improvement. The [tracking issue](https://github.com/rust-lang/rust/issues/79121) and the [issue label A-code-coverage](https://github.com/rust-lang/rust/labels/A-code-coverage) link to a few open issues related to `instrument-coverage`, but none of them seem like showstoppers. All of them seem like improvements and refinements we can make after stabilization. The original `-Z instrument-coverage` support went through a compiler-team MCP at https://github.com/rust-lang/compiler-team/issues/278 . Based on that, `@pnkfelix` suggested that this needed a stabilization PR and a compiler-team FCP.
2022-02-04Add regression tests for issue 80309Maybe Waffle-0/+29
2022-02-04rustdoc: Collect traits in scope for foreign inherent implsVadim Petrochenkov-0/+19
2022-02-04Rollup merge of #93593 - JulianKnodt:master, r=oli-obkMatthias Krüger-0/+31
Fix ret > 1 bound if shadowed by const Prior to a change, it would only look at types in bounds. When it started looking for consts, shadowing type variables with a const would cause an ICE, so now defer looking at consts only if there are no types present. cc ``````@compiler-errors`````` Should Fix #93553
2022-02-04Rollup merge of #92735 - GuillaumeGomez:crate-filter-url-param, r=jshaMatthias Krüger-0/+30
Add crate filter parameter in URL Fixes #92621. r? `@jsha`
2022-02-04Add comment in GUI testGuillaume Gomez-0/+1
2022-02-03Fix some tests to use -Cinstrument-coverageWesley Wiser-3/+3
2022-02-03Add missing const stability attributesJacob Pratt-7/+9
2022-02-03Require const stability on all stable const itemsJacob Pratt-9/+27
This was supposed to be the case previously, but a missed method call meant that trait impls were not checked.
2022-02-03Add GUI test for crate filter URL parameterGuillaume Gomez-0/+30