summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2021-06-19Revert "Allow specifying alignment for functions"Mark Rousskov-8/+14
This reverts commit 448d07683a6defd567996114793a09c9a8aef5df.
2021-06-05Remove `_` from E0121 diagnostic suggestionsDeadbeef-1/+1
2021-05-28Auto merge of #85607 - LeSeulArtichaut:thir-unsafeck-closures, r=nikomatsakisbors-4/+47
Make closures inherit their parent's "safety context" Fixes rust-lang/project-thir-unsafeck#9, ~~blocked on #85273~~. r? `@nikomatsakis`
2021-05-28Auto merge of #84968 - FabianWolff:master, r=estebankbors-3/+8
Fix incorrect suggestions for E0605 Fixes #84598. Here is a simplified version of the problem presented in issue #84598: ```Rust #![allow(unused_variables)] #![allow(dead_code)] trait T { fn t(&self) -> i32; } unsafe fn foo(t: *mut dyn T) { (t as &dyn T).t(); } fn main() {} ``` The current output is: ``` error[E0605]: non-primitive cast: `*mut (dyn T + 'static)` as `&dyn T` --> src/main.rs:7:5 | 7 | (t as &dyn T).t(); | ^^^^^^^^^^^^^ invalid cast | help: borrow the value for the cast to be valid | 7 | (&t as &dyn T).t(); | ^ ``` This is incorrect, though: The cast will _not_ be valid when writing `&t` instead of `t`: ``` error[E0277]: the trait bound `*mut (dyn T + 'static): T` is not satisfied --> t4.rs:7:6 | 7 | (&t as &dyn T).t(); | ^^ the trait `T` is not implemented for `*mut (dyn T + 'static)` | = note: required for the cast to the object type `dyn T` ``` The correct suggestion is `&*t`, which I have implemented in this pull request. Of course, this suggestion will always require an unsafe block, but arguably, that's what the user really wants if they're trying to cast a pointer to a reference. In any case, claiming that the cast will be valid after implementing the suggestion is overly optimistic, as the coercion logic doesn't seem to resolve all nested obligations, i.e. the cast may still be invalid after implementing the suggestion. I have therefore rephrased the suggestion slightly ("consider borrowing the value" instead of "borrow the value for the cast to be valid"). Additionally, I have fixed another incorrect suggestion not mentioned in #84598, which relates to casting immutable references to mutable ones: ```rust fn main() { let mut x = 0; let m = &x as &mut i32; } ``` currently leads to ``` error[E0605]: non-primitive cast: `&i32` as `&mut i32` --> t5.rs:3:13 | 3 | let m = &x as &mut i32; | ^^^^^^^^^^^^^^ invalid cast | help: borrow the value for the cast to be valid | 3 | let m = &mut &x as &mut i32; | ^^^^ ``` which is obviously incorrect: ``` error[E0596]: cannot borrow data in a `&` reference as mutable --> t5.rs:3:13 | 3 | let m = &mut &x as &mut i32; | ^^^^^^^ cannot borrow as mutable ``` I've changed the suggestion to a note explaining the problem: ``` error[E0605]: non-primitive cast: `&i32` as `&mut i32` --> t5.rs:3:13 | 3 | let m = &x as &mut i32; | ^^^^^^^^^^^^^^ invalid cast | note: this reference is immutable --> t5.rs:3:13 | 3 | let m = &x as &mut i32; | ^^ note: trying to cast to a mutable reference type --> t5.rs:3:19 | 3 | let m = &x as &mut i32; | ^^^^^^^^ ``` In this example, it would have been even nicer to suggest replacing `&x` with `&mut x`, but this would be much more complex because we would have to take apart the expression to be cast (currently, we only look at its type), and `&x` could be stored in a variable, where such a suggestion would not even be directly applicable: ```rust fn main() { let mut x = 0; let r = &x; let m = r as &mut i32; } ``` My solution covers this case, too.
2021-05-27Test THIR unsafeck for unsafe ops in closuresLeSeulArtichaut-4/+47
2021-05-27Rollup merge of #84221 - ABouttefeux:generic-arg-elision, r=estebankDylan DPC-1/+4
E0599 suggestions and elision of generic argument if no canditate is found fixes #81576 changes: In error E0599 (method not found) generic argument are eluded if the method was not found anywhere. If the method was found in another inherent implementation suggest that it was found elsewhere. Example ```rust struct Wrapper<T>(T); struct Wrapper2<T> { x: T, } impl Wrapper2<i8> { fn method(&self) {} } fn main() { let wrapper = Wrapper(i32); wrapper.method(); let wrapper2 = Wrapper2{x: i32}; wrapper2.method(); } ``` ``` Error[E0599]: no method named `method` found for struct `Wrapper<_>` in the current scope .... error[E0599]: no method named `method` found for struct `Wrapper2<i32>` in the current scope ... = note: The method was found for Wrapper2<i8>. ``` I am not very happy with the ```no method named `test` found for struct `Vec<_, _>` in the current scope```. I think it might be better to show only one generic argument `Vec<_>` if there is a default one. But I haven't yet found a way to do that,
2021-05-25show list of candidatesAliénore Bouttefeux-1/+2
2021-05-25Auto merge of #85273 - LeSeulArtichaut:thir-query, r=nikomatsakisbors-8/+8
Make building THIR a stealable query This PR creates a stealable `thir_body` query so that we can build the THIR only once for THIR unsafeck and MIR build. Blocked on #83842. r? `@nikomatsakis`
2021-05-24Replace more "NULL" with "null"LeSeulArtichaut-1/+1
2021-05-22Make the THIR unsafeck use the `thir_body` queryLeSeulArtichaut-8/+8
2021-05-22change from review and show full type if it can be derefAliénore Bouttefeux-1/+1
2021-05-21Check for use of mutable/extern statics in THIR unsafeckLeSeulArtichaut-5/+63
2021-05-21remove generic argument insead of displaying "_"Aliénore Bouttefeux-1/+1
2021-05-20Check for raw pointer dereference in THIR unsafeckLeSeulArtichaut-3/+18
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-1/+2
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-13Auto merge of #85258 - GuillaumeGomez:rollup-kzay7o5, r=GuillaumeGomezbors-5/+40
Rollup of 4 pull requests Successful merges: - #85068 (Fix diagnostic for cross crate private tuple struct constructors) - #85175 (Rustdoc cleanup) - #85177 (add BITS associated constant to core::num::Wrapping) - #85240 (Don't suggest adding `'static` lifetime to arguments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-05-13Rollup merge of #85240 - Aaron1011:no-suggest-static, r=davidtwcoGuillaume Gomez-2/+0
Don't suggest adding `'static` lifetime to arguments Fixes #69350 This is almost always the wrong this to do
2021-05-13Rollup merge of #85068 - luqmana:78708-xcrate-diag, r=estebankGuillaume Gomez-3/+40
Fix diagnostic for cross crate private tuple struct constructors Fixes #78708. There was already some limited support for certain cross-crate scenarios but that didn't handle a tuple struct rexported from an inner module for example (e.g. the NonZero* types as seen in #85049). ```Rust ➜ cat bug.rs fn main() { let _x = std::num::NonZeroU32(12); let n = std::num::NonZeroU32::new(1).unwrap(); match n { std::num::NonZeroU32(i) => {}, } } ``` **Before:** <details> ```Rust ➜ rustc +nightly bug.rs error[E0423]: expected function, tuple struct or tuple variant, found struct `std::num::NonZeroU32` --> bug.rs:2:14 | 2 | let _x = std::num::NonZeroU32(12); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `std::num::NonZeroU32 { 0: val }` | ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1 [snip] error[E0532]: expected tuple struct or tuple variant, found struct `std::num::NonZeroU32` --> bug.rs:5:9 | 5 | std::num::NonZeroU32(i) => {}, | ^^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `std::num::NonZeroU32 { 0 }` | ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1 [snip] error: aborting due to 2 previous errors Some errors have detailed explanations: E0423, E0532. For more information about an error, try `rustc --explain E0423`. ``` </details> **After:** <details> ```Rust ➜ /rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc bug.rs error[E0423]: cannot initialize a tuple struct which contains private fields --> bug.rs:2:14 | 2 | let _x = std::num::NonZeroU32(12); | ^^^^^^^^^^^^^^^^^^^^ | note: constructor is not visible here due to private fields --> /rust/library/core/src/num/nonzero.rs:148:1 [snip] error[E0532]: cannot match against a tuple struct which contains private fields --> bug.rs:5:9 | 5 | std::num::NonZeroU32(i) => {}, | ^^^^^^^^^^^^^^^^^^^^ | note: constructor is not visible here due to private fields --> bug.rs:5:30 | 5 | std::num::NonZeroU32(i) => {}, | ^ private field error: aborting due to 2 previous errors Some errors have detailed explanations: E0423, E0532. For more information about an error, try `rustc --explain E0423`. ``` </details> One question is if we should only collect the needed info for the cross-crate case after encountering an error instead of always doing it. Perf run perhaps to gauge the impact.
2021-05-13Auto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obkbors-20/+0
Remove rustc_args_required_const attribute Now that stdarch no longer needs it (thanks `@Amanieu!),` we can kill the `rustc_args_required_const` attribute. This means that lifetime extension of references to temporaries is the only remaining job that promotion is performing. :-) r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/69493
2021-05-13fix test suiteRalf Jung-20/+0
2021-05-13Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakisbors-6/+70
Introduce the beginning of a THIR unsafety checker This poses the foundations for the THIR unsafety checker, so that it can be implemented incrementally: - implements a rudimentary `Visitor` for the THIR (which will definitely need some tweaking in the future) - introduces a new `-Zthir-unsafeck` flag which tells the compiler to use THIR unsafeck instead of MIR unsafeck - implements detection of unsafe functions - adds revisions to the UI tests to test THIR unsafeck alongside MIR unsafeck This uses a very simple query design, where bodies are unsafety-checked on a body per body basis. This however has some big flaws: - the unsafety-checker builds the THIR itself, which means a lot of work is duplicated with MIR building constructing its own copy of the THIR - unsafety-checking closures is currently completely wrong: closures should take into account the "safety context" in which they are created, here we are considering that closures are always a safe context I had intended to fix these problems in follow-up PRs since they are always gated under the `-Zthir-unsafeck` flag (which is explicitely noted to be unsound). r? `@nikomatsakis` cc https://github.com/rust-lang/project-thir-unsafeck/issues/3 https://github.com/rust-lang/project-thir-unsafeck/issues/7
2021-05-12Don't suggest adding `'static` lifetime to argumentsAaron Hill-2/+0
Fixes #69350 This is almost always the wrong this to do
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-44/+44
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-11Test `-Zthir-unsafeck` for unused unsafe blocksLeSeulArtichaut-3/+26
2021-05-11Test `-Zthir-unsafeck` for unsafe function callsLeSeulArtichaut-3/+44
2021-05-11Auto merge of #82272 - b-naber:gat_diag, r=estebank,jackh726bors-26/+26
Improve diagnostics for GATs Fixes https://github.com/rust-lang/rust/issues/81801 Fixes https://github.com/rust-lang/rust/issues/81961 Fixes https://github.com/rust-lang/rust/issues/81862 r? `@estebank`
2021-05-11improve diagnosts for GATsb-naber-26/+26
2021-05-09remove const_fn feature gateRalf Jung-4/+2
2021-05-08Add tests.Luqman Aden-3/+40
2021-05-07Rollup merge of #84734 - tmandry:compiletest-needs-unwind, r=Mark-SimulacrumDylan DPC-0/+1
Add `needs-unwind` and beginning of support for testing `panic=abort` std to compiletest For the Fuchsia platform we build libstd with `panic=abort` and would like a way to run tests with that enabled. This adds low-level support for this directly to compiletest. In the future I'd like to add high-level support in rustbuild, e.g. having target-specific flags that allow configuring a panic strategy. (Side note: It would be nice if we could also build multiple configurations for the same target, but I'm getting ahead of myself.) This plus #84500 have everything that's needed to get ui tests passing on fuchsia targets. Part of #84766. Note that this change only includes the header on tests which need an unwinder to _build_, not those which need it to _run_. r? ````@Mark-Simulacrum````
2021-05-06Better rustc_on_unimplemented, and UI test fixesScott McMurray-1/+2
2021-05-06Fix up/ignore failing ui tests on fuchsiaTyler Mandry-0/+1
2021-05-06Fix incorrect suggestions for E0605Fabian Wolff-3/+8
2021-05-03Auto merge of #84842 - blkerby:null_lowercase, r=joshtriplettbors-1/+1
Replace 'NULL' with 'null' This replaces occurrences of "NULL" with "null" in docs, comments, and compiler error/lint messages. This is for the sake of consistency, as the lowercase "null" is already the dominant form in Rust. The all-caps NULL looks like the C macro (or SQL keyword), which seems out of place in a Rust context, given that NULL does not exist in the Rust language or standard library (instead having [`ptr::null()`](https://doc.rust-lang.org/stable/std/ptr/fn.null.html)).
2021-05-02Change 'NULL' to 'null'Brent Kerby-1/+1
2021-05-03Rollup merge of #84818 - ABouttefeux:enum-suggest, r=jackh726Dylan DPC-3/+12
suggestion for unit enum variant when matched with a patern resolve #84700 add suggestion for code like ```rust enum FarmAnimal { Worm, Cow, Bull, Chicken { num_eggs: usize }, Dog (String), } fn what_does_the_animal_say(animal: &FarmAnimal) { let noise = match animal { FarmAnimal::Cow(_) => "moo".to_string(), _ => todo!() }; println!("{:?} says: {:?}", animal, noise); } ``` ``` error[E0532]: expected tuple struct or tuple variant, found unit variant `FarmAnimal::Cow` --> $DIR/issue-84700.rs:15:9 | LL | Cow, | --- `FarmAnimal::Cow` defined here ... LL | FarmAnimal::Cow(_) => "moo".to_string(), | ^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FarmAnimal::Cow` ```
2021-05-03Rollup merge of #84784 - JulianKnodt:suggest_const, r=lcnrDylan DPC-0/+5
Add help message to suggest const for unused type param r? `@lcnr`
2021-05-02add suggestion for unit enum variant when matched with a paternAliénore Bouttefeux-3/+12
2021-05-01Closure capture borrow diagnostics for disjoint capturesChris Pardy-5/+5
2021-05-01Add help message for unused type paramkadmin-0/+5
2021-04-23Tweak suggestion outputEsteban Küber-0/+15
2021-04-19fix suggestion for unsized function parameterslcnr-12/+11
2021-04-18Auto merge of #83799 - crlf0710:stablize_non_ascii_idents, r=Manishearthbors-3/+1
Stablize `non-ascii-idents` This is the stablization PR for RFC 2457. Currently this is waiting on fcp in [tracking issue](https://github.com/rust-lang/rust/issues/55467). r? `@Manishearth`
2021-04-15elision of generic argument in E0599 if the methode has not been found ↵Aliénore Bouttefeux-1/+3
anywhere and sugetion of type with method when found.
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-8/+8
warn-by-default on 2015
2021-04-12Rollup merge of #84014 - estebank:cool-bears-hot-tip, r=varkorDylan DPC-13/+37
Improve trait/impl method discrepancy errors * Use more accurate spans * Clean up some code by removing previous hack * Provide structured suggestions Structured suggestions are particularly useful for cases where arbitrary self types are used, like in custom `Future`s, because the way to write `self: Pin<&mut Self>` is not necessarily self-evident when first encountered.
2021-04-09Auto merge of #81942 - the8472:reduce-ui-test-threads, r=Mark-Simulacrumbors-0/+1
reduce threads spawned by ui-tests The test harness already spawns enough tests to keep all cores busy. Individual tests should keep their own threading to a minimum to avoid context switch overhead. When running ui tests with lld enabled this shaves about 10% off that testsuite on my machine. Resolves #81946
2021-04-09reduce threads spawned by ui-testsThe8472-0/+1
the test harness already spawns enough tests for all cores, individual tests should keep their own threading to a minimum to avoid context switch overhead some tests fail with 1 CGU, so explicit compile flags have been added to keep their old behavior
2021-04-08Suggest return typeEsteban Küber-2/+8
2021-04-08Suggest changing impl parameter types to match traitEsteban Küber-7/+25
This is particularly useful for cases where arbitrary self types are used, like in custom `Future`s.