about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-10-01Don't lose binders when printing trait bound suggestionjackh726-0/+32
2021-10-01Normalize after substituting via `field.ty()`Nadrieril-22/+56
2021-10-01Rollup merge of #89340 - FabianWolff:issue-89173, r=petrochenkovManish Goregaokar-0/+32
Improve error message for `printf`-style format strings Fixes #89173. The following is actually supported today: ```rust fn main() { let num = 5; let width = 20; print!("%*2$x", num, width); } ``` ``` error: multiple unused formatting arguments --> src/main.rs:4:21 | 4 | print!("%*2$x", num, width); | ------- ^^^ ^^^^^ argument never used | || | | || argument never used | |help: format specifiers use curly braces: `{:1$x}` | multiple missing formatting specifiers | = note: printf formatting not supported; see the documentation for `std::fmt` ``` However, as noted in #89173, something like ```rust print!("%0*x", width, num); ``` does not give a helpful suggestion. I think this is partly intended, because there actually _is_ no Rust equivalent to this; you always have to use a positional or named argument to specify the width (instead of just using the "next" argument, as `printf` or even `.*` as a precision specifier in Rust would). Therefore, I have added a note: ``` [...] note: format specifiers use curly braces, and you have to use a positional or named parameter for the width --> t2.rs:4:13 | 4 | print!("%0*x", width, num); | ^^^^ = note: printf formatting not supported; see the documentation for `std::fmt` ``` This is not perfect, but it should at least point the user in the right direction, instead of issuing no explanation at all. cc ```@lcnr```
2021-10-01Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebankManish Goregaokar-0/+137
feat(rustc_parse): recover from pre-RFC-2000 const generics syntax Fixes #89013
2021-10-01Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkovManish Goregaokar-0/+111
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461
2021-09-30Rollup merge of #89412 - lqd:zvariant-repro, r=Aaron1011Manish Goregaokar-0/+71
Add regression test for issues #88969 and #89119 This adds a regression test to complete https://github.com/rust-lang/rust/pull/89125, and thus for issues #88969 and #89119, which needed a test. Used with multiple crates, [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f665e7e882059157e0f86cfb09c47187) minimized from `zvariant-2.8.0` reproduces the error on `nightly-2021-09-19`. The test in this PR fails on master if the commit 6dbb9d4eee0a2789a74bb2d4b8228626f7cd741c from #89125 is reverted, and passes otherwise since it's now fixed. r? `@Aaron1011`
2021-09-30Rollup merge of #89344 - jackh726:maybe-bound-eror, r=cjgillotManish Goregaokar-10/+10
Cleanup lower_generics_mut and make span be the bound itself Closes #86298 (supersedes those changes) r? `@cjgillot` since you reviewed the other PR (Used wrong branch for #89338)
2021-09-30Rollup merge of #89327 - oli-obk:nll_diag_infer_vars, r=wesleywiserManish Goregaokar-2/+10
Pick one possible lifetime in case there are multiple choices In case a lifetime variable is created, but doesn't have an obvious lifetime in the list of named lifetimes that it should be inferred to, just pick the first one for the diagnostic. This happens e.g. in ```rust fn foo<'a, 'b>(a: Struct<'a>, b: Struct<'b>) -> impl Trait<'a, 'b> { if bar() { a } else { b } } ``` where we get a lifetime variable that combines the lifetimes of `a` and `b` creating a lifetime that is the intersection of both. Right now the type system cannot express this and thus we get an error, but that error also can't express this. I can also create an entirely new diagnostic that mentions all involved lifetimes, so it would actually mention `'a` and `'b` instead of just `'b`.
2021-09-30Rollup merge of #89321 - tmiasko:rebase-resume-arg, r=estebankManish Goregaokar-3/+9
Rebase resume argument projections during state transform When remapping a resume argument with projections rebase them on top of the new base. The case where resume argument has projections is unusual, but might arise with box syntax where the assignment is performed directly into the box without an intermediate temporary. Fixes #85635.
2021-09-30Rollup merge of #89251 - estebank:negative-index-literals, r=davidtwcoManish Goregaokar-0/+79
Detect when negative literal indices are used and suggest appropriate code
2021-09-30Rollup merge of #88838 - FabianWolff:issue-88472, r=estebankManish Goregaokar-80/+146
Do not suggest importing inaccessible items Fixes #88472. For this example: ```rust mod a { struct Foo; } mod b { type Bar = Foo; } ``` rustc currently emits: ``` error[E0412]: cannot find type `Foo` in this scope --> test.rs:6:16 | 6 | type Bar = Foo; | ^^^ not found in this scope | help: consider importing this struct | 6 | use a::Foo; | ``` this is incorrect, as applying this suggestion leads to ``` error[E0603]: struct `Foo` is private --> test.rs:6:12 | 6 | use a::Foo; | ^^^ private struct | note: the struct `Foo` is defined here --> test.rs:2:5 | 2 | struct Foo; | ^^^^^^^^^^^ ``` With my changes, I get: ``` error[E0412]: cannot find type `Foo` in this scope --> test.rs:6:16 | 6 | type Bar = Foo; | ^^^ not found in this scope | = note: this struct exists but is inaccessible: a::Foo ``` As for the wildcard mentioned in #88472, I would argue that the warning is actually correct, since the import _is_ unused. I think the real issue is the wrong suggestion, which I have fixed here.
2021-10-01Add `pie` as another `relocation-model` valueMarcel Hlopko-0/+111
2021-10-01Auto merge of #89414 - Manishearth:rollup-hs11bcq, r=Manishearthbors-13/+249
Rollup of 8 pull requests Successful merges: - #88782 (Fix ICE when `start` lang item has wrong generics) - #89202 (Resolve infered types when complaining about unexpected call type ) - #89248 (Suggest similarly named associated items in trait impls) - #89303 (Add `#[must_not_suspend]` to some types in std) - #89306 (thread: implements available_concurrency on haiku) - #89314 (fix(lint): don't suggest refutable patterns to "fix" irrefutable bind) - #89370 (CTFE: tweak aggregate rvalue handling) - #89392 (bootstrap: Update comment in config.library.toml.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-30Rollup merge of #89314 - notriddle:notriddle/lint-fix-enum-variant-match, ↵Manish Goregaokar-0/+37
r=davidtwco fix(lint): don't suggest refutable patterns to "fix" irrefutable bind In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730 p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
2021-09-30Rollup merge of #89303 - guswynn:std_suspend, r=dtolnayManish Goregaokar-0/+38
Add `#[must_not_suspend]` to some types in std I am not sure what else should have it? `Ref`?
2021-09-30Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, ↵Manish Goregaokar-2/+130
r=estebank Suggest similarly named associated items in trait impls Fix #85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
2021-09-30Rollup merge of #89202 - estebank:infer-call-type, r=oli-obkManish Goregaokar-0/+14
Resolve infered types when complaining about unexpected call type ``` error[E0618]: expected function, found `{integer}` --> $DIR/call-block.rs:2:13 | LL | let _ = {42}(); | ^^^^-- | | | call expression requires function ``` instead of ``` error[E0618]: expected function, found `_` --> $DIR/call-block.rs:2:13 | LL | let _ = {42}(); | ^^^^-- | | | call expression requires function ```
2021-09-30Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillotManish Goregaokar-11/+30
Fix ICE when `start` lang item has wrong generics In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates. This fixes that by updating the requirement to be exactly one generic type. The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it. I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations. Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided. Fixes #79559, fixes #73584, fixes #83117 (all duplicates) Relevant to #9307 r? ````@cjgillot````
2021-10-01Auto merge of #89183 - cjgillot:noenc, r=oli-obkbors-3/+4
Move encode_metadata out of CrateStore. `rustc_metadata` is already accessible by all client crates. It does not need to be called trough a trait object.
2021-09-30[aarch64] add target feature outline-atomicsSebastian Pop-0/+16
Enable outline-atomics by default as enabled in clang by the following commit https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11 Performance improves by several orders of magnitude when using the LSE instructions instead of the ARMv8.0 compatible load/store exclusive instructions. Tested on Graviton2 aarch64-linux with x.py build && x.py install && x.py test
2021-09-30add regression test for issue 89119Rémy Rakic-0/+71
2021-09-30Elaborate predicates in min_specialization checksMatthew Jasper-0/+42
Supertraits of specialization markers could circumvent checks for min_specialization. Elaborating predicates prevents this.
2021-09-30Auto merge of #89282 - sexxi-goose:fix-88118, r=nikomatsakisbors-0/+36
2229: Consume IfLet expr When using the IfLet guard feature, we can ICE when attempting to resolve PlaceBuilders. For pattern matching, we currently don't consume the IfLet expression when "visiting" the arms leading us to not "read" all variables and hence not being able to resolve them. r? `@nikomatsakis` Closes https://github.com/rust-lang/rust/issues/88118
2021-09-30Update run-make-fulldeps.Camille GILLOT-3/+4
2021-09-30Bless tests.Camille GILLOT-15/+25
2021-09-30Auto merge of #87998 - nneonneo:master, r=oli-obkbors-0/+132
Avoid spurious "previous iteration of loop" errors Only follow backwards edges during `get_moved_indexes` if the move path is definitely initialized at loop entry. Otherwise, the error occurred prior to the loop, so we ignore the backwards edges to avoid generating misleading "value moved here, in previous iteration of loop" errors. This patch also slightly improves the analysis of inits, including `NonPanicPathOnly` initializations (which are ignored by `drop_flag_effects::for_location_inits`). This is required for the definite initialization analysis, but may also help find certain skipped reinits in rare cases. Patch passes all non-ignored src/test/ui testcases. Fixes #72649.
2021-09-30Auto merge of #86853 - usbalbin:const_try, r=oli-obkbors-0/+23
Constify ?-operator for Result and Option Try to make `?`-operator usable in `const fn` with `Result` and `Option`, see #74935 . Note that the try-operator itself was constified in #87237. TODO * [x] Add tests for const T -> T conversions * [x] cleanup commits * [x] Remove `#![allow(incomplete_features)]` * [?] Await decision in #86808 - I'm not sure * [x] Await support for parsing `~const` in bootstrapping compiler * [x] Tracking issue(s)? - #88674
2021-09-30Auto merge of #89250 - Aaron1011:keep-bound-region-names, r=estebankbors-21/+21
Don't anonymize bound region names during typeck Once this anonymization has performed, we have no way of recovering the original names during NLL borrow checking. Keeping the original names allows error messages in full NLL mode to contain the original bound region names. As a result, the typeck results may contain types that differ only in the names used for their bound regions. However, anonimization of bound regions does not guarantee that all distinct types are unqual (e.g. not subtypes of each other). For example, `for<'a> fn(&'a u32, &'a u32)` and `for<'b, 'c> fn(&'b u32, &'c u32)` are subtypes of each other, as explained here: https://github.com/rust-lang/rust/blob/63cc2bb3d07d6c726dfcdc5f95cbe5ed4760641a/compiler/rustc_infer/src/infer/nll_relate/mod.rs#L682-L690 Therefore, any code handling types with higher-ranked regions already needs to handle the case where two distinct `Ty`s are 'actually' equal.
2021-09-30Auto merge of #89386 - ehuss:rollup-idf4dmj, r=ehussbors-27/+84
Rollup of 13 pull requests Successful merges: - #87428 (Fix union keyword highlighting in rustdoc HTML sources) - #88412 (Remove ignore-tidy-undocumented-unsafe from core::slice::sort) - #89098 (Fix generics where bounds order) - #89232 (Improve help for recursion limit errors) - #89294 (:arrow_up: rust-analyzer) - #89297 (Remove Never variant from clean::Type enum) - #89311 (Add unit assignment to MIR for `asm!()`) - #89313 (PassWrapper: handle function rename from upstream D36850) - #89315 (Clarify that `CString::from_vec_unchecked` appends 0 byte.) - #89335 (Optimize is_sorted for Range and RangeInclusive) - #89366 (rustdoc: Remove lazy_static dependency) - #89377 (Update cargo) - #89378 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-29Rollup merge of #89311 - FabianWolff:issue-89305, r=oli-obkEric Huss-0/+29
Add unit assignment to MIR for `asm!()` Fixes #89305. `ExprKind::LlvmInlineAsm` gets a `push_assign_unit()` here: https://github.com/rust-lang/rust/blob/2b6ed3b675475abc01ce7e68bb75b457f0c85684/compiler/rustc_mir_build/src/build/expr/into.rs#L475-L479 The same should probably happen for `ExprKind::InlineAsm`, which fixes the "use of possibly-uninitialized variable" error described in #89305.
2021-09-29Rollup merge of #89232 - rossmacarthur:fix-76424, r=wesleywiserEric Huss-27/+55
Improve help for recursion limit errors - Tweak help message and suggested limit (handle `0` case). - Add test for #75602 (it was already fixed, maybe can be resolved too). Fixes #76424
2021-09-30Auto merge of #89110 - Aaron1011:adjustment-span, r=estebankbors-581/+426
Use larger span for adjustment THIR expressions Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions. These spans are recoded when we first create the adjustment during typecheck. For example, an autoref adjustment triggered by a method call will record the span of the entire method call. The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-29Additional tests (from jackh726)Audun Halland-0/+23
2021-09-29Cleanup lower_generics_mut and make span be the bound itself, not the typejackh726-10/+10
2021-09-29fix(lint): don't suggest refutable patterns to "fix" irrefutable bindMichael Howell-0/+37
In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730
2021-09-29Don't ignore impls for primitive typesHirochika Matsumoto-0/+14
2021-09-29Auto merge of #89331 - GuillaumeGomez:rollup-b10unye, r=GuillaumeGomezbors-19/+60
Rollup of 8 pull requests Successful merges: - #87260 (Libgccjit codegen) - #89212 (x.py: run `rustup toolchain link` in setup) - #89233 (Hide `<...> defined here` note if the source is not available) - #89235 (make junit output more consistent with default format) - #89255 (Fix incorrect disambiguation suggestion for associated items) - #89276 (Fix the population of the `union.impls` field) - #89283 (Add regression test for issue #83564) - #89318 (rustc_session: Remove lint store from `Session`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-28ref/refmutGus Wynn-1/+1
2021-09-29Auto merge of #88950 - Nadrieril:deconstruct-pat, r=oli-obkbors-17/+99
Add an intermediate representation to exhaustiveness checking The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start. I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
2021-09-29Improve error message for `printf`-style format stringsFabian Wolff-0/+32
2021-09-28feat(rustc_typeck): avoid erroring with "wrong number of generics" if ↵Michael Howell-42/+6
there's other problems As shown in the two test requirements that got updated, if there's other problems, then those other problems are probably the root cause of the incorrect generics count.
2021-09-29Deriving: Include bound generic params for extracted type parameters in ↵Audun Halland-0/+14
where clause
2021-09-28Improve help for recursion limit errorsRoss MacArthur-27/+55
2021-09-28Improve error messages for bad type constraintsMichael Howell-19/+14
Co-authored-by: Esteban Kuber <esteban@kuber.com.ar>
2021-09-28Rollup merge of #89283 - camelid:issue-83564-test, r=davidtwcoGuillaume Gomez-0/+26
Add regression test for issue #83564 cc #83564 r? ``@davidtwco``
2021-09-28Rollup merge of #89276 - Urgau:fix-union-impls, r=GuillaumeGomezGuillaume Gomez-0/+15
Fix the population of the `union.impls` field This pull-request fix the population of the `union.impls` field that was forgot when the `Union` type was introduce as a split from the `Struct` type https://github.com/rust-lang/rust/pull/81500. ``@rustbot`` label +T-rustdoc +A-rustdoc-json
2021-09-28Rollup merge of #89255 - FabianWolff:issue-88806, r=cjgillotGuillaume Gomez-19/+19
Fix incorrect disambiguation suggestion for associated items Fixes #88806. I have not added a new test case, because the erroneous behavior is already present in existing test cases.
2021-09-28Use less verbose syntax for error annotationsMichael Howell-4/+4
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-09-28Pick one possible lifetime in case there are multiple choicesOli Scherer-2/+10
2021-09-28review commentsEsteban Kuber-3/+3