about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2022-09-04Rollup merge of #100302 - compiler-errors:deref-path-methods, r=jackh726Matthias Krüger-0/+20
Suggest associated method on deref types when path syntax method fails Fixes #100278
2022-09-03Do not call object_lifetime_default on lifetime params.Camille GILLOT-33/+71
2022-09-03Auto merge of #101378 - matthiaskrgr:rollup-s1awa47, r=matthiaskrgrbors-108/+108
Rollup of 4 pull requests Successful merges: - #101335 (rustdoc: remove old CSS selector that causes weird spacing) - #101347 (ffx component run should provide a collection) - #101364 (Shrink suggestion span of argument mismatch error) - #101365 (remove redundant clones) Failed merges: - #101349 (rustdoc: remove `.impl-items { flex-basis }` CSS, not in flex container) r? `@ghost` `@rustbot` modify labels: rollup
2022-09-03Rollup merge of #101364 - compiler-errors:arg-suggestion-spans, r=wesleywiserMatthias Krüger-108/+108
Shrink suggestion span of argument mismatch error This doesn't really help with #101242, but I wanted to put this up while I work on other fixes.
2022-09-03Auto merge of #100574 - Urgau:check-cfg-warn-cfg, r=petrochenkovbors-3/+23
Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in https://github.com/rust-lang/rust/pull/99519. r? `@petrochenkov`
2022-09-03Include enum path in variant suggestionMichael Goulet-232/+232
2022-09-03Fix global_asm macro pretty printingMichael Goulet-0/+12
2022-09-03Suggest copied or clonedMichael Goulet-0/+129
2022-09-03Suggest associated method on deref typesMichael Goulet-0/+20
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-108/+108
2022-09-03Suggest removing unnecessary prefix let in patternsMichael Goulet-0/+31
2022-09-03Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514Dylan DPC-0/+3
[drop tracking] Use parent expression for scope, not parent node Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like Foo { b: &42, a: async { 0 }.await, } the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression. We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient. Helps with #97331 r? ``@jyn514``
2022-09-03Auto merge of #100966 - compiler-errors:revert-remove-deferred-sized-checks, ↵bors-25/+218
r=pnkfelix Revert "Remove deferred sized checks" cc: https://github.com/rust-lang/rust/pull/100652#issuecomment-1225798572 I'm okay with reverting this for now, and I will look into the diagnostic regressions. This reverts commit 33212bf7f527798a8cfa2bbb38781742f4ca718a. r? `@pnkfelix` ---- EDIT: This _also_ fixes #101066, a regression in method selection logic/coercion(?) due to the early registering of a `Sized` bound.
2022-09-02Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplettbors-0/+261
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE` When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program ```rust fn main() { loop { println!("hello world"); } } ``` will print an error if used with a short-lived pipe, e.g. % ./main | head -n 1 hello world thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace by enabling `#[unix_sigpipe = "sig_dfl"]` like this ```rust #![feature(unix_sigpipe)] #[unix_sigpipe = "sig_dfl"] fn main() { loop { println!("hello world"); } } ``` there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately: % ./main | head -n 1 hello world The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`. With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`. See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obkMatthias Krüger-0/+25
Try normalizing types without RevealAll in ParamEnv in MIR validation Before, the MIR validator used RevealAll in its ParamEnv for type checking. This could cause false negatives in some cases due to RevealAll ParamEnvs not always use all predicates as expected here. Since some MIR passes like inlining use RevealAll as well, keep using it in the MIR validator too, but when it fails usign RevealAll, also try the check without it, to stop false negatives. Fixes #99866 cc ````````@compiler-errors```````` who nicely helped me on zulip
2022-09-02Add warning against unexpected --cfg with --check-cfgUrgau-3/+23
2022-09-02Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkovGuillaume Gomez-0/+174
optimization of access level table construction Refactoring which was mentioned in #87487
2022-09-02Rollup merge of #97739 - a2aaron:let_underscore, r=estebankGuillaume Gomez-0/+63
Uplift the `let_underscore` lints from clippy into rustc. This PR resolves #97241. This PR adds three lints from clippy--`let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use`, which are meant to capture likely-incorrect uses of `let _ = ...` bindings (in particular, doing this on a type with a non-trivial `Drop` causes the `Drop` to occur immediately, instead of at the end of the scope. For a type like `MutexGuard`, this effectively releases the lock immediately, which is almost certainly the wrong behavior) In porting the lints from clippy I had to copy over a bunch of utility functions from `clippy_util` that these lints also relied upon. Is that the right approach? Note that I've set the `must_use` and `drop` lints to Allow by default and set `lock` to Deny by default (this matches the same settings that clippy has). In talking with `@estebank` he informed me to do a Crater run (I am not sure what type of Crater run to request here--I think it's just "check only"?) On the linked issue, there's some discussion about using `must_use` and `Drop` together as a heuristic for when to warn--I did not implement this yet. r? `@estebank`
2022-09-01Rollup merge of #101285 - ↵Matthias Krüger-0/+26
TaKO8Ki:do-not-suggest-adding-move-when-closure-is-already-marked-as-move, r=oli-obk Do not suggest adding `move` to closure when `move` is already used Fixes #101227
2022-09-01Rollup merge of #94467 - ibraheemdev:master, r=pnkfelixMatthias Krüger-0/+56
Add `special_module_name` lint Declaring `lib` as a module is one of the most common beginner mistakes when trying to setup a binary and library target in the same crate. `special_module_name` lints against it, as well as `mod main;` ``` warning: found module declaration for main.rs --> $DIR/special_module_name.rs:4:1 | LL | mod main; | ^^^^^^^^^ | = note: a binary crate cannot be used as library warning: found module declaration for lib.rs --> $DIR/special_module_name.rs:1:1 | LL | mod lib; | ^^^^^^^^ | = note: `#[warn(special_module_name)]` on by default = note: lib.rs is the root of this crate's library target = help: to refer to it from other targets, use the library's name as the path ``` Note that the help message is not the best in that it doesn't provide an example of an import path (`the_actual_crate_name::`), and doesn't check whether the current file is part of a library/binary target to provide more specific error messages. I'm not sure where this lint would have to be run to access that information.
2022-09-01do not suggest adding `move` to closure when `move` is already usedTakayuki Maeda-0/+26
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-38/+38
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Merge remote-tracking branch 'origin/master' into ↵Matthew Kelly-3102/+5468
mpk/add-long-error-message-for-E0311
2022-08-31Rollup merge of #101161 - ldm0:ldm_fix_diagnostic, r=cjgillotMatthias Krüger-15/+45
Fix uintended diagnostic caused by `drain(..)` Calling `drain(..)` makes later `suggestable_variants.is_empty()` always true, which makes the diagnostics unintended.
2022-08-31Rollup merge of #100838 - ↵Matthias Krüger-3/+127
hkmatsumoto:move-gen-args-to-trait-when-appropriate, r=davidtwco Suggest moving redundant generic args of an assoc fn to its trait Closes #89064
2022-08-31Rollup merge of #100787 - chenyukang:fix-100770-pretty-crash, r=petrochenkovMatthias Krüger-0/+8
Pretty printing give proper error message without panic Fixes #100770
2022-08-31Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwcoRalf Jung-2/+2
Migrate rustc_monomorphize to use SessionDiagnostic ### Description - Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic` - Adds an `impl IntoDiagnosticArg for PathBuf` ### TODO / Help! - [x] I'm having trouble figuring out how to apply an optional note. 😕 Help!? - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files - [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment. - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694 - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it? - [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)? - [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-31add TestReachabilityVisitorBryanskiy-0/+174
2022-08-31Fix ci checksDezhi Wu-2/+2
2022-08-31Fix a bunch of typoDezhi Wu-36/+36
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Rollup merge of #101185 - compiler-errors:tweak-wf-locs, r=davidtwcoMatthias Krüger-30/+30
Tweak `WellFormedLoc`s a bit Gives a bit tighter spans in returns and generic ty defaults
2022-08-31Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, ↵Matthias Krüger-140/+274
r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes #101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-31Fix uintended diagnostic caused by `drain(..)`Donough Liu-15/+45
2022-08-30Stabilize GATsJack Huey-760/+306
2022-08-30[drop tracking] Use parent expression for scopeEric Holk-0/+3
Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like Foo { b: &42, a: async { 0 }.await, } the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression. We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient.
2022-08-30Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJungbors-10/+66
Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB For context: https://github.com/rust-lang/rust/issues/66151#issuecomment-1174477404= This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB. This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.
2022-08-30Rollup merge of #100941 - lyming2007:issue-100584, r=oli-obkDylan DPC-0/+59
Point at the string inside literal and mention if we need string inte… …rpolation modified: compiler/rustc_passes/src/liveness.rs
2022-08-30Rollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnrDylan DPC-0/+35
Attempt to normalize `FnDef` signature in `InferCtxt::cmp` Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv. This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright. On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup. This is stacked onto #100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed. --- The code: ```rust trait Foo { type Bar; } impl<T> Foo for T { type Bar = i32; } fn foo<T>(_: <T as Foo>::Bar) {} fn needs_i32_ref_fn(f: fn(&'static i32)) {} fn main() { needs_i32_ref_fn(foo::<()>); } ``` Before: ``` = note: expected fn pointer `fn(&'static i32)` found fn item `fn(<() as Foo>::Bar) {foo::<()>}` ``` After: ``` = note: expected fn pointer `fn(&'static i32)` found fn item `fn(i32) {foo::<()>}` ```
2022-08-30Rollup merge of #99928 - compiler-errors:issue-99914, r=oli-obkDylan DPC-0/+34
Do not leak type variables from opaque type relation The "root cause" is that we call `InferCtxt::resolve_vars_if_possible` (3d9dd681f520d1d59f38aed0056cf9474894cc74) on the types we get back in `TypeError::Sorts` since I added a call to it in `InferCtxt::same_type_modulo_infer`. However if this `TypeError` comes from a `InferCtxt::commit_if_ok`, then it may reference type variables that do not exist anymore, which is problematic. We avoid this by substituting the `TypeError` with the types we had before being generalized while handling opaques. This is kinda gross, and I feel like we can get the same issue from other places where we generalize type/const inference variables. Maybe not? I don't know. Fixes #99914 Fixes #99970 Fixes #100463
2022-08-30Rollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errorsDylan DPC-7/+7
Display raw pointer as *{mut,const} T instead of *-ptr in errors The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
2022-08-30Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPCbors-501/+661
Rollup of 9 pull requests Successful merges: - #95376 (Add `vec::Drain{,Filter}::keep_rest`) - #100092 (Fall back when relating two opaques by substs in MIR typeck) - #101019 (Suggest returning closure as `impl Fn`) - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`) - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information) - #101123 (Remove `register_attr` feature) - #101175 (Don't --bless in pre-push hook) - #101176 (rustdoc: remove unused CSS selectors for `.table-display`) - #101180 (Add another MaybeUninit array test with const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-30Tweak WellFormedLocs a bitMichael Goulet-30/+30
2022-08-30Rollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8KiDylan DPC-473/+183
Remove `register_attr` feature Closes #66080 Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-30Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obkDylan DPC-28/+311
interpret: make read-pointer-as-bytes a CTFE-only error with extra information Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456. Pointer-to-int transmutation during CTFE now produces a message like this: ``` = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported ``` r? ``@oli-obk``
2022-08-30Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726Dylan DPC-0/+62
Erase late bound regions before comparing types in `suggest_dereferences` Fixes #101020
2022-08-30Rollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillotDylan DPC-0/+40
Suggest returning closure as `impl Fn` Fixes #100936
2022-08-30Rollup merge of #100092 - compiler-errors:issue-100075, r=oli-obkDylan DPC-0/+65
Fall back when relating two opaques by substs in MIR typeck This is certainly _one_ way to fix #100075. Not really confident it's the _best_ way to do it, though. The root cause of this issue is that during MIR type-check, we end up trying to equate an opaque against the same opaque def-id but with different substs. Because of the way that we replace RPITs during (HIR) typeck with an inference variable, we don't end up emitting a type-checking error, so the delayed MIR bug causes an ICE. See the `src/test/ui/impl-trait/issue-100075-2.rs` test below to make that clear -- in that example, we try to equate `{impl Sized} substs=[T]` and `{impl Sized} substs=[Option<T>]`, which causes an ICE. This new logic will instead cause us to infer `{impl Sized} substs=[Option<T>]` as the hidden type for `{impl Sized} substs=[T]`, which causes a proper error to be emitted later on when we check that an opaque isn't recursive. I'm open to closing this in favor of something else. Ideally we'd fix this in typeck, but the thing we do to ensure backwards compatibility with weird RPIT cases makes that difficult. Also open to discussing this further.
2022-08-30Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrumbors-371/+693
Revert let_chains stabilization This is the revert against master, the beta revert was already done in #100538. Bumps the stage0 compiler which already has it reverted.
2022-08-30add UI test for unprettyyukang-0/+8
2022-08-29Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgrbors-18/+78
Rollup of 7 pull requests Successful merges: - #100898 (Do not report too many expr field candidates) - #101056 (Add the syntax of references to their documentation summary.) - #101106 (Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items) - #101131 (CTFE: exposing pointers and calling extern fn is just impossible) - #101141 (Simplify `get_trait_ref` fn used for `virtual_function_elimination`) - #101146 (Various changes to logging of borrowck-related code) - #101156 (Remove `Sync` requirement from lint pass objects) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup