about summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2020-06-24review comments: clean up codeEsteban Küber-1/+1
* deduplicate logic * fix typos * remove unnecessary state
2020-06-24lints: add `improper_ctypes_definitions`David Wood-0/+6
This commit adds a new lint - `improper_ctypes_definitions` - which functions identically to `improper_ctypes`, but on `extern "C" fn` definitions (as opposed to `improper_ctypes`'s `extern "C" {}` declarations). Signed-off-by: David Wood <david@davidtw.co>
2020-06-23Tweak binop errorsEsteban Küber-1/+7
* Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-23Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, ↵Manish Goregaokar-6/+16
r=ecstatic-morse Point at the call span when overflow occurs during monomorphization This improves the output for issue #72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-4/+2
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-23Rollup merge of #72493 - nikomatsakis:move-leak-check, r=matthewjasperManish Goregaokar-50/+39
move leak-check to during coherence, candidate eval Implementation of MCP https://github.com/rust-lang/compiler-team/issues/295. I'd like to do a crater run on this. Note to @rust-lang/lang: This PR is a breaking change (bugfix). It causes tests like the following to go from a future-compatibility warning #56105 to a hard error: ```rust trait Trait {} impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {} impl Trait for for<'c> fn(&'c u32, &'c u32) {} // now rejected, used to warn ``` I am not aware of any instances of this code in the wild, but that is why we are doing a crater run. The reason for this change is that those two types are, in fact, the same type, and hence the two impls are overlapping. There will still be impls that trigger #56105 after this lands, however -- I hope that we will eventually just accept those impls without warning, for the most part. One example of such an impl is this pattern, which is used by wasm-bindgen and other crates as well: ```rust trait Trait {} impl<T> Trait for fn(&T) { } impl<T> Trait for fn(T) { } // still accepted, but warns ```
2020-06-22fix subtle bug in NLL type checkerNiko Matsakis-0/+8
The bug was revealed by the behavior of the old-lub-glb-hr-noteq1.rs test. The old-lub-glb-hr-noteq2 test shows the current 'order dependent' behavior of coercions around higher-ranked functions, at least when running with `-Zborrowck=mir`. Also, run compare-mode=nll.
2020-06-22remove snapshot calls from "match" operations during selectNiko Matsakis-0/+2
Motivation: - we want to use leak-check sparingly, first off - these calls were essentially the same as doing the check during subtyping
2020-06-22Point at the call spawn when overflow occurs during monomorphizationAaron Hill-6/+16
This improves the output for issue #72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-39/+6
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-22move leak-check to during coherence, candidate evalNiko Matsakis-50/+29
In particular, it no longer occurs during the subtyping check. This is important for enabling lazy normalization, because the subtyping check will be producing sub-obligations that could affect its results. Consider an example like for<'a> fn(<&'a as Mirror>::Item) = fn(&'b u8) where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a new subobligation like <'!1 as Mirror>::Item = &'b u8 This will, after being solved, ultimately yield a constraint that `'!1 = 'b` which will fail. But with the leak-check being performed on subtyping, there is no opportunity to normalize `<'!1 as Mirror>::Item` (unless we invoke that normalization directly from within subtyping, and I would prefer that subtyping and unification are distinct operations rather than part of the trait solving stack). The reason to keep the leak check during coherence and trait evaluation is partly for backwards compatibility. The coherence change permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait evaluation change means that we can distinguish those two cases without ambiguity errors. It also avoids recreating #57639, where we were incorrectly choosing a where clause that would have failed the leak check over the impl which succeeds. The other reason to keep the leak check in those places is that I think it is actually close to the model we want. To the point, I think the trait solver ought to have the job of "breaking down" higher-ranked region obligation like ``!1: '2` into into region obligations that operate on things in the root universe, at which point they should be handed off to polonius. The leak check isn't *really* doing that -- these obligations are still handed to the region solver to process -- but if/when we do adopt that model, the decision to pass/fail would be happening in roughly this part of the code. This change had somewhat more side-effects than I anticipated. It seems like there are cases where the leak-check was not being enforced during method proving and trait selection. I haven't quite tracked this down but I think it ought to be documented, so that we know what precisely we are committing to. One surprising test was `issue-30786.rs`. The behavior there seems a bit "fishy" to me, but the problem is not related to the leak check change as far as I can tell, but more to do with the closure signature inference code and perhaps the associated type projection, which together seem to be conspiring to produce an unexpected signature. Nonetheless, it is an example of where changing the leak-check can have some unexpected consequences: we're now failing to resolve a method earlier than we were, which suggests we might change some method resolutions that would have been ambiguous to be successful. TODO: * figure out remainig test failures * add new coherence tests for the patterns we ARE disallowing
2020-06-22Revert "modify leak-check to track only outgoing edges from placeholders"Niko Matsakis-42/+24
This reverts commit 2e01db4b396a1e161f7a73933fff34bc9421dba0.
2020-06-22modify leak-check to track only outgoing edges from placeholdersNiko Matsakis-24/+42
Also, update the affected tests. This seems strictly better but it is actually more permissive than I initially intended. In particular it accepts this ``` forall<'a, 'b> { exists<'intersection> { 'a: 'intersection, 'b: 'intersection, } } ``` and I'm not sure I want to accept that. It implies that we have a `'empty` in the new universe intoduced by the `forall`.
2020-06-22Rollup merge of #73502 - GuillaumeGomez:add-e0764, r=estebankDylan DPC-1/+2
Add E0765
2020-06-22Rollup merge of #72623 - da-x:use-suggest-public-path, r=petrochenkovDylan DPC-20/+42
Prefer accessible paths in 'use' suggestions This PR addresses issue https://github.com/rust-lang/rust/issues/26454, where `use` suggestions are made for paths that don't work. For example: ```rust mod foo { mod bar { struct X; } } fn main() { X; } // suggests `use foo::bar::X;` ```
2020-06-21Prefer accessible paths in 'use' suggestionsDan Aloni-20/+42
This fixes an issue with the following sample: mod foo { mod inaccessible { pub struct X; } pub mod avail { pub struct X; } } fn main() { X; } Instead of suggesting both `use crate::foo::inaccessible::X;` and `use crate::foo::avail::X;`, it should only suggest the latter. It is done by trimming the list of suggestions from inaccessible paths if accessible paths are present. Visibility is checked with `is_accessible_from` now instead of being hard-coded. - Some tests fixes are trivial, and others require a bit more explaining, here are my comments: src/test/ui/issues/issue-35675.stderr: Only needs to make the enum public to have the suggestion make sense. src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't help because its constructor is not visible, so the attempted constructor does not work. In that case, it's better not to suggest it. The case where the constructor is public is covered in `issue-26545.rs`.
2020-06-21Update UI testsGuillaume Gomez-1/+2
2020-06-21Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisabors-0/+44
Add a lint to catch clashing `extern` fn declarations. Closes #69390. Adds lint `clashing_extern_decl` to detect when, within a single crate, an extern function of the same name is declared with different types. Because two symbols of the same name cannot be resolved to two different functions at link time, and one function cannot possibly have two types, a clashing extern declaration is almost certainly a mistake. This lint does not run between crates because a project may have dependencies which both rely on the same extern function, but declare it in a different (but valid) way. For example, they may both declare an opaque type for one or more of the arguments (which would end up distinct types), or use types that are valid conversions in the language the extern fn is defined in. In these cases, we can't say that the clashing declaration is incorrect. r? @eddyb
2020-06-20Move bounds on associated types to the typeMatthew Jasper-5/+5
Given `trait X { type U; }` the bound `<Self as X>::U` now lives on the type, rather than the trait. This is feature gated on `feature(generic_associated_types)` for now until more testing can be done. The also enabled type-generic associated types since we no longer need "implies bounds".
2020-06-20Check associated type satisfy their boundsMatthew Jasper-2/+12
This was currently only happening due to eager normalization, which isn't possible if there's specialization or bound variables.
2020-06-20Refer just to the issue in the raw ptr cmp diagnostic instead of explaining ↵Oliver Scherer-4/+2
everything in the diagnostic
2020-06-20Update existing test cases.jumbatm-0/+44
- Allow ClashingExternDecl for lint-dead-code-3 - Update test case for #5791 - Update test case for #1866 - Update extern-abi-from-macro test case
2020-06-19Rollup merge of #73452 - matthewjasper:auto-rec, r=nikomatsakisManish Goregaokar-60/+0
Unify region variables when projecting associated types This is required to avoid cycles when evaluating auto trait predicates. Notably, this is required to be able add Chalk types to `CtxtInterners` for `cfg(parallel_compiler)`. r? @nikomatsakis
2020-06-19Rollup merge of #73027 - doctorn:issue-72690, r=estebankManish Goregaokar-6/+161
Make `need_type_info_err` more conservative Makes sure arg patterns we are going to suggest on are actually contained within the span of the obligation that caused the inference error (credit to @lcnr for suggesting this fix). There's a subtle trade-off regarding the handling of local patterns which I've left a comment about. Resolves #72690
2020-06-19Rollup merge of #72934 - christianpoveda:mut-borrows-in-consts, r=oli-obkManish Goregaokar-20/+11
forbid mutable references in all constant contexts except for const-fns PR to address #71212 cc: @ecstatic-morse
2020-06-19Rollup merge of #71420 - RalfJung:specialization-incomplete, r=matthewjasperManish Goregaokar-1/+36
Specialization is unsound As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound. I also expanded the "incomplete feature" warning to link the user to the tracking issue.
2020-06-19add new error codeChristian Poveda-7/+7
2020-06-19update diagnostics for &mut in constantsChristian Poveda-21/+12
2020-06-19Rollup merge of #73300 - crlf0710:crate_level_only_check, r=petrochenkovManish Goregaokar-1/+1
Implement crate-level-only lints checking. This implements a crate_level_only flag on lints, and when it is true, it becomes an error when user tries to specify this flag upon nodes other than crate node. This also turns on this flag for all non_ascii_ident lints.
2020-06-19Rollup merge of #73261 - estebank:generics-sized, r=nikomatsakisManish Goregaokar-0/+18
Suggest `?Sized` when applicable for ADTs Address #71790, fix #27964.
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-2/+3
2020-06-19Remove the const_raw_ptr_comparison feature gate.Oliver Scherer-5/+4
We can never supply a meaningful implementation of this. Instead, the follow up commits will create two intrinsics that approximate comparisons: * `ptr_maybe_eq` * `ptr_maybe_ne` The fact that `ptr_maybe_eq(a, b)` is not necessarily the same value as `!ptr_maybe_ne(a, b)` is a symptom of this entire problem.
2020-06-18Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwcoManish Goregaokar-30/+26
Tweak "non-primitive cast" error - Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-18Perform obligation deduplication to avoid buggy `ExistentialMismatch`Esteban Küber-0/+26
Fix #59326.
2020-06-18Implement crate level only lints checking.Charles Lew-1/+1
2020-06-17Unify region variables when projecting associated typesmatthewjasper-60/+0
This is required to avoid cycles when evaluating auto trait predicates.
2020-06-16Provide `help` when `T: ?Sized` can't be suggestedEsteban Küber-0/+14
2020-06-16bless allRalf Jung-1/+36
2020-06-15Account for derived obligations to suggest `?Sized` boundEsteban Küber-0/+4
Fix #27964.
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-2/+2
2020-06-15Register new eror codeEsteban Küber-0/+1
2020-06-15review comments: wordingEsteban Küber-2/+2
2020-06-15Tweak wording and add error codeEsteban Küber-4/+4
2020-06-15Tweak output for overlapping required/captured spansEsteban Küber-6/+1
2020-06-15Move overlapping span to a noteEsteban Küber-4/+6
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-2/+2
2020-06-15When `'static` is explicit, suggest constraining argument with itEsteban Küber-1/+1
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-30/+26
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Auto merge of #73369 - RalfJung:rollup-hl8g9zf, r=RalfJungbors-25/+76
Rollup of 10 pull requests Successful merges: - #72707 (Use min_specialization in the remaining rustc crates) - #72740 (On recursive ADT, provide indirection structured suggestion) - #72879 (Miri: avoid tracking current location three times) - #72938 (Stabilize Option::zip) - #73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM) - #73104 (Example about explicit mutex dropping) - #73139 (Add methods to go from a nul-terminated Vec<u8> to a CString) - #73296 (Remove vestigial CI job msvc-aux.) - #73304 (Revert heterogeneous SocketAddr PartialEq impls) - #73331 (extend network support for HermitCore) Failed merges: r? @ghost
2020-06-15Rollup merge of #72740 - estebank:recursive-indirection, r=matthewjasperRalf Jung-25/+76
On recursive ADT, provide indirection structured suggestion