about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-02-09Allow substitutions in `rustc_on_unimplemented` predicateMichael Goulet-12/+39
2022-02-09Auto merge of #93681 - Mark-Simulacrum:rlink-binary, r=davidtwco,bjorn3bors-9/+8
Store rlink data in opaque binary format on disk This removes one of the only uses of JSON decoding (to Rust structs) from the compiler, and fixes the FIXME comment. It's not clear to me what the reason for using JSON here originally was, and from what I can tell nothing outside of rustc expects to read the emitted information, so it seems like a reasonable step to move it to the metadata-encoding format (rustc_serialize::opaque). Mostly intended as a FIXME fix, though potentially a stepping stone to dropping the support for Decodable to be used to decode JSON entirely (allowing for better/faster APIs on the Decoder trait). cc #64191
2022-02-09Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obkbors-60/+169
Improve opaque type higher-ranked region error message under NLL Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-09Rollup merge of #93781 - lcnr:ty-kind-docs, r=jackh726Yuki Okushi-20/+70
update `ty::TyKind` documentation slightly unsure about `ty::Opaque` and `ty::Bound`/`ty::Placeholder`. r? `@jackh726` `@nikomatsakis` `@oli-obk`
2022-02-09Rollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiaskoYuki Okushi-19/+21
Drop tracking: track borrows of projections Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs. This PR also includes the `-Zdrop-tracking` flag from #93313. If that PR lands first, I'll rebase to drop the commit from this one. Fixes #93648
2022-02-09Rollup merge of #93748 - klensy:vis-r, r=cjgillotYuki Okushi-3/+3
rustc_query_impl: reduce visibility of some modules/fn's Locally this reduces number of exported functions from 15221 -> 14952 and size a little. Perf run please?
2022-02-09Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakisYuki Okushi-13/+3
Remove defaultness from ImplItem. This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgrbors-12/+24
Rollup of 7 pull requests Successful merges: - #91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`) - #92715 (Do not suggest char literal for zero-length strings) - #92917 (Don't constrain projection predicates with inference vars in GAT substs) - #93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file) - #93732 (add fut/back compat tests for implied trait bounds) - #93764 (:arrow_up: rust-analyzer) - #93767 (deduplicate `lcnr` in mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-08Improve opaque type higher-ranked region error message under NLLAaron Hill-60/+169
Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-08Update compiler/rustc_middle/src/ty/sty.rslcnr-0/+2
2022-02-08Update compiler/rustc_middle/src/ty/sty.rslcnr-1/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-02-08Fix regression from lazy opaque typesOli Scherer-8/+32
2022-02-08update `ty::TyKind` documentationlcnr-20/+68
2022-02-08Rollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakisMatthias Krüger-1/+11
Don't constrain projection predicates with inference vars in GAT substs cc #91762 Not a fix, but a mitigation to prevent a backwards-compatible hazard where we normalize using a predicate only because it's the only one available, but shouldn't. This would constrain an inference variable which didn't really want. We already do this when selecting a projection candidate, which isn't always correct. But changing that is a problem for a different day. Also found out that a suggestion for `await`ing a future was using the wrong substs. r? ``@nikomatsakis``
2022-02-08Rollup merge of #92715 - chordtoll:empty-string, r=davidtwcoMatthias Krüger-1/+1
Do not suggest char literal for zero-length strings PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided. The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint. This PR adds the missing check, and a test case to confirm the new behavior.
2022-02-08Rollup merge of #91950 - estebank:point-at-type-of-non-allocator, ↵Matthias Krüger-10/+12
r=matthewjasper Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`
2022-02-08Auto merge of #93762 - matthiaskrgr:rollup-vdjpfmz, r=matthiaskrgrbors-76/+105
Rollup of 9 pull requests Successful merges: - #86497 (Add {floor,ceil}_char_boundary methods to str) - #92695 (Add `#[no_coverage]` tests for nested functions) - #93521 (Fix hover effects in sidebar) - #93568 (Include all contents of first line of scraped item in Rustdoc) - #93569 (rustdoc: correct unclosed HTML tags as generics) - #93672 (update comment wrt const param defaults) - #93715 (Fix horizontal trim for block doc comments) - #93721 (rustdoc: Special-case macro lookups less) - #93728 (Add in ValuePair::Term) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-08Rollup merge of #93728 - JulianKnodt:toterm, r=oli-obkMatthias Krüger-69/+74
Add in ValuePair::Term This adds in an enum when matching on positions which can either be types or consts. It will default to emitting old special cased error messages for types. r? `@oli-obk` cc `@matthiaskrgr` Fixes #93578
2022-02-08Rollup merge of #93715 - GuillaumeGomez:horizontal-trim, r=notriddleMatthias Krüger-6/+30
Fix horizontal trim for block doc comments Fixes #93662. r? `@notriddle`
2022-02-08Rollup merge of #93672 - lcnr:const-param-defaults-xx, r=matthewjasperMatthias Krüger-1/+1
update comment wrt const param defaults after #93669 i looked through all other uses of `GenericParamKind::Const` again to detect if we missed the `default` there as well, but afaict we really only missed lifetime resolution '^^ at least i found an outdated comment :3
2022-02-08Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisabors-75/+142
Add more *-unwind ABI variants The following *-unwind ABIs are now supported: - "C-unwind" - "cdecl-unwind" - "stdcall-unwind" - "fastcall-unwind" - "vectorcall-unwind" - "thiscall-unwind" - "aapcs-unwind" - "win64-unwind" - "sysv64-unwind" - "system-unwind" cc `@rust-lang/wg-ffi-unwind`
2022-02-07Drop tracking: track borrows of projectionsEric Holk-12/+16
Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs.
2022-02-07Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakisbors-831/+1149
Lazy type-alias-impl-trait Previously opaque types were processed by 1. replacing all mentions of them with inference variables 2. memorizing these inference variables in a side-table 3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing. This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around. Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing * https://github.com/rust-lang/rfcs/pull/2515 much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities). r? `@nikomatsakis` fixes #93411 fixes #88236
2022-02-0814956 -> 14952 exportsklensy-2/+2
2022-02-07Add a flag enabling drop range tracking in generatorsTomasz Miąsko-7/+5
2022-02-07Change inference var check to be in project_typeJack Huey-11/+11
2022-02-07Don't match any projection predicates when the obligation has inference ↵Jack Huey-2/+12
types or consts in GAT substs
2022-02-0715221 -> 14956 exportsklensy-1/+1
2022-02-07Rm ValuePairs::Ty/Constkadmin-68/+61
Remove old value pairs which is a strict subset of Terms.
2022-02-07Add test for block doc comments horizontal trimGuillaume Gomez-14/+6
2022-02-07Fix horizontal trim for block doc commentsGuillaume Gomez-6/+38
2022-02-07Print opaque types from type aliases via their pathOli Scherer-19/+15
2022-02-07Rollup merge of #93682 - ↵Mara Bos-1/+1
PatchMixolydic:where-in-the-world-is-const_fn_trait_bound, r=oli-obk Update tracking issue for `const_fn_trait_bound` It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). This tracking issue doesn't mention anything about `const_fn_trait_bound`(the only occurrence of "trait bound" is for the now-removed `?const Trait` syntax), which can be confusing to people who want to find out more about trait bounds on `const fn`s. This pull request changes the tracking issue to one meant specifically for `const_fn_trait_bound`, #93706, which can help collect information on this feature's stabilization and point users towards `const_trait_impl` if they're looking for const-in-const-contexts trait bounds. Fixes #93679. `````@rustbot````` modify labels +A-const-fn +F-const_trait_impl
2022-02-07Rollup merge of #93680 - Mark-Simulacrum:drop-json-reader, r=bjorn3Mara Bos-24/+2
Drop json::from_reader Just a small cleanup -- this was essentially unused; the one use site is better suited to reading from &str regardless.
2022-02-07Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-seMara Bos-12/+2
remove `allow_fail` test flag close #93345
2022-02-07Rollup merge of #93394 - m-ou-se:fix-93378, r=estebankMara Bos-11/+24
Don't allow {} to refer to implicit captures in format_args. Fixes #93378
2022-02-07Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelidMara Bos-13/+37
Suggest 1-tuple parentheses on exprs without existing parens A follow-on from #86116, split out from #90677. This alters the suggestion to add a trailing comma to create a 1-tuple - previously we would only apply this if the relevant expression was parenthesised. We now make the suggestion regardless of parentheses, which reduces the fragility of the check (w.r.t formatting). e.g. ```rust let a: Option<(i32,)> = Some(3); ``` gets the below suggestion: ```rust let a: Option<(i32,)> = Some((3,)); // ^ ^^ ``` This change also improves the suggestion in other ways, such as by only making the suggestion if the types would match after the suggestion is applied and making the suggestion a multipart suggestion.
2022-02-07Add in ValuePair::Termkadmin-10/+22
This adds in an enum when matching on positions which can either be types or consts. It will default to emitting old special cased error messages for types.
2022-02-07Auto merge of #93643 - lcnr:fold-substs-perf, r=michaelwoeristerbors-9/+1
use `fold_list` in `try_super_fold_with` for `SubstsRef` split out from #93505 as this by itself is responsible for most of the perf improvements there r? `@michaelwoerister`
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-10/+55
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-06Merge duplicate suggestion stringRob Pilling-7/+4
2022-02-06Factor out emit_tuple_wrap_err, improve ApplicabilityRob Pilling-29/+39
2022-02-06Fix tracking issue for `const_fn_trait_bound`Ruby Lazuli-1/+1
It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). `const_fn_trait_bounds` weren't mentioned here, so this commit changes its tracking issue to a new one.
2022-02-06Rollup merge of #93489 - Amanieu:panic_no_unwind, r=nagisaMatthias Krüger-0/+7
Mark the panic_no_unwind lang item as nounwind This has 2 effects: - It helps LLVM when inlining since it doesn't need to generate landing pads for `panic_no_unwind`. - It makes it sound for a panic handler to unwind even if `PanicInfo::can_unwind` returns true. This will simply cause another panic once the unwind tries to go past the `panic_no_unwind` lang item. Eventually this will cause a stack overflow, which is safe.
2022-02-06Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obkMatthias Krüger-18/+18
Require const stability attribute on all stable functions that are `const` This PR requires all stable functions (of all kinds) that are `const fn` to have a `#[rustc_const_stable]` or `#[rustc_const_unstable]` attribute. Stability was previously implied if omitted; a follow-up PR is planned to change the fallback to be unstable.
2022-02-06Rollup merge of #93669 - compiler-errors:const-generic-args, r=lcnrMatthias Krüger-1/+4
Resolve lifetimes for const generic defaults We weren't visiting the const generic default argument in `rustc_resolve::late::lifetimes`. This seems to fix the issue, and we deny any non-`'static` lifetimes anyways. Fixes #93647
2022-02-06Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillotMatthias Krüger-48/+125
Change struct expr pretty printing to match rustfmt style This PR backports trailing comma support from https://github.com/dtolnay/prettyplease into rustc_ast_pretty and uses it to improve the formatting of struct expressions. Example: ```rust macro_rules! stringify_expr { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", stringify_expr!(Struct { a: Struct { b, c }, })); println!("{}", stringify_expr!(Struct { aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct { cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE, }, })); } ``` 🤮 Before: ```console Struct{a: Struct{b, c,},} Struct{aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct{cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE,},} ``` After: ```console Struct { a: Struct { b, c } } Struct { aaaaaaaaaa: AAAAAAAAAA, bbbbbbbbbb: Struct { cccccccccc: CCCCCCCCCC, dddddddddd: DDDDDDDDDD, eeeeeeeeee: EEEEEEEEEE, }, } ```
2022-02-06Rollup merge of #92383 - lancethepants:armv7-unknown-linux-uclibceabi, r=nagisaMatthias Krüger-0/+24
Add new target armv7-unknown-linux-uclibceabi (softfloat) This adds the new target `armv7-unknown-linux-uclibceabi (softfloat)`. It is of course similar to `armv7-unknown-linux-uclibceabihf (hardfloat)` which was just recently added to rust except that it is `softfloat`. My interest lies in the Broadcom BCM4707/4708/BCM4709 family, notably found in some Netgear and Asus consumer routers. The armv7 Cortex-A9 cpus found in these devices do not have an fpu or NEON support. With this patch I've been able to bootstrap rustc, std and host tools `(extended = true)` to run on the target device for native compilation, allowing the target to be used as a development platform. With the recent addition of `armv7-unknown-linux-uclibceabihf (hardfloat)` it looks like many of the edge cases of using the uclibc c-library are getting worked out nicely. I've been able to compile some complex projects. Some patching still needed in some crates, but getting there for sure. I think `armv7-unknown-linux-uclibceabi` is ready to be a tier 3 target. I use a cross-toolchain from my project to bootstrap rust. https://github.com/lancethepants/tomatoware The goal of this project is to create a native development environment with support for various languages.
2022-02-06Rollup merge of #92300 - Itus-Shield:mips64-openwrt, r=nagisaMatthias Krüger-0/+28
mips64-openwrt-linux-musl: Add Tier 3 target Tier 3 tuple for Mips64 OpenWrt toolchain. This add first-time support for OpenWrt. Future Tier3 targets will be added as I test them. Signed-off-by: Donald Hoskins <grommish@gmail.com>
2022-02-06Rollup merge of #91939 - GKFX:feature-91866, r=cjgillotMatthias Krüger-7/+24
Clarify error on casting larger integers to char Closes #91836 with changes to E0604.md and a `span_help`.