about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-01-04Mirror metadata changes in layout sanity checkMichael Goulet-7/+45
2023-01-04layout_of: `T: Thin` implies `sizeof(&T) == sizeof(usize)`Michael Goulet-8/+28
2023-01-03Auto merge of #105752 - chenyukang:yukang/refactor-method-error, ↵bors-900/+905
r=compiler-errors Refactoring report_method_error While working on #105732, I found it's hard to follow this long function, so I tried to make it shorter. It's not easy for code reviewing, since so many lines of code changes, but only the positions are changed. Generally, I extract two sub-methods from `report_method_error`: https://github.com/rust-lang/rust/blob/397b66e77b279de5006facf87979f9ecff5c7f87/compiler/rustc_hir_typeck/src/method/suggest.rs#L117 to `note_candidates_on_method_error` And this long block: https://github.com/rust-lang/rust/blob/397b66e77b279de5006facf87979f9ecff5c7f87/compiler/rustc_hir_typeck/src/method/suggest.rs#L263 to `report_no_match_method_error`. r? `@compiler-errors`
2023-01-03Auto merge of #106409 - matthiaskrgr:rollup-b58z1hz, r=matthiaskrgrbors-9/+9
Rollup of 8 pull requests Successful merges: - #104552 (warn newer available version of the x tool) - #105681 (some fixes/improvements to mir::visit module) - #106005 (Test the borrowck behavior of if-let guards) - #106356 (clean: Remove `ctor_kind` from `VariantStruct`.) - #106365 (Grammar : Missing "is" in format specifier diagnostic) - #106388 (rustdoc: remove legacy box-sizing CSS) - #106392 (`has_overflow` only if value is *not* within limit) - #106402 (Fix dupe word typos) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-03Rollup merge of #106402 - Rageking8:fix_dupe_word_typos, r=NilstriebMatthias Krüger-3/+3
Fix dupe word typos r? `@Nilstrieb` Thanks!
2023-01-03Rollup merge of #106392 - compiler-errors:new-trait-solver-overflow, r=lcnrMatthias Krüger-1/+1
`has_overflow` only if value is *not* within limit New solver forgot a not operator, I think.
2023-01-03Rollup merge of #106365 - gimbles:patch-1, r=jyn514Matthias Krüger-1/+1
Grammar : Missing "is" in format specifier diagnostic
2023-01-03Rollup merge of #105681 - tshepang:doc-mir-visit, r=NilstriebMatthias Krüger-4/+4
some fixes/improvements to mir::visit module
2023-01-03Auto merge of #101792 - lqd:rust-lld, r=petrochenkovbors-1/+20
Only specify `--target` by default for `-Zgcc-ld=lld` on wasm On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The `--target` argument is not needed on our current targets with a vanilla config to do so, but may be in some cases ? That is, things look to be different and more subtle than suggested in https://github.com/rust-lang/rust/issues/97402#issuecomment-1147404520. Specifying this argument unconditionally currently breaks `-Zgcc-ld=lld` on the 10.7+ targets on x64 macOS. Vanilla configs on x64 and aarch64 don't seem to need it to be able to find `rust-lld`. This fixes #101653 on macOS (I've tried on x64 and aarch64: vanilla installs with the most recent command line tools available for each of the OS versions I have access to, `run-make/issue-71519` passes). I didn't expect the previous PRs to fail because of the existing tests, but CI does not actually run those tests yet, which explains the regressions. I was hoping to fix those in this PR but it's more involved (building lld is required for the tests to run, llvm/lld is not built on the test builders but on the dist builders, the dist builders don't run tests). This PR is just to unblock current users on macOS who have reported issues, but a regression could happen in the future by mistake until then. r? `@petrochenkov`
2023-01-03Auto merge of #105609 - bjorn3:shrink_rustc_dev, r=jyn514bors-2/+20
Only include metadata for non-dynamic libraries in rustc-dev The actual object code should be linked from librustc_driver.so, which is still included in rustc-dev. This saves on download time and disk usage. Fixes https://github.com/rust-lang/rust/issues/103538
2023-01-03fix dupe word typosRageking8-3/+3
2023-01-03Auto merge of #106371 - RalfJung:no-ret-position-noalias, r=nikicbors-2/+4
do not add noalias in return position `noalias` as a return attribute in LLVM indicates that the returned pointer does not alias anything else that is reachable from the caller, *including things reachable before this function call*. This is clearly not the case with a function like `fn id(Box<T>) -> Box<T>`, so we cannot use this attribute. Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/385 (including an actual miscompilation that `@comex` managed to produce).
2023-01-03Auto merge of #106386 - compiler-errors:rollup-dxjv18b, r=compiler-errorsbors-5/+56
Rollup of 8 pull requests Successful merges: - #95985 (Add PhantomData marker to Context to make Context !Send and !Sync) - #104298 (Add notes and examples about non-intuitive `PathBuf::set_extension` behavior) - #105558 (Reduce HIR debug output) - #106315 (Cleanup `mingw-tidy` docker job) - #106354 (Rustdoc-Json: Report discriminant on all kinds of enum variant.) - #106366 (Fix rustdoc ICE on bad typedef with mismatching types) - #106376 (Update books) - #106383 (Document some of the AST nodes) Failed merges: - #106356 (clean: Remove `ctor_kind` from `VariantStruct`.) r? `@ghost` `@rustbot` modify labels: rollup
2023-01-03has_overflow only if value is *not* within limitMichael Goulet-1/+1
2023-01-02Rollup merge of #106383 - Manishearth:ast-docs, r=compiler-errorsMichael Goulet-0/+15
Document some of the AST nodes Someone was confused about some of this on Zulip, added some docs We probably should make sure every last field/variant in the AST/HIR is documented at some point `@bors` rollup
2023-01-02Rollup merge of #105558 - Nilstrieb:less-spam-hir-tree, r=cjgillotMichael Goulet-5/+41
Reduce HIR debug output HIR debug output is currently very verbose, especially when used with the alternate (`#`) flag. This commit reduces the amount of noisy newlines by forcing a few small key types to stay on one line, which makes the output easier to read and scroll by. ``` $ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l 582 $ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l 932 ```
2023-01-02only specify --target by default for -Zgcc-ld=lld on wasmRémy Rakic-1/+20
On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The --target is not needed on our current targets with a vanilla config, but may be in some cases. Specifying it all the time breaks the 10.7+ targets on x64 macOS. We try to only specify it on macOS if the linker flavors are different, for possible cases of cross-compilation with `-Zgcc-ld=lld` but the expectation is that it should be passed manually when needed in these situations.
2023-01-02Auto merge of #106364 - JakobDegen:top-down-inlining, r=cjgillotbors-6/+36
Reenable limited top-down MIR inlining Reverts most of #105119 and uses an alternative strategy to prevent exponential blowup. Specifically, we allow doing top-down inlining up to depth at most five, and for at most one call site per nested body. r? `@cjgillot`
2023-01-02Document rustc_ast::FnHeader fieldsManish Goregaokar-0/+4
2023-01-02Document rustc_ast::Extern variantsManish Goregaokar-0/+11
2023-01-02Auto merge of #106307 - Nilstrieb:dynamic->static, r=cjgillotbors-114/+95
Abolish `QueryVTable` in favour of more assoc items on `QueryConfig` This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
2023-01-02Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`Nilstrieb-114/+95
This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
2023-01-02Reduce HIR debug outputNilstrieb-5/+41
HIR debug output is currently very verbose, especially when used with the alternate (`#`) flag. This commit reduces the amount of noisy newlines by forcing a few small key types to stay on one line, which makes the output easier to read and scroll by. ``` $ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l 582 $ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l 932 ```
2023-01-02do not add noalias in return positionRalf Jung-2/+4
2023-01-02Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkovbors-85/+157
Encode spans relative to the enclosing item -- enable on nightly Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default. This PR seeks to remove one of the main shortcomings of incremental: the handling of spans. Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed. Within one file: all the spans in HIR change, so typechecking had to be re-done. Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span). The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query. Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent. In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode: - the parent when the `SyntaxContext` is 0; - the `SyntaxContext` when the parent is `None`. Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans. The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required. Possible future directions: - validate that all spans are marked in HIR validation; - mark macro-expanded spans relative to the def-site and not the use-site.
2023-01-02Update format.rsGimbles-1/+1
2023-01-02Auto merge of #106284 - estebank:merge-mut-errors, r=jyn514bors-40/+112
Merge multiple mutable borrows of immutable binding errors Fix #53466.
2023-01-01Reenable limited top-down MIR inliningJakob Degen-6/+36
2023-01-01Verbose suggestionsEsteban Küber-3/+3
2023-01-01Implement fix for #67535Troy Neubauer-3/+11
2023-01-02resolve merge conflictyukang-44/+60
2023-01-02code refactor report_method_erroryukang-901/+890
2023-01-01Use the correct tracking issue for `dyn_star`Léo Lanteri Thauvin-1/+1
2023-01-01Merge multiple mutable borrows of immutable binding errorsEsteban Küber-40/+112
Fix #53466.
2022-12-31Auto merge of #106282 - Ezrashaw:merge-e0465, r=estebankbors-60/+33
refactor: merge error code `E0465` into `E0464` `E0465` is an undocumented and untested error code that is functionally identical to `E0464`. This PR merges `E0465` into `E0464`, thus documenting and testing another error code (#61137). r? `@GuillaumeGomez` (not sure if you want to review this but it's relevant to my other PRs that you have reviewed)
2022-12-31Add help for the error message when missing rustc_driverbjorn3-2/+20
2022-12-31Auto merge of #106302 - compiler-errors:terr-coerce-w-infer, r=estebankbors-0/+4
Suppress errors due to TypeError not coercing with inference variables Fixes #75331 Fixes #68507 Fixes #82323 cc `@estebank`
2022-12-31Auto merge of #106245 - estebank:mutability-suggestions, r=jyn514bors-21/+12
Use verbose suggestions for mutability errors
2022-12-31refactor: merge `E0465` into `E0464`Ezra Shaw-60/+33
2022-12-30Rollup merge of #106317 - compiler-errors:restore-the-backtraces, r=jyn514Michael Goulet-15/+23
Only deduplicate stack traces for good path bugs Fixes #106267 Restores backtraces for `bug!` and `delay_span_bug` after #106056. Only `delay_good_path_bug` needed its backtraces to be deduplicated, since it spits out the backtrace where it was created when it's being emitted. Before: ``` error: internal compiler error: /home/ubuntu/rust2/compiler/rustc_middle/src/ty/relate.rs:638:13: var types encountered in super_relate_consts: Const { ty: usize, kind: Infer(Var(_#0c)) } Const { ty: usize, kind: Param(N/#1) } note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.68.0-dev running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `<impl at /home/ubuntu/test.rs:7:1: 7:34>::trigger` #1 [typeck_item_bodies] type-checking all item bodies #2 [analysis] running analysis passes on this crate end of query stack error: aborting due to 2 previous errors ``` Hmm... that's a little bare. After: ``` error: internal compiler error: /home/ubuntu/rust2/compiler/rustc_middle/src/ty/relate.rs:638:13: var types encountered in super_relate_consts: Const { ty: usize, kind: Infer(Var(_#0c)) } Const { ty: usize, kind: Param(N/#1) } thread 'rustc' panicked at 'Box<dyn Any>', /home/ubuntu/rust2/compiler/rustc_errors/src/lib.rs:1599:9 stack backtrace: 0: 0x7ffb5b41bdd1 - std::backtrace_rs::backtrace::libunwind::trace::h26056f81198c6594 at /home/ubuntu/rust2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7ffb5b41bdd1 - std::backtrace_rs::backtrace::trace_unsynchronized::hacfb345a0c6d5bb1 at /home/ubuntu/rust2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7ffb5b41bdd1 - std::sys_common::backtrace::_print_fmt::h18ea6016ac8030f3 at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7ffb5b41bdd1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he35dde201d0c2d09 at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7ffb5b4a0308 - core::fmt::write::h094ad263467a053c at /home/ubuntu/rust2/library/core/src/fmt/mod.rs:1208:17 5: 0x7ffb5b43caf1 - std::io::Write::write_fmt::hd47b4e2324b4d9b7 at /home/ubuntu/rust2/library/std/src/io/mod.rs:1682:15 6: 0x7ffb5b41bbfa - std::sys_common::backtrace::_print::h43044162653a17fc at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:47:5 7: 0x7ffb5b41bbfa - std::sys_common::backtrace::print::hc8605da258fa5aeb at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:34:9 8: 0x7ffb5b3ffb87 - std::panicking::default_hook::{{closure}}::h9e37f23f75122a15 9: 0x7ffb5b3ff97b - std::panicking::default_hook::h602873a063f84da2 at /home/ubuntu/rust2/library/std/src/panicking.rs:286:9 10: 0x7ffb5be192b2 - <alloc[48d7b30605060536]::boxed::Box<dyn for<'a, 'b> core[672e3947e150d6c6]::ops::function::Fn<(&'a core[672e3947e150d6c6]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[672e3947e150d6c6]::marker::Send + core[672e3947e150d6c6]::marker::Sync> as core[672e3947e150d6c6]::ops::function::Fn<(&core[672e3947e150d6c6]::panic::panic_info::PanicInfo,)>>::call at /home/ubuntu/rust2/library/alloc/src/boxed.rs:2002:9 11: 0x7ffb5be192b2 - rustc_driver[f5b6d32d8905ecdd]::DEFAULT_HOOK::{closure#0}::{closure#0} at /home/ubuntu/rust2/compiler/rustc_driver/src/lib.rs:1204:17 12: 0x7ffb5b4000d3 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfd13333ca953ae8e at /home/ubuntu/rust2/library/alloc/src/boxed.rs:2002:9 13: 0x7ffb5b4000d3 - std::panicking::rust_panic_with_hook::h45753e10264ebe7e at /home/ubuntu/rust2/library/std/src/panicking.rs:692:13 14: 0x7ffb5e8b3a63 - std[3330b4673efabfce]::panicking::begin_panic::<rustc_errors[1b15f4e7e49d1fd5]::ExplicitBug>::{closure#0} [... FRAMES INTENTIONALLY OMITTED BECAUSE GITHUB GOT ANGRY ...] 186: 0x7ffb5bea5554 - <std[3330b4673efabfce]::thread::Builder>::spawn_unchecked_::<rustc_interface[947706ead88047d0]::util::run_in_thread_pool_with_globals<rustc_interface[947706ead88047d0]::interface::run_compiler<core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>, rustc_driver[f5b6d32d8905ecdd]::run_compiler::{closure#1}>::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#1} at /home/ubuntu/rust2/library/std/src/thread/mod.rs:549:30 187: 0x7ffb5bea5554 - <<std[3330b4673efabfce]::thread::Builder>::spawn_unchecked_<rustc_interface[947706ead88047d0]::util::run_in_thread_pool_with_globals<rustc_interface[947706ead88047d0]::interface::run_compiler<core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>, rustc_driver[f5b6d32d8905ecdd]::run_compiler::{closure#1}>::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#1} as core[672e3947e150d6c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} at /home/ubuntu/rust2/library/core/src/ops/function.rs:250:5 188: 0x7ffb5b433968 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he8b26fc22c6f51ec at /home/ubuntu/rust2/library/alloc/src/boxed.rs:1988:9 189: 0x7ffb5b433968 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5cf9cbe75a8c3ddc at /home/ubuntu/rust2/library/alloc/src/boxed.rs:1988:9 190: 0x7ffb5b41199c - std::sys::unix::thread::Thread::new::thread_start::h2d6dd4455e97d031 at /home/ubuntu/rust2/library/std/src/sys/unix/thread.rs:108:17 191: 0x7ffb5441b609 - start_thread 192: 0x7ffb5b282133 - clone 193: 0x0 - <unknown> note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.68.0-dev running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `<impl at /home/ubuntu/test.rs:7:1: 7:34>::trigger` #1 [typeck_item_bodies] type-checking all item bodies #2 [analysis] running analysis passes on this crate end of query stack error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0601`. ```
2022-12-30Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726Michael Goulet-69/+0
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint" This is a clean revert of #105484. I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** https://github.com/rust-lang/rust/issues/106247#issuecomment-1367174384 has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe. FYI `@nbdd0121` `@compiler-errors`
2022-12-30Rollup merge of #106232 - maurer:transparent-subst, r=rcvalleMichael Goulet-1/+4
CFI: Monomorphize transparent ADTs before typeid Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String. `#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution. Fixes #106230
2022-12-31Only deduplicate stack traces for good path bugsMichael Goulet-15/+23
2022-12-30Suppress errors due to TypeError not coercing with inference variablesMichael Goulet-0/+4
2022-12-30Auto merge of #106268 - kraktus:patch-2, r=Nilstriebbors-1/+1
fix comment for `TokenCursor::desugar` the hashes of the text were forgotten.
2022-12-30Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, ↵bors-7/+27
r=compiler-errors Allow trait method paths to satisfy const Fn bounds r? `@oli-obk`
2022-12-29Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgrbors-12/+198
Rollup of 9 pull requests Successful merges: - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params) - #105899 (`./x doc library --open` opens `std`) - #106190 (Account for multiple multiline spans with empty padding) - #106202 (Trim more paths in obligation types) - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing) - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`) - #106259 (Update Clippy) - #106260 (Fix index out of bounds issues in rustdoc) - #106263 (Formatter should not try to format non-Rust files) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-29fix comment for `TokenCursor::desugar`kraktus-1/+1
the hashes of the text were forgotten.
2022-12-29CFI: Monomorphize transparent ADTs before typeidMatthew Maurer-1/+4
Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String. `#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution. Fixes #106230
2022-12-29Rollup merge of #106236 - Ezrashaw:add-test+docs-e0519-e0514, r=GuillaumeGomezMatthias Krüger-2/+75
docs/test: add docs and a UI test for `E0514` and `E0519` No UI test on `E0514`, it would need to compile with a different `rustc` version. r? `@GuillaumeGomez`