about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-07-31Always include a position span in rustc_parse_format::ArgumentAlex Macleod-39/+94
2022-07-30Auto merge of #99959 - cuviper:niche-size, r=eddybbors-2/+8
Fix the size of niche enums with ZST alignment For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match. Fixes #99836 r? `@eddyb`
2022-07-30Rollup merge of #99956 - est31:fix_llvm_wrapper_warning, r=cuviperMatthias Krüger-0/+2
Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE Fixes a warning: ``` warning: llvm-wrapper/RustWrapper.cpp:159:11: warning: enumeration values 'AllocatedPointer' and 'AllocAlign' not handled in switch [-Wswitch] warning: switch (Kind) { warning: ^ ``` Which was fall out from 130a1df71ea73ab9d66d3cb8fc9cdb43155d514b. Fixes #99955
2022-07-30Rollup merge of #99890 - compiler-errors:issue-99828, r=lcnrMatthias Krüger-4/+14
Do not allow bad projection term to leak into the type checker Fixes #99828
2022-07-30Rollup merge of #99889 - compiler-errors:cleanup-ti, r=cjgillotMatthias Krüger-36/+18
Remove `parent_pat` from `TopInfo` We can get the parent pat from the hir map.
2022-07-30Fix the size of niche enums with ZST alignmentJosh Stone-2/+8
For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match.
2022-07-30Auto merge of #99948 - Dylan-DPC:rollup-ed5136t, r=Dylan-DPCbors-151/+104
Rollup of 5 pull requests Successful merges: - #99311 (change maybe_body_owned_by to take local def id) - #99862 (Improve type mismatch w/ function signatures) - #99895 (don't call type ascription "cast") - #99900 (remove some manual hash stable impls) - #99903 (Add diagnostic when using public instead of pub) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-30Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GEest31-0/+2
Fixes a warning: warning: llvm-wrapper/RustWrapper.cpp:159:11: warning: enumeration values 'AllocatedPointer' and 'AllocAlign' not handled in switch [-Wswitch] warning: switch (Kind) { warning: ^ Which was fall out from 130a1df71ea73ab9d66d3cb8fc9cdb43155d514b.
2022-07-30Rollup merge of #99903 - gimbles:pub, r=davidtwcoDylan DPC-0/+11
Add diagnostic when using public instead of pub Forwarding from https://github.com/rust-lang/rust/pull/99706 I accidentally broke something(??) in git and the commits in that PR are absolutely not what I did in that branch Anyways, this is the PR for this now. Adding tests again in a minute. cc `@davidtwco`
2022-07-30Rollup merge of #99900 - lcnr:hash-stable-fun, r=cjgillotDylan DPC-89/+15
remove some manual hash stable impls
2022-07-30Rollup merge of #99895 - compiler-errors:type-ascription-aint-cast, r=davidtwcoDylan DPC-6/+7
don't call type ascription "cast" Noticed in #99885
2022-07-30Rollup merge of #99862 - WaffleLapkin:type_mismatch_fix, r=compiler-errorsDylan DPC-13/+20
Improve type mismatch w/ function signatures This PR makes use of `note: expected/found` (instead of labeling types in labels) in type mismatch with function signatures. Pros: it's easier to compare the signatures, cons: the error is a little more verbose now. This is especially nice when - The signatures differ in a small subset of parameters (same parameters are elided) - The difference is in details, for example `isize` vs `usize` (there is a better chance that the types align) Also this PR fixes the inconsistency in variable names in the edited code (`expected` and `found`). A zulip thread from which this pr started: [[link]](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Type.20error.20regression.3F.2E.2E.2E/near/289756602). An example diagnostic: <table> <tr> <th>this pr</th> <th>nightly</th> </tr> <tr> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected due to this | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature defined here | = note: expected function signature `fn(usize, _, Vec<u64>) -> _` found function signature `fn(isize, _, Vec<u32>) -> _` note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast from `fn(isize, u8, Vec<u32>) {f}` to the object type `dyn Trait` ``` </td> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected signature of `fn(usize, u8, Vec<u64>) -> _` | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature of `fn(isize, u8, Vec<u32>) -> _` | note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast to the object type `dyn Trait` ``` </td> </tr> </table> <details><summary>code</summary> <p> ```rust fn main() { fn expect(_: &dyn Trait) {} expect(&f); } trait Trait {} impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} fn f(_: isize, _: u8, _: Vec<u32>) {} ``` </p> </details> r? `@compiler-errors`
2022-07-30Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillotDylan DPC-43/+51
change maybe_body_owned_by to take local def id Issue https://github.com/rust-lang/rust/issues/96341 r? `@cjgillot`
2022-07-30Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkovbors-265/+251
Remove `TreeAndSpacing`. A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is not quite right. `Spacing` makes sense for `TokenTree::Token`, but does not make sense for `TokenTree::Delimited`, because a `TokenTree::Delimited` cannot be joined with another `TokenTree`. This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`, changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the `TreeAndSpacing` typedef. The commit removes these two impls: - `impl From<TokenTree> for TokenStream` - `impl From<TokenTree> for TreeAndSpacing` These were useful, but also resulted in code with many `.into()` calls that was hard to read, particularly for anyone not highly familiar with the relevant types. This commit makes some other changes to compensate: - `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`. - `TokenStream::token_{alone,joint}()` are added. - `TokenStream::delimited` is added. This results in things like this: ```rust TokenTree::token(token::Semi, stmt.span).into() ``` changing to this: ```rust TokenStream::token_alone(token::Semi, stmt.span) ``` This makes the type of the result, and its spacing, clearer. These changes also simplifies `Cursor` and `CursorRef`, because they no longer need to distinguish between `next` and `next_with_spacing`. r? `@petrochenkov`
2022-07-30Auto merge of #99796 - compiler-errors:issue-53475, r=oli-obkbors-13/+18
use `check_region_obligations_and_report_errors` to avoid ICEs If we don't call `process_registered_region_obligations` before `resolve_regions_and_report_errors` then we'll ICE if we have any region obligations, and `check_region_obligations_and_report_errors` just does both of these for us in a nice convenient function. Fixes #53475 r? types
2022-07-30Auto merge of #99123 - mystor:crossbeam_bridge, r=eddybbors-8/+67
proc_macro: use crossbeam channels for the proc_macro cross-thread bridge This is done by having the crossbeam dependency inserted into the `proc_macro` server code from the server side, to avoid adding a dependency to `proc_macro`. In addition, this introduces a -Z command-line option which will switch rustc to run proc-macros using this cross-thread executor. With the changes to the bridge in #98186, #98187, #98188 and #98189, the performance of the executor should be much closer to same-thread execution. In local testing, the crossbeam executor was substantially more performant than either of the two existing `CrossThread` strategies, so they have been removed to keep things simple. r? `@eddyb`
2022-07-30Auto merge of #99925 - JohnTitor:rollup-4bt9ou3, r=JohnTitorbors-138/+134
Rollup of 8 pull requests Successful merges: - #99227 (Fix thumbv4t-none-eabi frame pointer setting) - #99518 (Let-else: break out scopes when a let-else pattern fails to match) - #99671 (Suggest dereferencing index when trying to use a reference of usize as index) - #99831 (Add Fuchsia platform support documentation) - #99881 (fix ICE when computing codegen_fn_attrs on closure with non-fn parent) - #99888 (Streamline lint checking) - #99891 (Adjust an expr span to account for macros) - #99904 (Cleanup html whitespace) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-30Rollup merge of #99891 - compiler-errors:suggest-slicing-carefully, r=oli-obkYuki Okushi-2/+5
Adjust an expr span to account for macros Fix this erroneous suggestion: ``` error[E0529]: expected an array or slice, found `Vec<{integer}>` --> /home/gh-compiler-errors/test.rs:2:9 | 2 | let [..] = vec![1, 2, 3]; | ^^^^ pattern cannot match with input type `Vec<{integer}>` | help: consider slicing here --> /home/gh-compiler-errors/rust2/library/alloc/src/macros.rs:50:36 | 50~ $crate::__rust_force_expr!(<[_]>::into_vec( 51+ #[rustc_box] 52+ $crate::boxed::Box::new([$($x),+]) 53~ )[..]) ```
2022-07-30Rollup merge of #99888 - nnethercote:streamline-visitors, r=cjgillotYuki Okushi-88/+6
Streamline lint checking The early (AST) and late (HIR) lint checkers have a number of functions that aren't used by rustc or clippy. Might as well remove them -- it's not like there's a canonical API here, as shown by the ad hoc use of `check_foo`/`check_foo_post` combinations. r? `@cjgillot`
2022-07-30Rollup merge of #99881 - compiler-errors:issue-99876, r=tmiaskoYuki Okushi-3/+5
fix ICE when computing codegen_fn_attrs on closure with non-fn parent Other call sites check `has_codegen_attrs` first, so let's do that too. Fixes #99876
2022-07-30Rollup merge of #99671 - TaKO8Ki:suggest-dereferencing-index, r=compiler-errorsYuki Okushi-0/+48
Suggest dereferencing index when trying to use a reference of usize as index fixes #96678
2022-07-30Rollup merge of #99518 - dingxiangfei2009:let-else-additional-tests, r=oli-obkYuki Okushi-42/+49
Let-else: break out scopes when a let-else pattern fails to match This PR will commit to a new behavior so that values from initializer expressions are dropped earlier when a let-else pattern fails to match. Fix #98672. Close #93951. cc `@camsteffen` `@est31`
2022-07-30Rollup merge of #99227 - Lokathor:fix-thumbv4t-none-eabi-frame-pointer, ↵Yuki Okushi-3/+21
r=davidtwco Fix thumbv4t-none-eabi frame pointer setting The `thumb_base` profile has changed since I last remember seeing it, and now it sets the frame pointer to "always keep", which is not desired for this target. Hooking a debugger to the running program is not really done, it's preferable to have the register available for actual program use, so the default "may omit" is now set. I thought that the target was already using "may omit" when I checked on it last month, because I forgot that the target was previously based on `thumb_base` rather than `Default::default()`. I only noticed the issue just now when creating the `armv4t-none-eabi` target (https://github.com/rust-lang/rust/pull/99226), though this PR is not in any way conditional on that one.
2022-07-29Change enclosing_body_owner to return LocalDefIdMiguel Guarniz-13/+12
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Rename local_did to def_idMiguel Guarniz-23/+27
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-41/+46
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Auto merge of #99730 - lcnr:bound-vars-anon, r=jackh726bors-138/+246
anonymize all bound vars, not just regions fixes #98702 r? types
2022-07-29proc_macro: use crossbeam channels for the proc_macro cross-thread bridgeNika Layzell-8/+67
This is done by having the crossbeam dependency inserted into the proc_macro server code from the server side, to avoid adding a dependency to proc_macro. In addition, this introduces a -Z command-line option which will switch rustc to run proc-macros using this cross-thread executor. With the changes to the bridge in #98186, #98187, #98188 and #98189, the performance of the executor should be much closer to same-thread execution. In local testing, the crossbeam executor was substantially more performant than either of the two existing CrossThread strategies, so they have been removed to keep things simple.
2022-07-29Auto merge of #99467 - BelovDV:add_option_link_arg, r=petrochenkovbors-12/+48
flag '-l link-arg=___ was added #99427
2022-07-29Add diagnostic when using public instead of pubGimgim-0/+11
2022-07-29remove some manual hash stable implslcnr-89/+15
2022-07-29Auto merge of #99892 - JohnTitor:rollup-qi4fem8, r=JohnTitorbors-13/+48
Rollup of 8 pull requests Successful merges: - #99686 (add suggestion when there is a impl of external trait on pointer with wrong coherence rules) - #99760 (doc/rustc: describe the uefi target platforms) - #99766 (Htmldocck: Substitute the doc channel when blessing) - #99781 (Use String::from_utf8_lossy in CStr demo) - #99803 (Update mentions to `rustc_metadata::rmeta::Lazy`) - #99845 (Remove `$` prefix for bash scripts in doc) - #99850 (rustdoc: Remove more Clean trait implementations) - #99872 (Clone the `src/llvm-project` submodule if profiling is enabled) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-29Auto merge of #99667 - ouz-a:some_branch, r=oli-obkbors-28/+22
Optimize `UnDerefer` Addresses the performance [issues](https://github.com/rust-lang/rust/pull/98145#issuecomment-1183548597) faced here. r? `@oli-obk`
2022-07-29dont call type ascription 'cast'Michael Goulet-6/+7
2022-07-29optimize bound vars replacement :3lcnr-20/+24
2022-07-29Rollup merge of #99803 - JohnTitor:update-lazy-docs, r=compiler-errorsYuki Okushi-12/+12
Update mentions to `rustc_metadata::rmeta::Lazy` While working on https://github.com/rust-lang/rustc-dev-guide/pull/1411, I noticed there are still some mentions of `Lazy`. This updates them to `LazyValue`, `LazyArray`, or `LazyTable`. r? ````@compiler-errors```` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-29Rollup merge of #99686 - vincenzopalazzo:macros/impl_on_ptr, r=compiler-errorsYuki Okushi-1/+36
add suggestion when there is a impl of external trait on pointer with wrong coherence rules Closes https://github.com/rust-lang/rust/issues/99572 This will try to improve the node in the error message by suggesting a general solution because the solution, in this case, is application depended. I'm not super happy regarding the code quality, but I'm happy to have feedback on it. `@rustbot` r? `@compiler-errors`
2022-07-29Document check_region_obligations_and_report_errors, simplify a call to ↵Michael Goulet-7/+11
resolve_regions
2022-07-29Adjust an expr span to account for macrosMichael Goulet-2/+5
2022-07-29Remove `TreeAndSpacing`.Nicholas Nethercote-265/+251
A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is not quite right. `Spacing` makes sense for `TokenTree::Token`, but does not make sense for `TokenTree::Delimited`, because a `TokenTree::Delimited` cannot be joined with another `TokenTree`. This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`, changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the `TreeAndSpacing` typedef. The commit removes these two impls: - `impl From<TokenTree> for TokenStream` - `impl From<TokenTree> for TreeAndSpacing` These were useful, but also resulted in code with many `.into()` calls that was hard to read, particularly for anyone not highly familiar with the relevant types. This commit makes some other changes to compensate: - `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`. - `TokenStream::token_{alone,joint}()` are added. - `TokenStream::delimited` is added. This results in things like this: ```rust TokenTree::token(token::Semi, stmt.span).into() ``` changing to this: ```rust TokenStream::token_alone(token::Semi, stmt.span) ``` This makes the type of the result, and its spacing, clearer. These changes also simplifies `Cursor` and `CursorRef`, because they no longer need to distinguish between `next` and `next_with_spacing`.
2022-07-29Do not allow bad projection term to leak into the type checkerMichael Goulet-4/+14
2022-07-29Remove parent_pat from TopInfoMichael Goulet-36/+18
2022-07-29Remove some late `check_*` functions.Nicholas Nethercote-34/+2
They're not used by rustc or clippy.
2022-07-29Remove `visit_name` from the AST visitor.Nicholas Nethercote-18/+4
Because the default is empty and it's never overridden. This means `walk_ident` can also be removed, because it does nothing.
2022-07-29Remove some early `check_*` functions.Nicholas Nethercote-36/+0
They're not used by rustc or clippy.
2022-07-29check if T is sliceTakayuki Maeda-2/+3
fix msg
2022-07-29implement `point_at_index_if_possible`Takayuki Maeda-11/+17
2022-07-29Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errorsbors-77/+255
Generate correct suggestion with named arguments used positionally Address issue #99265 by checking each positionally used argument to see if the argument is named and adding a lint to use the name instead. This way, when named arguments are used positionally in a different order than their argument order, the suggested lint is correct. For example: ``` println!("{b} {}", a=1, b=2); ``` This will now generate the suggestion: ``` println!("{b} {a}", a=1, b=2); ``` Additionally, this check now also correctly replaces or inserts only where the positional argument is (or would be if implicit). Also, width and precision are replaced with their argument names when they exists. Since the issues were so closely related, this fix for issue #99265 also fixes issue #99266. Fixes #99265 Fixes #99266
2022-07-29Auto merge of #99512 - nikic:llvm-15-fixes, r=cuviperbors-81/+89
LLVM 15 compatibility fixes These are LLVM 15 compatibility fixes split out from #99464. There are three changes here: * Emit elementtype attribtue for ldrex/strex intrinsics. This is requires as part of the opaque pointers migration. * Make more tests compatible with opaque pointers. These are either new or aren't run on x86. * Remove a test for `#[rustc_allocator]`. Since #99574 there are more requirement on the function signature. I dropped the test entirely, since we already test the effect of the attribute elsewhere. * The main change: When a worker thread emits an error, wait for other threads to finish before unwinding the main thread and exiting. Otherwise workers may end up using globals for which destructors have already been run. This was probably never quite correct, but became an active problem with LLVM 15, because it started using global dtors in critical places, as part of ManagedStatic removal. Fixes #99432 (and probably also #95679). r? `@cuviper`
2022-07-29fix ICE when computing codegen_fn_attrs on closure with non-fn parentMichael Goulet-3/+5