about summary refs log tree commit diff
path: root/compiler/rustc_error_messages
AgeCommit message (Collapse)AuthorLines
2022-12-17Resolve various merge conflictsmejrs-2/+2
2022-12-17Migrate multiple mut borrows diagnosticTheOddGarlic-0/+6
2022-12-17Migrate borrow of moved value diagnosticTheOddGarlic-0/+6
2022-12-17Migrate irrefutable let pattern diagnosticsTheOddGarlic-0/+50
2022-12-17Migrate pattern bindings with variant name lintTheOddGarlic-0/+4
2022-12-17Migrate leading/trailing irrefutable let pattern diagnosticsTheOddGarlic-0/+26
2022-12-17Migrate lower range bound diagnosticsTheOddGarlic-0/+7
2022-12-17Migrate "could not evaluate const pattern" diagnosticTheOddGarlic-0/+2
2022-12-17Migrate "constant pattern depends on generic parameter" diagnosticTheOddGarlic-0/+3
2022-12-17Migrate unreachable pattern diagnosticTheOddGarlic-0/+4
2022-12-17Migrate pattern inlining error diagnosticsTheOddGarlic-0/+8
2022-12-17Migrate "non-exhaustive patterns: type is non-empty" diagnosticTheOddGarlic-0/+8
2022-12-17Migrate "unused unsafe" lintTheOddGarlic-0/+6
2022-12-17Migrate "requires unsafe" diagnosticsTheOddGarlic-0/+110
2022-12-17Migrate "unsafe_op_in_unsafe_fn" lintsTheOddGarlic-0/+56
2022-12-17Migrate "function cannot return without recursing" diagnosticTheOddGarlic-0/+6
2022-12-17Auto merge of #105421 - jacobbramley:jb/branch-prot-check, r=nagisabors-3/+2
Check AArch64 branch-protection earlier in the pipeline. As suggested in #93516. r? `@nagisa`
2022-12-16Auto merge of #102318 - Amanieu:default_alloc_error_handler, r=oli-obkbors-6/+0
Stabilize default_alloc_error_handler Tracking issue: #66741 This turns `feature(default_alloc_error_handler)` on by default, which causes the compiler to automatically generate a default OOM handler which panics if `#[alloc_error_handler]` is not provided. The FCP completed over 2 years ago but the stabilization was blocked due to an issue with unwinding. This was fixed by #88098 so stabilization can be unblocked. Closes #66741
2022-12-15Rollup merge of #105481 - lqd:mono-stats, r=wesleywiserMatthias Krüger-0/+3
Start improving monomorphization items stats As described in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Compile-time.20case-study.3A.20AWS.20crates/near/314560832), some stats about monomorphization collection would be interesting to have, in a different form than `-Zprint-mono-items`: to have some visibility into the cost of the mono items, we'd like to know how many are instantiated and what is their estimated size. That can be a proxy to analyze sources of slow compile times, although in the future, we'd also like to add more realistic stats from the actual backend's lowering. This PR adds a new `-Z dump-mono-stats` flag which will output some stats in a `{crate_name}.mono-items.md` file (the flag optionally takes an output directory parameter, for easier use within a workspace than printing to stdout). For example, ```rust fn compute<T>(collection: Vec<T>) -> usize { collection.len() + 19 - 0 * 9 - 18 - 1 * 1 // random code to increase the function's size } fn main() { dbg!(compute(vec![0u8, 1, 2])); dbg!(compute(vec![0u64, 1, 2])); dbg!(compute(vec!["0", "1", "2", "3"])); } ``` will output a file with this markdown table (abridged for readability), for a debug build: | Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost | | --- | ---: | ---: | ---: | | alloc::alloc::box_free | 3 | 122 | 366 | | std::alloc::Global::alloc_impl | 1 | 284 | 284 | | alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 | | std::ptr::align_offset | 1 | 222 | 222 | | std::slice::hack::into_vec | 3 | 67 | 201 | | <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 | | std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 | | main | 1 | 163 | 163 | | std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 | ... <details> <summary>Click for full output</summary> | Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost | | --- | ---: | ---: | ---: | | alloc::alloc::box_free | 3 | 122 | 366 | | std::alloc::Global::alloc_impl | 1 | 284 | 284 | | alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 | | std::ptr::align_offset | 1 | 222 | 222 | | std::slice::hack::into_vec | 3 | 67 | 201 | | <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 | | std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 | | main | 1 | 163 | 163 | | std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 | | std::boxed::Box::<T, A>::into_unique | 3 | 48 | 144 | | std::boxed::Box::<T, A>::leak | 3 | 39 | 117 | | std::alloc::Layout::array::inner | 1 | 107 | 107 | | std::ptr::align_offset::mod_inv | 1 | 103 | 103 | | std::boxed::Box::<T, A>::into_raw_with_allocator | 3 | 31 | 93 | | std::fmt::Arguments::<'a>::new_v1 | 1 | 80 | 80 | | <alloc::raw_vec::RawVec<T, A> as std::ops::Drop>::drop | 3 | 26 | 78 | | alloc::raw_vec::RawVec::<T, A>::from_raw_parts_in | 3 | 26 | 78 | | alloc::alloc::exchange_malloc | 1 | 75 | 75 | | std::ptr::const_ptr::<impl *const T>::is_null | 1 | 75 | 75 | | std::ptr::const_ptr::<impl *const T>::is_aligned_to | 1 | 64 | 64 | | compute | 3 | 20 | 60 | | std::ptr::const_ptr::<impl *const T>::align_offset | 1 | 55 | 55 | | std::ptr::read | 1 | 52 | 52 | | <std::alloc::Global as std::alloc::Allocator>::deallocate | 1 | 50 | 50 | | std::ptr::mut_ptr::<impl *mut T>::guaranteed_eq | 1 | 48 | 48 | | std::fmt::ArgumentV1::<'a>::new_display | 2 | 22 | 44 | | std::ptr::Alignment::new_unchecked | 1 | 42 | 42 | | core::fmt::num::<impl std::fmt::Debug for usize>::fmt | 1 | 40 | 40 | | std::result::Result::<T, E>::unwrap_unchecked | 1 | 37 | 37 | | std::cmp::Ord::min | 1 | 32 | 32 | | std::cmp::impls::<impl std::cmp::Ord for usize>::cmp | 1 | 31 | 31 | | std::intrinsics::is_aligned_and_not_null | 1 | 27 | 27 | | std::rt::lang_start | 1 | 27 | 27 | | std::ptr::NonNull::<T>::new | 1 | 24 | 24 | | std::fmt::ArgumentV1::<'a>::new_debug | 1 | 22 | 22 | | std::fmt::Arguments::<'a>::new_v1_formatted | 1 | 19 | 19 | | std::rt::lang_start::{closure#0} | 1 | 17 | 17 | | std::sys_common::backtrace::__rust_begin_short_backtrace | 1 | 16 | 16 | | std::slice::<impl [T]>::into_vec | 3 | 5 | 15 | | <std::ptr::NonNull<T> as std::convert::From<std::ptr::Unique<T>>>::from | 1 | 14 | 14 | | <&T as std::fmt::Debug>::fmt | 1 | 12 | 12 | | <&T as std::fmt::Display>::fmt | 1 | 12 | 12 | | std::vec::Vec::<T, A>::len | 3 | 2 | 6 | | <T as std::convert::Into<U>>::into | 1 | 5 | 5 | | <T as std::convert::From<T>>::from | 1 | 2 | 2 | | <() as std::process::Termination>::report | 1 | 2 | 2 | | std::hint::unreachable_unchecked | 1 | 2 | 2 | | core::fmt::UnsafeArg::new | 1 | 1 | 1 | </details> Since we discussed it together, r? `@wesleywiser.`
2022-12-14Ensure async trait impls are async (or otherwise return an opaque type)Dan Johnson-0/+4
As a workaround for the full `#[refine]` semantics not being implemented yet, forbit returning a concrete future type like `Box<dyn Future>` or a manually implemented Future. `-> impl Future` is still permitted; while that can also cause accidental refinement, that's behind a different feature gate (`return_position_impl_trait_in_trait`) and that problem exists regardless of whether the trait method is async, so will have to be solved more generally. Fixes #102745
2022-12-14add `-Z dump-mono-stats`Rémy Rakic-0/+3
This option will output some stats from the monomorphization collection pass to a file, to show estimated sizes from each instantiation.
2022-12-14Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebankMatthias Krüger-0/+3
Suggest impl in the scenario of typo with fn Fixes #105366
2022-12-13Move some codegen-y methods from rustc_hir_analysis::collect -> ↵Michael Goulet-2/+2
rustc_codegen_ssa
2022-12-10Migrate parts of `rustc_expand` to session diagnosticsnils-0/+107
This migrates everything but the `mbe` and `proc_macro` modules. It also contains a few cleanups and drive-by/accidental diagnostic improvements which can be seen in the diff for the UI tests.
2022-12-10fix #105366, suggest impl in the scenario of typo with fnyukang-0/+3
2022-12-07Auto merge of #104799 - pcc:linkage-fn, r=tmiaskobors-6/+3
Support Option and similar enums as type of static variable with linkage attribute Compiler MCP: rust-lang/compiler-team#565
2022-12-06Check AArch64 branch-protection earlier in the pipeline.Jacob Bramley-3/+2
As suggested in #93516.
2022-12-05On E0195 point at where clause lifetime boundsEsteban Küber-0/+2
Fix #104733
2022-12-05Support Option and similar enums as type of static variable with linkage ↵Peter Collingbourne-1/+1
attribute. Compiler MCP: https://github.com/rust-lang/compiler-team/issues/565
2022-12-05Move linkage type check to HIR analysis and fix semantics issues.Peter Collingbourne-6/+3
This ensures that the error is printed even for unused variables, as well as unifying the handling between the LLVM and GCC backends. This also fixes unusual behavior around exported Rust-defined variables with linkage attributes. With the previous behavior, it appears to be impossible to define such a variable such that it can actually be imported and used by another crate. This is because on the importing side, the variable is required to be a pointer, but on the exporting side, the type checker rejects static variables of pointer type because they do not implement `Sync`. Even if it were possible to import such a type, it appears that code generation on the importing side would add an unexpected additional level of pointer indirection, which would break type safety. This highlighted that the semantics of linkage on Rust-defined variables is different to linkage on foreign items. As such, we now model the difference with two different codegen attributes: linkage for Rust-defined variables, and import_linkage for foreign items. This change gives semantics to the test src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was previously expected to fail to compile. Therefore, convert it into a test that is expected to successfully compile. The update to the GCC backend is speculative and untested.
2022-11-26Rewrite LLVM's archive writer in Rustbjorn3-9/+6
This allows it to be used by other codegen backends
2022-11-22Rollup merge of #104621 - YC:master, r=davidtwcoManish Goregaokar-1/+1
Fix --extern library finding errors - `crate_name` is not specified/passed to `metadata_crate_location_unknown_type` https://github.com/rust-lang/rust/blob/c493bae0d8efd75723460ce5c371f726efa93f15/compiler/rustc_error_messages/locales/en-US/metadata.ftl#L274-L275 - `metadata_lib_filename_form` is missing `$` - Add additional check to ensure that library is file Testing 1. Create file `a.rs` ```rust extern crate t; fn main() {} ``` 1. Create empty file `x` 1. Create empty directory `y` 1. Run ```sh $ rustc -o a a.rs --extern t=x $ rustc -o a a.rs --extern t=y ``` Both currently panic with stable.
2022-11-22Remove extra . in metadata_lib_filename_formSteven Tang-1/+1
2022-11-21Match crate and slug namesmejrs-436/+436
2022-11-20Rollup merge of #104504 - compiler-errors:fru-syntax-note, r=estebankMatthias Krüger-0/+9
Add a detailed note for missing comma typo w/ FRU syntax Thanks to `@pierwill` for working on this with me! Fixes #104373, perhaps `@alice-i-cecile` can comment on the new error for the example provided on that issue -- feedback is welcome. ``` error[E0063]: missing field `defaulted` in initializer of `Outer` --> $DIR/multi-line-fru-suggestion.rs:14:5 | LL | Outer { | ^^^^^ missing `defaulted` | note: this expression may have been misinterpreted as a `..` range expression --> $DIR/multi-line-fru-suggestion.rs:16:16 | LL | inner: Inner { | ________________^ LL | | a: 1, LL | | b: 2, LL | | } | |_________^ this expression does not end in a comma... LL | ..Default::default() | ^^^^^^^^^^^^^^^^^^^^ ... so this is interpreted as a `..` range expression, instead of functional record update syntax help: to set the remaining fields from `Default::default()`, separate the last named field with a comma | LL | }, | + error: aborting due to previous error For more information about this error, try `rustc --explain E0063`. ```
2022-11-20Fix metadata_lib_filename_formSteven Tang-1/+1
2022-11-18Auto merge of #104591 - Manishearth:rollup-b3ser4e, r=Manishearthbors-2/+99
Rollup of 8 pull requests Successful merges: - #102977 (remove HRTB from `[T]::is_sorted_by{,_key}`) - #103378 (Fix mod_inv termination for the last iteration) - #103456 (`unchecked_{shl|shr}` should use `u32` as the RHS) - #103701 (Simplify some pointer method implementations) - #104047 (Diagnostics `icu4x` based list formatting.) - #104338 (Enforce that `dyn*` coercions are actually pointer-sized) - #104498 (Edit docs for `rustc_errors::Handler::stash_diagnostic`) - #104556 (rustdoc: use `code-header` class to format enum variants) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-18Enable icu sync feature for parallel compilerCharles Lew-0/+3
2022-11-18Import icu locale fallback dataCharles Lew-11/+12
2022-11-18Migrate diagnostics list output to use icu list formatter.Charles Lew-2/+95
2022-11-18Add a detailed note for missing comma in FRU syntax typoMichael Goulet-0/+9
2022-11-18Rollup merge of #103405 - chenyukang:yukang/fix-103381-and-if, r=compiler-errorsMatthias Krüger-0/+3
Detect incorrect chaining of if and if let conditions and recover Fixes #103381
2022-11-18Rollup merge of #101162 - rajputrajat:master, r=davidtwcoMatthias Krüger-0/+212
Migrate rustc_resolve to use SessionDiagnostic, part # 1 crate a somewhat on larger size, so plz allow some time to get it finished.
2022-11-16Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=bjorn3Matthias Krüger-0/+2
Issue error when -C link-self-contained option is used on unsupported platforms The documentation was also updated to reflect this. I'm assuming the supported platforms are the same as initially written in [RELEASES.md](https://github.com/rust-lang/rust/blob/master/RELEASES.md#compiler-17). Fixes #103576
2022-11-14Issue error when `-C link-self-contained` option is used on unsupported ↵StackDoubleFlow-0/+2
platforms Document supported targets for `-C link-self-contained` Move `LinkSelfContainedDefault::True` from wasm_base to wasm32_wasi
2022-11-15fix #104088, Slightly improve error message for invalid identifieryukang-0/+3
2022-11-15Auto merge of #104418 - matthiaskrgr:rollup-y4i6xjc, r=matthiaskrgrbors-0/+9
Rollup of 11 pull requests Successful merges: - #101967 (Move `unix_socket_abstract` feature API to `SocketAddrExt`.) - #102470 (Stabilize const char convert) - #104223 (Recover from function pointer types with generic parameter list) - #104229 (Don't print full paths in overlap errors) - #104294 (Don't ICE with inline const errors during MIR build) - #104332 (Fixed some `_i32` notation in `maybe_uninit`’s doc) - #104349 (fix some typos in comments) - #104350 (Fix x finding Python on Windows) - #104356 (interpret: make check_mplace public) - #104364 (rustdoc: Resolve doc links in external traits having local impls) - #104378 (Bump chalk to v0.87) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-15fix #103381, Detect incorrect chaining of if and if let conditionsyukang-0/+3
2022-11-15Auto merge of #104091 - BelovDV:issue-103044, r=petrochenkovbors-0/+2
Wrap bundled static libraries into object files Fixes #103044 (not sure, couldn't test locally) Bundled static libraries should be wrapped into object files as it's done for metadata file. r? `@petrochenkov`
2022-11-14Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=estebankMatthias Krüger-0/+9
Recover from function pointer types with generic parameter list Give a more helpful error when encountering function pointer types with a generic parameter list like `fn<'a>(&'a str) -> bool` or `fn<T>(T) -> T` and suggest moving lifetime parameters to a `for<>` parameter list. I've added a bunch of extra code to properly handle (unlikely?) corner cases like `for<'a> fn<'b>()` (where there already exists a `for<>` parameter list) correctly suggesting `for<'a, 'b> fn()` (merging the lists). If you deem this useless, I can simplify the code by suggesting nothing at all in this case. I am quite open to suggestions regarding the wording of the diagnostic messages. Fixes #103487. ``@rustbot`` label A-diagnostics r? diagnostics