about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-08-15Add missing closing quoteRageking8-1/+1
fixes #100563
2022-08-13Rollup merge of #100479 - compiler-errors:argument-type-error-improvements, ↵Michael Goulet-4/+6
r=lcnr Argument type error improvements Motivated by this interesting code snippet: ```rust #[derive(Copy, Clone)] struct Wrapper<T>(T); fn foo(_: fn(i32), _: Wrapper<i32>) {} fn f(_: u32) {} fn main() { let w = Wrapper::<isize>(1isize); foo(f, w); } ``` Which currently errors like: ``` error[E0308]: arguments to this function are incorrect --> src/main.rs:10:5 | 10 | foo(f, w); | ^^^ - - expected `i32`, found `isize` | | | expected `i32`, found `u32` | = note: expected fn pointer `fn(i32)` found fn item `fn(u32) {f}` = note: expected struct `Wrapper<i32>` found struct `Wrapper<isize>` note: function defined here --> src/main.rs:4:4 | 4 | fn foo(_: fn(i32), _: Wrapper<i32>) {} | ^^^ ---------- --------------- ``` Specifically, that double `expected .. found ..` which is very difficult to correlate to the types in the arguments. Also, the fact that "expected `i32`, found `isize`" and the other argument mismatch label don't even really explain what's going on here. After this PR: ``` error[E0308]: arguments to this function are incorrect --> $DIR/two-mismatch-notes.rs:10:5 | LL | foo(f, w); | ^^^ | note: expected fn pointer, found fn item --> $DIR/two-mismatch-notes.rs:10:9 | LL | foo(f, w); | ^ = note: expected fn pointer `fn(i32)` found fn item `fn(u32) {f}` note: expected struct `Wrapper`, found a different struct `Wrapper` --> $DIR/two-mismatch-notes.rs:10:12 | LL | foo(f, w); | ^ = note: expected struct `Wrapper<i32>` found struct `Wrapper<isize>` note: function defined here --> $DIR/two-mismatch-notes.rs:4:4 | LL | fn foo(_: fn(i32), _: Wrapper<i32>) {} | ^^^ ---------- --------------- error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. ``` Yeah, it's a bit verbose, but much clearer IMO. --- Open to discussions about how this could be further improved. Motivated by `@jyn514's` [tweet](https://mobile.twitter.com/joshuayn514/status/1558042020601634816) here.
2022-08-13Rollup merge of #100446 - ↵Michael Goulet-4/+34
TaKO8Ki:suggest-removing-semicolon-after-impl-trait-items, r=compiler-errors Suggest removing a semicolon after impl/trait items fixes #99822
2022-08-13Rollup merge of #100431 - compiler-errors:enum-ctor-variant-stab, r=estebankMichael Goulet-1/+4
Enum variant ctor inherits the stability of the enum variant Fixes #100399 Fixes #100420 Context #71481 for why enum variants don't need stability
2022-08-13Rollup merge of #100367 - fmease:fix-100365, r=compiler-errorsMichael Goulet-16/+37
Suggest the path separator when a dot is used on a trait Fixes #100365. `@rustbot` label A-diagnostics r? diagnostics
2022-08-13Rollup merge of #99646 - compiler-errors:arg-mismatch-single-arg-label, ↵Michael Goulet-19/+41
r=estebank Only point out a single function parameter if we have a single arg incompatibility Fixes #99635
2022-08-13Rollup merge of #100490 - lcnr:wf-consts, r=jackh726Michael Goulet-9/+7
wf: correctly `shallow_resolve` consts `shallow_resolve` on `InferConst` is always a noop. this is mostly irrelevant as inference vars should already be resolved at most - if not all - call sites. Haven't actually looked too deeply into whether this was a problem.
2022-08-13Rollup merge of #100475 - chenyukang:fix-100461, r=fee1-deadMichael Goulet-2/+6
Give a helpful diagnostic when the next struct field has an attribute Fixes #100461
2022-08-13Rollup merge of #100438 - compiler-errors:issue-100360, r=lcnrMichael Goulet-7/+2
Erase regions better in `promote_candidate` Use `tcx.erase_regions` instead of manually walking through the substs.... this also makes the code slightly simpler :see_no_evil: Fixes #100360 Fixes #89851
2022-08-13Rollup merge of #100434 - compiler-errors:issue-100373, r=cjgillotMichael Goulet-0/+4
Fix HIR pretty printing of let else Fixes #100373 Fixes #99318 Fixes #99319
2022-08-13wf correctly shallow_resolve constslcnr-9/+7
2022-08-13Do not inline non-simple argument type errors into labelsMichael Goulet-3/+3
2022-08-13Label argument coercion errorsMichael Goulet-1/+3
2022-08-13use `span_suggestion` instead of `span_suggestion_verbose`Takayuki Maeda-1/+1
2022-08-13give a helpful diagnostic even when the next struct field has an attributeyukang-2/+6
2022-08-12Adjust cfgsMark Rousskov-70/+47
2022-08-12Auto merge of #100456 - Dylan-DPC:rollup-fn17z9f, r=Dylan-DPCbors-124/+162
Rollup of 9 pull requests Successful merges: - #100022 (Optimize thread ID generation) - #100030 (cleanup code w/ pointers in std a little) - #100229 (add -Zextra-const-ub-checks to enable more UB checking in const-eval) - #100247 (Generalize trait object generic param check to aliases.) - #100255 (Adding more verbose documentation for `std::fmt::Write`) - #100366 (errors: don't fail on broken primary translations) - #100396 (Suggest const and static for global variable) - #100409 (rustdoc: don't generate DOM element for operator) - #100443 (Add two let else regression tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-12Address nitMichael Goulet-8/+6
2022-08-12Adjust span of closure paramMichael Goulet-1/+1
2022-08-12And for closuresMichael Goulet-1/+18
2022-08-12Point out a single arg if we have a single arg incompatibilityMichael Goulet-19/+26
2022-08-12Check ctor for missing stabilityMichael Goulet-0/+3
2022-08-12enum variant ctor inherits stability of variantMichael Goulet-1/+1
2022-08-12Rollup merge of #100396 - chenyukang:fix-100394, r=petrochenkovDylan DPC-1/+6
Suggest const and static for global variable Fixing #100394
2022-08-12Rollup merge of #100366 - davidtwco:translation-never-fail, r=compiler-errorsDylan DPC-32/+51
errors: don't fail on broken primary translations If a primary bundle doesn't contain a message then the fallback bundle is used. However, if the primary bundle's message is broken (e.g. it refers to a interpolated variable that the compiler isn't providing) then this would just result in a compiler panic. While there aren't any primary bundles right now, this is the type of issue that could come up once translation is further along. r? ```@compiler-errors``` (since this comes out of a in-person discussion we had at RustConf)
2022-08-12Rollup merge of #100247 - cjgillot:verify-dyn-trait-alias-defaults, r=lcnrDylan DPC-79/+77
Generalize trait object generic param check to aliases. The current algorithm only checks that `Self` does not appear in defaults for traits. This is not sufficient for trait aliases. This PR moves the check to trait object elaboration, which sees through trait aliases. Fixes https://github.com/rust-lang/rust/issues/82927. Fixes https://github.com/rust-lang/rust/issues/84789.
2022-08-12Rollup merge of #100229 - RalfJung:extra-const-ub-checks, r=lcnrDylan DPC-12/+28
add -Zextra-const-ub-checks to enable more UB checking in const-eval Cc https://github.com/rust-lang/rust/issues/99923 r? `@oli-obk`
2022-08-12Auto merge of #100328 - davidtwco:perf-implications, r=nnethercotebors-36/+91
passes: load `defined_lib_features` query less Hopefully addresses the perf regressions from #99212 (see #99905). Re-structure the stability checks for library features to avoid calling `defined_lib_features` for any more crates than necessary for each of the implications or local feature attributes that need validation. r? `@ghost` (just checking perf at first)
2022-08-12suggest removing a semicolon after impl/trait itemsTakayuki Maeda-4/+34
2022-08-12Erase regions better in promote_candidateMichael Goulet-7/+2
2022-08-12Auto merge of #99464 - nikic:llvm-15, r=cuviperbors-1/+12
Update to LLVM 15 For preliminary testing. Some LLVM 15 compatibility fixes were applied separately in #99512. Release timeline: * LLVM 15 branched on Jul 26. * The final LLVM 15.0.0 release is scheduled for Sep 6. * Current nightly (1.65.0) is scheduled for Nov 3. Changes in this PR (apart from the LLVM update): * Pass `--set llvm.allow-old-toolchain` for many Docker images. LLVM 16 will require GCC >= 7.1, while LLVM 15 still allows older compilers with an option. Specify the option for builders still using GCC 5.4. #95026 updated some of the used toolchains, but not all. * Use the `+atomics-32` target feature for thumbv6m. * Explicitly link libatomic when cross-compiling LLVM to 32-bit target. * Explicitly disable zstd support, to avoid libzstd.so dependency. New LLVM patches ([commits](https://github.com/rust-lang/llvm-project/commits/rustc/15.0-2022-08-09)): * [rust-only] Fix ICE with GCC 5.4 (https://github.com/nikic/llvm-project/commit/15be58d7f0342b1da5af219bac8bd71d01da6dff) * [rust-only] Fix build with GCC 5.4 (https://github.com/nikic/llvm-project/commit/774edc10fa45229c2aa678f1bef8b4812dc0f76a) * ~~[rust-only] Fix build with GCC 5.2 (https://github.com/nikic/llvm-project/commit/1a6069a7bb35ace1e40d566035cbf7ed2fa3b1f7)~~ * ~~[rust-only] Fix ICE with GCC 5.2 (https://github.com/nikic/llvm-project/commit/493081f2909206e0ed55af68a4058a76c0ad7a64)~~ * ~~[rust-only] Fix build with GCC 5.2 (https://github.com/nikic/llvm-project/commit/0fc5979d738c3a1f9510fe2d62417f7d2af37817)~~ * [backported] Addition of `+atomics` target feature (https://github.com/llvm/llvm-project/commit/57bdd9892d0eba5bdd25fc44799235be7b9f5153). * [backported] Revert compiler-rt change that broke powerpc (https://github.com/llvm/llvm-project/commit/9c68b43915fc1c9c0a07e935163ae8d638d7241b) * [awaiting backport] Fix RelLookupTableConverter on gnux32 (https://github.com/nikic/llvm-project/commit/639388a05f25772fb23eea5b1045e7df83bcfaa7 / https://github.com/llvm/llvm-project/issues/57021) Tested images: dist-x86_64-linux, armhf-gnu, arm-android, dist-s390x-linux, dist-x86_64-illumos, dist-x86_64-freebsd, wasm32, dist-x86_64-musl, dist-various-1, dist-riscv64-linux, dist-mips-linux, dist-mipsel-linux, dist-powerpc-linux, dist-aarch64-linux, dist-x86_64-apple, x86_64-msvc-1, x86_64-msvc-2, dist-various-2, dist-arm-linux Tested up to the usual ipv6 error: test-various, i686-gnu, x86_64-gnu-nopt r? `@ghost`
2022-08-12Fix HIR pretty printing of let elseMichael Goulet-0/+4
2022-08-11Suggest path separator when a dot is used on a traitLeón Orell Valerian Liehr-16/+37
2022-08-11Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillotMatthias Krüger-172/+57
Simplify visitors By removing some unused arguments. r? `@cjgillot`
2022-08-11Rollup merge of #100350 - jhpratt:stringify-vis, r=cjgillotMatthias Krüger-7/+15
Stringify non-shorthand visibility correctly This makes `stringify!(pub(in crate))` evaluate to `pub(in crate)` rather than `pub(crate)`, matching the behavior before the `crate` shorthand was removed. Further, this changes `stringify!(pub(in super))` to evaluate to `pub(in super)` rather than the current `pub(super)`. If the latter is not desired (it is _technically_ breaking), it can be undone. Fixes #99981 `@rustbot` label +C-bug +regression-from-stable-to-beta +T-compiler
2022-08-11Rollup merge of #100307 - nnethercote:fix-96847, r=cjgillotMatthias Krüger-3/+1
Fix #96847 r? `@petrochenkov`
2022-08-11Rollup merge of #99500 - tmandry:fuchsia-flags, r=petrochenkovMatthias Krüger-4/+21
Fix flags when using clang as linker for Fuchsia Don't add C runtime or set dynamic linker when linking with clang for Fuchsia. Clang already does this for us.
2022-08-11Rollup merge of #99421 - Bryanskiy:android-crt-static, r=petrochenkovMatthias Krüger-1/+1
add crt-static for android
2022-08-11Rollup merge of #100398 - nnethercote:improve-Zhir-stats, r=michaelwoeristerDylan DPC-52/+253
Improve `-Zhir-stats` Add testing, improve coverage, avoid some double counting, and add more detail. r? `@michaelwoerister`
2022-08-11Rollup merge of #100391 - nnethercote:improve-size-assertions, r=lqdDylan DPC-42/+47
Improve size assertions r? `@lqd`
2022-08-11Rollup merge of #100351 - compiler-errors:diagnostic-convention, r=fee1-deadDylan DPC-59/+37
Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder` unless needed This seems to be the established convention (02ff9e0) when `DiagnosticBuilder` was first added. I am guilty of introducing some of these.
2022-08-11Rollup merge of #100232 - cjgillot:no-desugar-methodcall, r=nagisaDylan DPC-38/+44
Do not consider method call receiver as an argument in AST. Fixes https://github.com/rust-lang/rust/issues/73663
2022-08-11Rollup merge of #100192 - tmiasko:rm-duplicated-locals, r=nagisaDylan DPC-8/+0
Remove duplicated temporaries creating during box derefs elaboration Temporaries created with `MirPatch::new_temp` will be declared after patch application. Remove manually created duplicate declarations. Removing duplicates exposes another issue. Visitor elaborates terminator twice and attempts to access new, but not yet available, local declarations. Remove duplicated call to `visit_terminator`. Extracted from #99946.
2022-08-11Rollup merge of #100184 - Kixunil:stabilize_ptr_const_cast, r=m-ou-seDylan DPC-1/+0
Stabilize ptr_const_cast This stabilizes `ptr_const_cast` feature as was decided in a recent [FCP](https://github.com/rust-lang/rust/issues/92675#issuecomment-1190660233) Closes #92675
2022-08-11Rollup merge of #99110 - audunhalland:match_has_guard_from_candidate, r=pnkfelixDylan DPC-1/+1
Determine match_has_guard from candidates instead of looking up thir table again Currently looking through mir build of matches because of interest in deref patterns. Finding some micro-optimizable things.
2022-08-11Rollup merge of #92744 - lambinoo:I-91161-non-exhaustive-foreign-variants, ↵Dylan DPC-1/+22
r=scottmcm Check if enum from foreign crate has any non exhaustive variants when attempting a cast Fixes #91161 As stated in the issue, this will require a crater run as it might break other people's stuff.
2022-08-11suggest const or static for global variablechenyukang-1/+6
2022-08-11Avoid lowering a `MacArgs::Eq` twice.Nicholas Nethercote-3/+1
Fixes #96847.
2022-08-11Auto merge of #100315 - compiler-errors:norm-ct-in-proj, r=lcnrbors-3/+20
Keep going if normalized projection has unevaluated consts in `QueryNormalizer` #100312 was the wrong approach, I think this is the right one. When normalizing a type, if we see that it's a projection, we currently defer to `tcx.normalize_projection_ty`, which normalizes the projections away but doesn't touch the unevaluated constants. So now we just continue to fold the type if it has unevaluated constants so we make sure to evaluate those too, if we can. Fixes #100217 Fixes #83972 Fixes #84669 Fixes #86710 Fixes #82268 Fixes #73298
2022-08-11Add a second level to the AST size reporting.Nicholas Nethercote-34/+184
This tells you which variants of the enums are most common, which is very useful. I've only done it for the AST for now, HIR can be done later.