Commit Graph

16796 Commits

Author SHA1 Message Date
Camille GILLOT
60a052f4d3 Handle MIR in a single place. 2022-08-30 19:07:22 +02:00
Camille GILLOT
b94d421d08 Remove fn_has_self_parameter table. 2022-08-30 19:06:30 +02:00
Camille GILLOT
b0b46c0a10 Separate macro_rules and macro_definition. 2022-08-30 19:06:12 +02:00
Camille GILLOT
c485fccd81 Remove EntryKind. 2022-08-30 19:05:59 +02:00
Camille GILLOT
affb12210d Create a module-reexports table. 2022-08-30 19:05:50 +02:00
Camille GILLOT
d330dc8c11 Fix the panic message. 2022-08-30 19:05:42 +02:00
Camille GILLOT
30ae64e51f Create a table for fn_has_self_parameter. 2022-08-30 19:05:33 +02:00
Camille GILLOT
1ddb944311 Use tables for macros. 2022-08-30 19:05:15 +02:00
Camille GILLOT
ca9f5645f3 Move AssocContainer to a metadata table. 2022-08-30 19:04:58 +02:00
Camille GILLOT
927e58d633 Move VariantData to a metadata table. 2022-08-30 19:04:49 +02:00
Camille GILLOT
edd25c37c5 Simplify recursion scheme. 2022-08-30 19:04:41 +02:00
Camille GILLOT
73e9f37eaa Encode consts in metadata main loop. 2022-08-30 19:04:37 +02:00
Camille GILLOT
45ad22be8f Encode type in the main loop. 2022-08-30 19:04:04 +02:00
bors
fce6a7d66e Auto merge of #101195 - Dylan-DPC:rollup-rhjaz6r, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #99517 (Display raw pointer as *{mut,const} T instead of *-ptr in errors)
 - #99928 (Do not leak type variables from opaque type relation)
 - #100473 (Attempt to normalize `FnDef` signature in `InferCtxt::cmp`)
 - #100653 (Move the cast_float_to_int fallback code to GCC)
 - #100941 (Point at the string inside literal and mention if we need string inte…)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 14:52:02 +00:00
JeanCASPAR
79d4f09942
Change fatal diagnostic to an error.
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-08-30 14:26:09 +02:00
Dylan DPC
467d2c1833
Rollup merge of #100941 - lyming2007:issue-100584, r=oli-obk
Point at the string inside literal and mention if we need string inte…

…rpolation

	modified:   compiler/rustc_passes/src/liveness.rs
2022-08-30 16:56:10 +05:30
Dylan DPC
c57a932c3f
Rollup merge of #100653 - cuviper:fptoint_sat, r=michaelwoerister,antoyo
Move the cast_float_to_int fallback code to GCC

Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
2022-08-30 16:56:09 +05:30
Dylan DPC
15e2e5185a
Rollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnr
Attempt to normalize `FnDef` signature in `InferCtxt::cmp`

Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv.

This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright.

On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup.

This is stacked onto #100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed.

---

The code:
```rust
trait Foo { type Bar; }

impl<T> Foo for T {
    type Bar = i32;
}

fn foo<T>(_: <T as Foo>::Bar) {}

fn needs_i32_ref_fn(f: fn(&'static i32)) {}

fn main() {
    needs_i32_ref_fn(foo::<()>);
}
```

Before:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(<() as Foo>::Bar) {foo::<()>}`
```

After:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(i32) {foo::<()>}`
```
2022-08-30 16:56:08 +05:30
Dylan DPC
9cfd161cd5
Rollup merge of #99928 - compiler-errors:issue-99914, r=oli-obk
Do not leak type variables from opaque type relation

The "root cause" is that we call `InferCtxt::resolve_vars_if_possible` (3d9dd681f5) on the types we get back in `TypeError::Sorts` since I added a call to it in `InferCtxt::same_type_modulo_infer`. However if this `TypeError` comes from a `InferCtxt::commit_if_ok`, then it may reference type variables that do not exist anymore, which is problematic.

We avoid this by substituting the `TypeError` with the types we had before being generalized while handling opaques.

This is kinda gross, and I feel like we can get the same issue from other places where we generalize type/const inference variables. Maybe not? I don't know.

Fixes #99914
Fixes #99970
Fixes #100463
2022-08-30 16:56:07 +05:30
Dylan DPC
548ed409af
Rollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errors
Display raw pointer as *{mut,const} T instead of *-ptr in errors

The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
2022-08-30 16:56:06 +05:30
bors
230a8ee364 Auto merge of #98100 - bjorn3:use_object_for_bitcode_reading, r=wesleywiser
Use object instead of LLVM for reading bitcode from rlibs

Together with changes I plan to make as part of https://github.com/rust-lang/rust/pull/97485 this will allow entirely removing usage of LLVM's archive reader and thus allow removing `archive_ro.rs` and `ArchiveWrapper.cpp`.
2022-08-30 11:13:58 +00:00
Xiretza
31b939b315 Rework SessionSubdiagnostic derive to support multipart_suggestion 2022-08-30 12:18:43 +02:00
Takayuki Maeda
f6252a4862 remove path string 2022-08-30 19:06:19 +09:00
Jakob Degen
d56751cc34 Simplify pass manager's run_passes logic 2022-08-30 01:40:16 -07:00
Jakob Degen
aad14c701e Refactor MIR phases 2022-08-30 01:40:14 -07:00
bors
0631ea5d73 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #95376 (Add `vec::Drain{,Filter}::keep_rest`)
 - #100092 (Fall back when relating two opaques by substs in MIR typeck)
 - #101019 (Suggest returning closure as `impl Fn`)
 - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
 - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
 - #101123 (Remove `register_attr` feature)
 - #101175 (Don't --bless in pre-push hook)
 - #101176 (rustdoc: remove unused CSS selectors for `.table-display`)
 - #101180 (Add another MaybeUninit array test with const)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 08:29:42 +00:00
Xiretza
9dc0643744 SessionSubdiagnostic: make #[applicability] optional 2022-08-30 09:48:03 +02:00
Xiretza
6e8dad5c07 Use span_suggestion_with_style in SessionSubdiagnostic derive 2022-08-30 09:48:00 +02:00
Xiretza
8af7f4208a Code deduplication in tool_only_multipart_suggestion 2022-08-30 09:46:42 +02:00
Michael Goulet
5a4f7d4ad3 Tweak WellFormedLocs a bit 2022-08-30 06:19:48 +00:00
Dylan DPC
c18292f6a3
Rollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8Ki
Remove `register_attr` feature

Closes #66080

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-30 11:26:52 +05:30
Dylan DPC
81f3841cfb
Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``
2022-08-30 11:26:51 +05:30
Dylan DPC
1ea84961e8
Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726
Erase late bound regions before comparing types in `suggest_dereferences`

Fixes #101020
2022-08-30 11:26:50 +05:30
Dylan DPC
aa9bfdee32
Rollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillot
Suggest returning closure as `impl Fn`

Fixes #100936
2022-08-30 11:26:49 +05:30
Dylan DPC
e63424db19
Rollup merge of #100092 - compiler-errors:issue-100075, r=oli-obk
Fall back when relating two opaques by substs in MIR typeck

This is certainly _one_ way to fix #100075. Not really confident it's the _best_ way to do it, though.

The root cause of this issue is that during MIR type-check, we end up trying to equate an opaque against the same opaque def-id but with different substs. Because of the way that we replace RPITs during (HIR) typeck with an inference variable, we don't end up emitting a type-checking error, so the delayed MIR bug causes an ICE.

See the `src/test/ui/impl-trait/issue-100075-2.rs` test below to make that clear -- in that example, we try to equate `{impl Sized} substs=[T]` and `{impl Sized} substs=[Option<T>]`, which causes an ICE. This new logic will instead cause us to infer `{impl Sized} substs=[Option<T>]` as the hidden type for `{impl Sized} substs=[T]`, which causes a proper error to be emitted later on when we check that an opaque isn't recursive.

I'm open to closing this in favor of something else. Ideally we'd fix this in typeck, but the thing we do to ensure backwards compatibility with weird RPIT cases makes that difficult. Also open to discussing this further.
2022-08-30 11:26:48 +05:30
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
Donough Liu
97b1a6146c Use more into_iter rather than drain(..) 2022-08-30 04:42:03 +01:00
yukang
77eb1aef52 add UI test for unpretty 2022-08-30 09:31:52 +08:00
bors
9f4d5d2a28 Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #100898 (Do not report too many expr field candidates)
 - #101056 (Add the syntax of references to their documentation summary.)
 - #101106 (Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items)
 - #101131 (CTFE: exposing pointers and calling extern fn is just impossible)
 - #101141 (Simplify `get_trait_ref` fn used for `virtual_function_elimination`)
 - #101146 (Various changes to logging of borrowck-related code)
 - #101156 (Remove `Sync` requirement from lint pass objects)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-29 22:49:04 +00:00
Matthias Krüger
bf42ba41a4
Rollup merge of #101156 - Jarcho:remove_sync_lint_pass, r=compiler-errors
Remove `Sync` requirement from lint pass objects

This is blocking the clippy sync (#101140). One of the lint passes contains a `Cell` in order to make lifetimes work. It could be worked around, but this is the easier change to make if there are no objections.

Rational for removing the requirement
* All lint pass methods take `&mut self` arguments.
* Many passes depend on running is visitor order.
* Lint passes are created on demand so they're only ever stored in a local.
* `Send` is enough to lint different passes in parallel.

`LintStore` remains `Sync` with this. The constructor functions it contains still maintain their `Sync` requirement.

r? rust-lang/compiler
2022-08-29 21:13:00 +02:00
Matthias Krüger
7b84298f1b
Rollup merge of #101146 - jackh726:borrowck-logging, r=compiler-errors
Various changes to logging of borrowck-related code

Cleanups found when doing other changes

r? `@compiler-errors`
2022-08-29 21:12:59 +02:00
Matthias Krüger
3094cc1db0
Rollup merge of #101141 - compiler-errors:get-trait-ref-is-a-misleading-name, r=oli-obk
Simplify `get_trait_ref` fn used for `virtual_function_elimination`

1. The name `get_trait_ref` is misleading, so I renamed it to something more like `expect_...` because it ICEs if used incorrectly.
2. No need to manually go through the existential trait refs, we already have `.principal()` for that.
2022-08-29 21:12:58 +02:00
Matthias Krüger
cd53b4dba5
Rollup merge of #101131 - RalfJung:ctfe-no-needs-rfc, r=oli-obk
CTFE: exposing pointers and calling extern fn is just impossible

The remaining "needs RFC" errors are just needlessly confusing, I think -- time to get rid of that error variant. They are anyway only reachable with miri-unleashed (if at all).

r? `@oli-obk`
2022-08-29 21:12:57 +02:00
Matthias Krüger
091017c244
Rollup merge of #100898 - compiler-errors:too-many-expr-fields, r=spastorino
Do not report too many expr field candidates

When considering "this expressions' field has a {field/method}" suggestions:
1. Don't report methods that are out of scope
2. Use `span_suggestions` instead of reporting each field candidate, which caps the number of suggestions to 4
4. Blacklist some common traits like `Clone` and `Deref`

Fixes #100894
2022-08-29 21:12:54 +02:00
Yiming Lei
39ffabbb40 Point at the string inside literal and mention if we need string interpolation
modified:   compiler/rustc_passes/src/liveness.rs

	new file:   src/test/ui/type/issue-100584.rs
	new file:   src/test/ui/type/issue-100584.stderr
2022-08-29 11:58:20 -07:00
bors
bc4b39c271 Auto merge of #101152 - Dylan-DPC:rollup-v4iw8ux, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #98304 (Add MaybeUninit memset test)
 - #98801 (Add a `File::create_new` constructor)
 - #99821 (Remove separate indexing of early-bound regions)
 - #100239 (remove an ineffective check in const_prop)
 - #100337 (Stabilize `std::io::read_to_string`)
 - #100819 (Make use of `[wrapping_]byte_{add,sub}`)
 - #100934 (Remove a panicking branch from `fmt::builders::PadAdapter`)
 - #101000 (Separate CountIsStar from CountIsParam in rustc_parse_format.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-29 18:56:59 +00:00
nils
5021dcd799 Display raw pointer as *{mut,const} T instead of *-ptr in errors
The `*-ptr` is rather confusing, and we have the full information for
properly displaying the information.
2022-08-29 20:40:25 +02:00
Nilstrieb
01acfef1a4 Migrate stable let_chains error to session diagnostics 2022-08-29 19:49:30 +02:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Jack Huey
8033c3c27d Various changes to logging of borrowck-related code 2022-08-29 10:59:21 -04:00
Nilstrieb
96d4137dee Only normalize once in mir validator typechecker
Before, it called `normalize_erasing_regions` twice since
`equal_up_to_regions` called it as well for both types.
2022-08-29 16:29:53 +02:00
Nilstrieb
81a583c21e Try normalizing types without RevealAll in ParamEnv in mir validation
Before, the MIR validator used RevealAll in its ParamEnv for type
checking. This could cause false negatives in some cases due to
RevealAll ParamEnvs not always use all predicates as expected here.

Since some MIR passes like inlining use RevealAll as well, keep using
it in the MIR validator too, but when it fails usign RevealAll, also
try the check without it, to stop false negatives.
2022-08-29 16:27:52 +02:00
Jason Newcomb
74f2d582d2 Remove Sync requirement from lint pass objects as they are created on demand 2022-08-29 10:00:22 -04:00
Obei Sideg
1383f0e9af Make the trait bound is not satisfied specify kind 2022-08-29 16:53:36 +03:00
Ralf Jung
8b53abd602 interpret: fix unnecessary allocation in validation visitor 2022-08-29 08:05:20 -04:00
Dylan DPC
0b6faca670
Rollup merge of #101000 - m-ou-se:count-is-star, r=nagisa
Separate CountIsStar from CountIsParam in rustc_parse_format.

`rustc_parse_format`'s parser would result in the exact same output for `{:.*}` and `{:.0$}`, making it hard for diagnostics to handle these cases properly.

This splits those cases by adding a new `CountIsStar` enum variant.

This fixes #100995

Prerequisite for https://github.com/rust-lang/rust/pull/100996
2022-08-29 16:49:45 +05:30
Dylan DPC
395ce34a95
Rollup merge of #100819 - WaffleLapkin:use_ptr_byte_methods, r=scottmcm
Make use of `[wrapping_]byte_{add,sub}`

These new methods trivially replace old `.cast().wrapping_offset().cast()` & similar code.
Note that [`arith_offset`](https://doc.rust-lang.org/std/intrinsics/fn.arith_offset.html) and `wrapping_offset` are the same thing.

r? ``@scottmcm``

_split off from #100746_
2022-08-29 16:49:43 +05:30
Dylan DPC
3ea5456366
Rollup merge of #100239 - RalfJung:const-prop-uninit, r=oli-obk
remove an ineffective check in const_prop

Based on https://github.com/rust-lang/rust/pull/100043, only the last two commits are new.

ConstProp has a special check when reading from a local that prevents reading uninit locals. However, if that local flows into `force_allocation`, then no check fires and evaluation proceeds. So this check is not really effective at preventing accesses to uninit locals.

With https://github.com/rust-lang/rust/pull/100043, `read_immediate` and friends always fail when reading uninit locals, so I don't see why ConstProp would need a separate check. Thus I propose we remove it. This is needed to be able to do https://github.com/rust-lang/rust/pull/100085.
2022-08-29 16:49:40 +05:30
Dylan DPC
5555e13a6e
Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errors
Remove separate indexing of early-bound regions

~Based on https://github.com/rust-lang/rust/pull/99728.~

This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults.
These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-29 16:49:39 +05:30
bors
b96fa1a25c Auto merge of #98626 - oli-obk:tracing, r=lcnr
bump tracing version

Bump tracing dependency to 0.1.35 to give us features like printing the return value of functions
2022-08-29 11:13:42 +00:00
Nicholas Nethercote
78f83f0b46 Inline attrs. 2022-08-29 20:25:48 +10:00
Jakub Beránek
925644ed09
Track PGO profiles in depinfo 2022-08-29 10:56:56 +02:00
Nicholas Nethercote
c768617f6f Improve parse_dot_or_call_expr_with.
Avoid all the extra work in the very common case where `attrs` is empty.
2022-08-29 15:42:16 +10:00
Nicholas Nethercote
b38106b6d8 Replace rustc_data_structures::thin_vec::ThinVec with thin_vec::ThinVec.
`rustc_data_structures::thin_vec::ThinVec` looks like this:
```
pub struct ThinVec<T>(Option<Box<Vec<T>>>);
```
It's just a zero word if the vector is empty, but requires two
allocations if it is non-empty. So it's only usable in cases where the
vector is empty most of the time.

This commit removes it in favour of `thin_vec::ThinVec`, which is also
word-sized, but stores the length and capacity in the same allocation as
the elements. It's good in a wider variety of situation, e.g. in enum
variants where the vector is usually/always non-empty.

The commit also:
- Sorts some `Cargo.toml` dependency lists, to make additions easier.
- Sorts some `use` item lists, to make additions easier.
- Changes `clean_trait_ref_with_bindings` to take a
  `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this
  avoid some unnecessary allocations.
2022-08-29 15:42:13 +10:00
Matthias Krüger
3e5be57de8
Rollup merge of #101111 - saethlin:better-fnentry-spans, r=RalfJung
Use the declaration's SourceInfo for FnEntry retags, not the outermost

This addresses a long-standing `// FIXME` in the pass that adds retags.

The changes to Miri's UI tests will look like this:
```
   --> $DIR/aliasing_mut1.rs:LL:CC
    |
 LL | pub fn safe(_x: &mut i32, _y: &mut i32) {}
<   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
>   |                           ^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
    |
```

r? ````@RalfJung````
2022-08-29 06:34:48 +02:00
Matthias Krüger
6667754694
Rollup merge of #100959 - LuisCardosoOliveira:translation-rename-attr-warning, r=davidtwco
translations: rename warn_ to warning

## Description

This MR renames the the macro `warn_` to `warning`.

To give a little bit of context, as [explained](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20diag.20translation/near/295074146) by ```````@davidtwco``````` in the Zulip channel, `warn_`  was named like that because the keyword `warn` is a built-in attribute and at the time this macro was created the word `warning` was also
taken.

However, it is no longer the case and we can rename `warn_` to `warning`.
2022-08-29 06:34:47 +02:00
Matthias Krüger
d814fdd3f9
Rollup merge of #100897 - RalfJung:const-not-to-mutable, r=lcnr
extra sanity check against consts pointing to mutable memory

This should be both unreachable and redundant (since we already ensure that validation only reads from read-only memory, when validating consts), but I feel like we cannot be paranoid enough here, and also if this ever fails it'll be a nicer error than the "cannot read from mutable memory" error.
2022-08-29 06:34:46 +02:00
Matthias Krüger
a3c965f5fe
Rollup merge of #100843 - IntQuant:issue-100717-infer, r=compiler-errors
Migrate part of rustc_infer to session diagnostic
2022-08-29 06:34:45 +02:00
Matthias Krüger
26c86c6993
Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, r=oli-obk
Improve const mismatch `FulfillmentError`

Fixes #100414
2022-08-29 06:34:44 +02:00
Matthias Krüger
d182081de1
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Michael Goulet
72fe79244d Simplify get_trait_ref a bit 2022-08-29 04:19:14 +00:00
Nicholas Nethercote
f26fdce991 Improve HIR stats collector.
Adds and removes some `visit_*` methods accordingly, improving
coverage, and avoiding some double counting. Brings it in line with the
AST stats collector.
2022-08-29 14:16:53 +10:00
Nicholas Nethercote
0a52fbe536 Rename GenericArg::id as GenericArg::hir_id.
Because `hir_id` is the standard name for methods that return a `HirId`
from a HIR node.
2022-08-29 14:16:49 +10:00
Nicholas Nethercote
ad7b4d5d22 Move a comment to the right place.
This comment on the HIR `visit_path_segment` is supposed be on the AST
`visit_path_segment`.
2022-08-29 11:13:36 +10:00
Nicholas Nethercote
22379bd9db Use &'hir Mod everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
a847d5e4ce Use &'hir Ty everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
db35b685a7 Use &'hir Expr everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
854219d2ad Expand the HIR (and AST) size assertions. 2022-08-29 06:35:14 +10:00
Nicholas Nethercote
9ee0192095 Add prefix to every line of -Zhir-stats output.
This is based on `-Zprint-type-sizes` which does the same thing. It
makes the output provenance clearer, and helps with post-processing.
E.g. if you have `-Zhir-stats` output from numerous compiler invocations
you can now easily extract the pre-expansion stats separately from the
post-expansion stats.
2022-08-29 06:35:14 +10:00
bors
ce36e88256 Auto merge of #100497 - kadiwa4:remove_clone_into_iter, r=cjgillot
Avoid cloning a collection only to iterate over it

`@rustbot` label: +C-cleanup
2022-08-28 18:31:08 +00:00
Martin Nordholts
ddee45e1d7 Support #[unix_sigpipe = "inherit|sig_dfl|sig_ign"] on fn main()
This makes it possible to instruct libstd to never touch the signal
handler for `SIGPIPE`, which makes programs pipeable by default (e.g.
with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe`
errors.
2022-08-28 19:46:45 +02:00
Ralf Jung
f29c3c421b entirely get rid of NeedsRfc CTFE errors 2022-08-28 13:40:24 -04:00
Ralf Jung
a9f9145b09 CTFE: exposing pointers and calling extern fn doesn't need an RFC, it is just impossible 2022-08-28 13:32:48 -04:00
Ralf Jung
c46e803aaf improve OFFSET_IS_ADDR docs 2022-08-28 13:05:34 -04:00
Ralf Jung
1a1220c5e4 validation should only catch UB errors 2022-08-28 11:49:32 -04:00
Ben Kimock
cd1a42a95d Use the declaration's SourceInfo for FnEntry retags, not the outermost 2022-08-28 11:40:10 -04:00
Yuki Okushi
76dd5c58a0
Remove register_attr feature
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-28 21:23:23 +09:00
Hirochika Matsumoto
152913767a Support method calls 2022-08-28 17:51:28 +09:00
Matthias Krüger
0335909b4f
Rollup merge of #101098 - petrochenkov:noinvis, r=TaKO8Ki
rustc_middle: Remove `Visibility::Invisible`

It had a different meaning in the past, but now it's only used as an implementation detail of import resolution.
2022-08-28 09:35:22 +02:00
Matthias Krüger
3142996a46
Rollup merge of #101055 - TaKO8Ki:use-smaller-span, r=compiler-errors
Use smaller span for suggestions
2022-08-28 09:35:20 +02:00
Matthias Krüger
5b8081490f
Rollup merge of #101038 - RalfJung:interning-alignment, r=oli-obk
no alignment check during interning

This should fix https://github.com/rust-lang/rust/issues/101034
r? `@oli-obk`

Unfortunately we don't have a self-contained testcase for this problem. I am not sure how it can be triggered...
2022-08-28 09:35:19 +02:00
Matthias Krüger
c5770219f2
Rollup merge of #101002 - estebank:hashmap-idx, r=davidtwco
Provide structured suggestion for `hashmap[idx] = val`
2022-08-28 09:35:18 +02:00
Hirochika Matsumoto
75ed56f0cb Make CI pass 2022-08-28 16:18:44 +09:00
Hirochika Matsumoto
722d136766 Use hir::Map to prevent false positives 2022-08-28 16:05:44 +09:00
Sébastien Marie
1de5b22678 add riscv64gc-unknown-openbsd support (target riscv64-unknown-openbsd on OpenBSD)
- add platform-support documentation
- add riscv64gc-unknown-openbsd spec
- do not try to link with -latomic on openbsd
2022-08-28 05:22:21 +00:00
Sébastien Marie
dacb6ee7b0 add powerpc64-unknown-openbsd support 2022-08-28 05:16:02 +00:00
bors
91f128baf7 Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum
Move EH personality functions to std

These were previously in the panic_unwind crate with dummy stubs in the
panic_abort crate. However it turns out that this is insufficient: we
still need a proper personality function even with -C panic=abort to
handle the following cases:

1) `extern "C-unwind"` still needs to catch foreign exceptions with -C
panic=abort to turn them into aborts. This requires landing pads and a
personality function.

2) ARM EHABI uses the personality function when creating backtraces.
The dummy personality function in panic_abort was causing backtrace
generation to get stuck in a loop since the personality function is
responsible for advancing the unwind state to the next frame.

Fixes #41004
2022-08-28 04:16:29 +00:00
yukang
9678751a88 pretty printing give proper erro message without panic 2022-08-28 09:56:18 +08:00
bors
1e978a3627 Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm
Add pointer masking convenience functions

This PR adds the following public API:
```rust
impl<T: ?Sized> *const T {
    fn mask(self, mask: usize) -> *const T;
}

impl<T: ?Sized> *mut T {
    fn mask(self, mask: usize) -> *const T;
}

// mod intrinsics
fn mask<T>(ptr: *const T, mask: usize) -> *const T
```
This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic.

Proposed in https://github.com/rust-lang/rust/pull/95643#issuecomment-1121562352

cc `@Gankra` `@scottmcm` `@RalfJung`

r? rust-lang/libs-api
2022-08-28 01:34:47 +00:00
Michael Goulet
1256530643 More descriptive argument placeholders 2022-08-28 01:24:41 +00:00
Michael Goulet
18b640aee5 Suggest calling when operator types mismatch 2022-08-28 01:08:24 +00:00
Michael Goulet
2f78dd15a6 Suggest calling trait objects and parameters too, when possible 2022-08-27 23:08:44 +00:00
Amanieu d'Antras
a7e4794c2e Fix handling of rust_eh_personality in reachable_non_generics 2022-08-28 06:38:01 +08:00
Ralf Jung
2e172473da interpret: make read-pointer-as-bytes *always* work in Miri
and show some extra information when it happens in CTFE
2022-08-27 18:37:44 -04:00
Michael Goulet
703603a362 Only suggest call on nonexistent fields and methods if they make sense 2022-08-27 22:36:04 +00:00
Michael Goulet
0734200e80 Use autoderef 2022-08-27 21:23:06 +00:00
Michael Goulet
dca5f5bf8f Drive-by: Rename expr_t to base_ty 2022-08-27 21:23:06 +00:00
Vadim Petrochenkov
fc3f3c304b rustc_middle: Remove Visibility::Invisible 2022-08-27 22:34:18 +03:00
Ralf Jung
e63a625711 interpret: rename relocation → provenance 2022-08-27 14:11:19 -04:00
bors
eaadb8947b Auto merge of #100591 - est31:stabilization_placeholder, r=Mark-Simulacrum
Require stabilizations to use a placeholder instead of writing out stabilization version

Implements the idea from [this](https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/libs.20stabilization.20placeholder) zulip stream.

It's a common phenomenon that feature stabilizations don't make it into a particular release, but the version is still inaccurate. Often this is caught in the PR, but it can also require subsequent changes to adjust/correct the version. A list with examples of such PRs is given in #100577, but it's far from complete.

This PR requires stabilization PRs to use the placeholder `CURRENT_RUSTC_VERSION`, enforced via tidy tooling. The PR also adds a tool that replaces the placeholder with the version number. It can be invoked via `./x.py run src/tools/replace-version-placeholder` and is supposed to be ran upon beta branching as well as version bumping and any backports to the beta branch.  I filed PRs to the dev guide and forge to document these changes in the release and stabilization workflows:

* The [dev guide](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#determining-the-stabilization-version) PR: https://github.com/rust-lang/rustc-dev-guide/pull/1443
* The [std dev guide](https://std-dev-guide.rust-lang.org/) PR: https://github.com/rust-lang/std-dev-guide/pull/43
* The [forge](https://github.com/rust-lang/rust-forge) PR: https://github.com/rust-lang/rust-forge/pull/643

Alternative to #100577 which added checking.
2022-08-27 16:57:19 +00:00
Nicholas Bishop
1dd47b04c0 Set DebuginfoKind::Pdb in msvc_base
This PDB setting was added to `windows_msvc_base` in
https://github.com/rust-lang/rust/pull/98051. It's also needed for the
UEFI targets, and since `uefi_msvc_base` and `windows_msvc_base` are the
only things that inherit from `msvc_base`, just move the PDB setting up
to `mscv_base` to cover both.

Fixes https://github.com/rust-lang/rust/issues/101071
2022-08-27 11:44:35 -04:00
est31
4caedbae86 Adjust label break value stabilization version to CURRENT_RUSTC_VERSION 2022-08-27 17:36:13 +02:00
est31
7a5b1d7939 Expand the version placeholder to the current version in stability attribute parsing
That way, the current version is shown in rustdoc etc.
2022-08-27 17:08:52 +02:00
bors
332cc8fb75 Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3
Shrink `FnAbi`

Because they can take up a lot of memory in debug and release builds.

r? `@bjorn3`
2022-08-27 14:00:53 +00:00
Ralf Jung
aff9841507 remove a now-useless machine hook 2022-08-27 08:53:04 -04:00
Ralf Jung
4173e971b8 remove an ineffective check in const_prop 2022-08-27 08:53:04 -04:00
Vadim Petrochenkov
f4b5954764 rustc_target: Use Cow and link args helpers in apple_base 2022-08-27 15:30:05 +03:00
Vadim Petrochenkov
f0d0573db1 rustc_target: Do not specify some target options redundantly
These values are already inherited
2022-08-27 15:30:05 +03:00
Vadim Petrochenkov
2e83c22154 rustc_target: Add some more target spec sanity checking 2022-08-27 15:30:05 +03:00
bors
3b3f3b72c5 Auto merge of #100989 - lcnr:implied-bounds-uwu, r=spastorino
no unnormalized types for implied bounds outside borrowck

fixes #100910 - introduced in https://github.com/rust-lang/rust/pull/100676 - by only considering normalized types for wf.

r? types
2022-08-27 11:37:06 +00:00
bors
4065b89b1e Auto merge of #100946 - jyn514:query-system-3, r=cjgillot
Simplify the arguments to macros generated by the `rustc_queries` proc macro

Very small cleanup. Based on https://github.com/rust-lang/rust/pull/100436 which modifies some of the same code.

r? `@cjgillot`
2022-08-27 08:53:24 +00:00
Jean CASPAR
e89d4fcc7d remove span_fatal from ast_lowering 2022-08-27 09:15:55 +02:00
Takayuki Maeda
b33c3d6cd6 use smaller span for suggestions 2022-08-27 15:22:08 +09:00
bors
d0e1491ecd Auto merge of #101074 - JohnTitor:rollup-zwznihq, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #96240 (Stabilize `const_ptr_offset_from`.)
 - #99784 (Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default)
 - #100811 (Fix wrong compiletest filters on Windows)
 - #100924 (Smaller improvements of tidy and the unicode generator)
 - #100953 (Update documentation for `write!` and `writeln!`)
 - #101018 (rustdoc: omit start/end tags for empty item description blocks)
 - #101044 (rustdoc: remove unused CSS for `hidden-by-*-hider`)
 - #101046 (rustdoc: remove incorrect CSS selector `.impl-items table td`)
 - #101057 (Merge implementations of HIR fn_decl and fn_sig.)
 - #101062 (rustdoc: remove empty extern_crates and type="text/javascript" on script)
 - #101063 (Merge duplicated CSS rules)

Failed merges:

 - #101055 (Use smaller span for suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-27 06:12:17 +00:00
Yuki Okushi
aa6b750854
Rollup merge of #101057 - cjgillot:one-fn-sig, r=compiler-errors
Merge implementations of HIR fn_decl and fn_sig.
2022-08-27 13:14:24 +09:00
Yuki Okushi
134cc2d6be
Rollup merge of #99784 - est31:deny_cfg_attr_crate_type_name, r=Mark-Simulacrum
Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default

Turns the forward compatibility lint added by #83744 to deprecate `cfg_attr` usage with `#![crate_type]` and `#![crate_name]` attributes into deny by default. Copying the example from #83744:

```Rust
#![crate_type = "lib"] // remains working
#![cfg_attr(foo, crate_type = "bin")] // will stop working
```

Over 8 months have passed since #83744 was merged so I'd say this gives ample time for people to have been warned, so we can make the warning stronger. No usage was found via grep.app except for one, which was in an unmaintained code base that didn't seem to be used in the open source eco system. The crater run conducted in #83744 also didn't show up anything.

cc #91632 - tracking issue for the lint
2022-08-27 13:14:16 +09:00
Michael Goulet
eda91d9291 Sad 2022-08-27 03:42:24 +00:00
bors
9845f4c47e Auto merge of #100732 - dpaoliello:import_name_type, r=wesleywiser
Implementation of import_name_type

Fixes #96534 by implementing https://github.com/rust-lang/compiler-team/issues/525

Symbols that are exported or imported from a binary on 32bit x86 Windows can be named in four separate ways, corresponding to the [import name types](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type) from the PE-COFF spec. The exporting and importing binaries must use the same name encoding, otherwise mismatches can lead to link failures due to "missing symbols" or to 0xc0000139 (`STATUS_ENTRYPOINT_NOT_FOUND`) errors when the executable/library is loaded. For details, see the comments on the raw-dylib feature's https://github.com/rust-lang/rust/issues/58713. To generate the correct import libraries for these DLLs, therefore, rustc must know the import name type for each `extern` function, and there is currently no way for users to provide this information.

This change adds a new `MetaNameValueStr` key to the `#[link]` attribute called `import_name_type`, and which accepts one of three values: `decorated`, `noprefix`, and `undecorated`.

A single DLL is likely to export all its functions using the same import type name, hence `import_name_type` is a parameter of `#[link]` rather than being its own attribute that is applied per-function. It is possible to have a single DLL that exports different functions using different import name types, but users could express such cases by providing multiple export blocks for the same DLL, each with a different import name type.

Note: there is a fourth import name type defined in the PE-COFF spec, `IMPORT_ORDINAL`. This case is already handled by the `#[link_ordinal]` attribute. While it could be merged into `import_type_name`, that would not make sense as `#[link_ordinal]` provides per-function information (namely the ordinal itself).

Design decisions (these match the MCP linked above):
* For GNU, `decorated` matches the PE Spec and MSVC rather than the default behavior of `dlltool` (i.e., there will be a leading `_` for `stdcall`).
* If `import_name_type` is not present, we will keep our current behavior of matching the environment (MSVC vs GNU) default for decorating.
* Using `import_name_type` on architectures other than 32bit x86 will result in an error.
* Using `import_name_type` with link kinds other than `"raw-dylib"` will result in an error.
2022-08-27 03:19:12 +00:00
Michael Goulet
2820bc4b69 Revert "Remove deferred sized checks"
This reverts commit 33212bf7f5.
2022-08-27 03:02:05 +00:00
bors
bb8a08f011 Auto merge of #101064 - compiler-errors:rollup-fwm5m5f, r=compiler-errors
Rollup of 9 pull requests

Successful merges:

 - #100724 (Migrate ast lowering to session diagnostic)
 - #100735 (Migrate `rustc_ty_utils` to `SessionDiagnostic`)
 - #100738 (Diagnostics migr const eval)
 - #100744 (Migrate rustc_mir_dataflow to diagnostic structs)
 - #100776 (Migrate `rustc_lint` errors to `SessionDiagnostic`)
 - #100817 (sugg: suggest the usage of boolean value when there is a typo in the keyword)
 - #100836 (Migrate `rustc_attr` crate diagnostics)
 - #100890 (Migrate rustc_driver to SessionDiagnostic)
 - #100900 (on `region_errors.rs`)

Failed merges:

 - #100831 (Migrate `symbol_mangling` module to new diagnostics structs)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-27 00:38:06 +00:00
Michael Goulet
96ceadde76
Rollup merge of #100900 - AndyJado:diag-migrate, r=davidtwco
on `region_errors.rs`

`@rustbot` label +A-translation
2022-08-26 15:56:30 -07:00
Michael Goulet
e7d870b188
Rollup merge of #100890 - adriantombu:migrate_diagnostic_rustc_driver, r=davidtwco
Migrate rustc_driver to SessionDiagnostic

First timer noob here 👋🏽 I'm having a problem understanding how I can retrieve the span, and how to properly construct the error structs to avoid the current compilation errors.

Any help pointing me in the right direction would be much appreciated 🙌🏽
2022-08-26 15:56:29 -07:00
Michael Goulet
d97e616e21
Rollup merge of #100836 - hampuslidin:migrate-attr-crate-diagnostics, r=davidtwco
Migrate `rustc_attr` crate diagnostics

Hi!

This is my first PR to the rustc project, excited to be part of the development! This PR is part of the diagnostics effort, to make diagnostics translatable.

`@rustbot` label +A-translation
2022-08-26 15:56:28 -07:00
Michael Goulet
54744601bf
Rollup merge of #100817 - vincenzopalazzo:macros/bool_spelling_sugg, r=davidtwco
sugg: suggest the usage of boolean value when there is a typo in the keyword

Fixes https://github.com/rust-lang/rust/issues/100686

This adds a new suggestion when there is a well-known typo

With the following program

```rust
fn main() {
    let x = True;
}
```

Now we have the following suggestion

```
error[E0425]: cannot find value `True` in this scope
 --> test.rs:2:13
  |
2 |     let x = True;
  |             ^^^^ not found in this scope
  |
help: you may want to use a bool value instead
  |
2 |     let x = true;
  |             ~~~~

error: aborting due to previous error
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-26 15:56:26 -07:00
Michael Goulet
389dda149c
Rollup merge of #100776 - Rejyr:diagnostic-migration-rustc-lint, r=davidtwco
Migrate `rustc_lint` errors to `SessionDiagnostic`

Draft PR for migrating `rustc_lint` to `SessionDiagnostic`, as part of the [recent blog post](https://blog.rust-lang.org/inside-rust/2022/08/16/diagnostic-effort.html)
2022-08-26 15:56:25 -07:00
Michael Goulet
93b2acd88a
Rollup merge of #100744 - 5225225:migrate-rustc-mir-dataflow, r=davidtwco
Migrate rustc_mir_dataflow to diagnostic structs
2022-08-26 15:56:24 -07:00
Michael Goulet
b54344401a
Rollup merge of #100738 - nidnogg:diagnostics_migr_const_eval, r=davidtwco
Diagnostics migr const eval

This PR should eventually contain all diagnostic migrations for the `rustc_const_eval` crate.

r? `@davidtwco`
`@rustbot` label +A-translation
2022-08-26 15:56:23 -07:00
Michael Goulet
181b0410ec
Rollup merge of #100735 - Facel3ss1:ty-utils-translation, r=davidtwco
Migrate `rustc_ty_utils` to `SessionDiagnostic`

I have migrated the `rustc_ty_utils` crate to use `SessionDiagnostic`, motivated by the [recent blog post about the diagnostic translation effort](https://blog.rust-lang.org/inside-rust/2022/08/16/diagnostic-effort.html).

This is my first PR to the Rust repository, so if I have missed anything, or anything needs to be changed, please let me know! 😄

`@rustbot` label +A-translation
2022-08-26 15:56:22 -07:00
Michael Goulet
bc1d205e4c
Rollup merge of #100724 - JeanCASPAR:migrate-ast_lowering-to-session-diagnostic, r=davidtwco
Migrate ast lowering to session diagnostic

I migrated the whole rustc_ast_lowering crate to session diagnostic *except* the for the use of `span_fatal` at /compiler/rustc_ast_lowering/src/expr.rs#L1268 because `#[fatal(...)]` is not yet supported (see https://github.com/rust-lang/rust/pull/100694).
2022-08-26 15:56:21 -07:00
bors
2b443a8d97 Auto merge of #100043 - RalfJung:scalar-always-init, r=RalfJung
interpret: remove support for uninitialized scalars

With Miri no longer supporting `-Zmiri-allow-uninit-numbers`, we no longer need to support storing uninit data in a `Scalar`. We anyway already only use this representation for types with *initialized* `Scalar` layout (and we have to, due to partial initialization), so let's get rid of the `ScalarMaybeUninit` type entirely.

I tried to stage this into meaningful commits, but the one that changes `read_immediate` to always trigger UB on uninit is the largest chunk of the PR and I don't see how it could be subdivided.

Fixes https://github.com/rust-lang/miri/issues/2187
r? `@oli-obk`
2022-08-26 21:50:09 +00:00
5225225
3e567bcd4f Make invalid-value trigger on uninit primitives 2022-08-26 21:13:33 +01:00
Camille GILLOT
20012ea4eb Merge implementations of HIR fn_decl and fn_sig. 2022-08-26 21:38:20 +02:00
bors
c07a8b4e09 Auto merge of #101039 - ouz-a:issue-100991, r=compiler-errors
Don't catch overflow when running with cargo doc

Fixes #100991

r? `@compiler-errors`
2022-08-26 18:53:16 +00:00
ouz-a
36faf8fc7e Don't catch overflow when running with cargo doc 2022-08-26 21:02:35 +03:00
Nathan Stocks
a19139f9ff remove unnecessary comment 2022-08-26 11:45:09 -06:00
Ralf Jung
62b6a8b7b8 remove now-unused ScalarMaybeUninit 2022-08-26 13:20:57 -04:00
Ralf Jung
30fa931f92 make read_immediate error immediately on uninit, so ImmTy can carry initialized Scalar 2022-08-26 13:20:57 -04:00
Ralf Jung
2e52fe01cf remove some now-unnecessary parameters from check_bytes 2022-08-26 13:20:56 -04:00
Ralf Jung
da13935ecc remove enforce_number_init machine hook that Miri no longer needs 2022-08-26 13:20:56 -04:00
Ralf Jung
9d604f301b fix an outdated machine hook name 2022-08-26 13:20:56 -04:00
Daniel Paoliello
cc49c3e582 Implementation of import_name_type 2022-08-26 09:15:35 -07:00
bors
450e99f937 Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
session: stabilize split debuginfo on linux

Stabilize the `-Csplit-debuginfo` flag...

- ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance.
- ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable.
2022-08-26 15:47:26 +00:00
Luis Cardoso
2c77f3e9c5 translations(rustc_session): migrate check_expected_reuse
This commit migrates the errors in the function check_expected_reuse
to use the new SessionDiagnostic. It also does some small refactor
for the IncorrectCguReuseType to include the 'at least' word in the
fluent translation file
2022-08-26 16:10:11 +02:00
Luis Cardoso
d5262a9452 translations(rustc_session): migrate 80% of the file parse.rs
This commit migrates around 80% of the parse file to use SsessionDiagnostic
We still have to migrate struct_err and struct_warn.
2022-08-26 16:10:11 +02:00
Luis Cardoso
706452eba7 translations(rustc_session): migrate the file cgu_reuse_tracker
This commit migrates the errors that indicates an incorrect
CGU type and the fatal error that indicates that a CGU has
not been correctly recorded
2022-08-26 16:10:11 +02:00
Peter Medus
01c1616b25 Migrate rustc_ty_utils to use SessionDiagnostic 2022-08-26 14:36:51 +01:00
Tomasz Miąsko
b48870b451 Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Ralf Jung
b85178a5fc no alignment check during interning 2022-08-26 08:15:29 -04:00
bors
8a13871b69 Auto merge of #100944 - nnethercote:shrink-thir-Expr, r=cjgillot
Shrink `thir::Expr`

r? `@cjgillot`
2022-08-26 10:00:27 +00:00
Sébastien Marie
908ac84662 openbsd: rustc_target: reorder spec by name 2022-08-26 06:15:54 +00:00
bors
983f4daddf Auto merge of #100705 - compiler-errors:issue-100620, r=oli-obk
Avoid reporting overflow in `is_impossible_method`

Fixes #100620

We're evaluating a new predicate in a different param-env than it was checked during typeck, so be more careful about handling overflow errors. Instead of using `FulfillmentCtxt`, using `InferCtxt::evaluate_obligation` by itself will give us back the overflow error, so we can throw it away properly.

This may give us more false-positives, but it doesn't regress the `<HashMap as Iterator>::rev` example that originally motivated adding `is_impossible_method` in the first place.
2022-08-26 06:05:06 +00:00
Michael Goulet
48b3d8aa82 Drive-by: same_type_modulo_infer should handle ReVar == ReVar 2022-08-26 04:42:53 +00:00
Michael Goulet
cfd47afa19 Erase late bound regions before comparing types in suggest_dereferences 2022-08-26 04:42:36 +00:00
AndyJado
622217da59 diag-mig 2022-08-26 10:32:59 +08:00
Michael Goulet
448c6a4db7 Suggest returning closure as impl Fn 2022-08-26 01:25:56 +00:00
Nicholas Nethercote
f974617bda Move ArgAbi::pad_i32 into PassMode::Cast.
Because it's only needed for that variant. This shrinks the types and
clarifies the logic.
2022-08-26 11:12:36 +10:00
Nicholas Nethercote
b853e8a619 Turn ArgAbi::pad into a bool.
Because it's only ever set to `None` or `Some(Reg::i32())`.
2022-08-26 10:53:41 +10:00
Yuki Okushi
d4a5ec17a7
Rollup merge of #100978 - nnethercote:fix-100948, r=petrochenkov
Handle `Err` in `ast::LitKind::to_token_lit`.

Fixes #100948.

r? ``@petrochenkov``
2022-08-26 09:51:46 +09:00
Yuki Okushi
ba31a9b505
Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-se
Remove unstable Result::into_ok_or_err

Pending FCP: https://github.com/rust-lang/rust/issues/82223#issuecomment-1214920203

```@rustbot``` label +waiting-on-fcp
2022-08-26 09:51:44 +09:00
Yuki Okushi
55562c7ddc
Rollup merge of #100034 - tmiasko:elaborate-box-derefs, r=oli-obk
Elaborate all box dereferences in `ElaborateBoxDerefs`

so that it is the only pass responsible for elaboration, instead of
splitting this responsibility between the `StateTransform` and
`ElaborateBoxDerefs`.
2022-08-26 09:51:42 +09:00
Yuki Okushi
28457e10f5
Rollup merge of #99920 - emarteca:custom-allocator-support, r=oli-obk
Custom allocator support in `rustc_serialize`

Adding support for `rustc_serialize` encode/decode for `Box` and `Vec` that use a custom allocator.
2022-08-26 09:51:41 +09:00
Yuki Okushi
f7f80c27f2
Rollup merge of #99064 - lyming2007:issue-97687-fix, r=estebank
distinguish the method and associated function diagnostic information

Methods are defined within the context of a struct and their first parameter is always self
Associated functions don’t take self as a parameter
```
	modified:   compiler/rustc_typeck/src/check/method/suggest.rs
	modified:   src/test/ui/auto-ref-slice-plus-ref.stderr
	modified:   src/test/ui/block-result/issue-3563.stderr
	modified:   src/test/ui/issues/issue-28344.stderr
	modified:   src/test/ui/suggestions/dont-suggest-pin-array-dot-set.stderr
	modified:   src/test/ui/suggestions/suggest-methods.stderr
	modified:   src/test/ui/traits/trait-upcasting/subtrait-method.stderr
```
2022-08-26 09:51:40 +09:00
Nicholas Nethercote
feeaa4db3c Simplify arg capacity calculations.
Currently they try to be very precise. But they are wrong, i.e. they
don't match what's happening in the loop below. This code isn't hot
enough for it to matter that much.
2022-08-26 10:45:45 +10:00
Nicholas Nethercote
b75b3b3afe Change FnAbi::args to a boxed slice. 2022-08-26 10:30:36 +10:00
Nicholas Nethercote
4df7bffa95 Change FnAbi::fixed_count to a u32. 2022-08-26 10:29:40 +10:00
Michael Goulet
e5602cb2a0 Add and use ObligationCtxt::new_in_snapshot 2022-08-26 00:10:38 +00:00
Nicholas Nethercote
e4bf113027 Box CastTarget within PassMode.
Because `PassMode::Cast` is by far the largest variant, but is
relatively rare.

This requires making `PassMode` not impl `Copy`, and `Clone` is no
longer necessary. This causes lots of sigil adjusting, but nothing very
notable.
2022-08-26 09:35:28 +10:00
Michael Goulet
fee9e9b9d3 Do not leak variables from probe 2022-08-25 23:32:46 +00:00
Michael Goulet
075b3ce89d Attempt to normalize FnDef signature in InferCtxt::cmp 2022-08-25 23:32:46 +00:00
Michael Goulet
e69cad449a Use real inference variable in build_fn_sig_ty 2022-08-25 23:32:46 +00:00
Michael Goulet
c655d4b233 Don't create an extra infcx in report_closure_arg_mismatch 2022-08-25 23:32:46 +00:00
Nicholas Nethercote
263c426bfd Add size assertions for FnAbi and ArgAbi. 2022-08-26 09:30:30 +10:00
bors
cfb5ae26a4 Auto merge of #100748 - SparrowLii:query_depth, r=cjgillot
add `depth_limit` in `QueryVTable` to avoid entering a new tcx in `layout_of`

Fixes #49735
Updates #48685

The `layout_of` query needs to check whether it overflows the depth limit, and the current implementation needs to create a new `ImplicitCtxt` inside `layout_of`. However, `start_query` will already create a new `ImplicitCtxt`, so we can check the depth limit in `start_query`.

We can tell whether we need to check the depth limit simply by whether the return value of `to_debug_str` of the query is `layout_of`. But I think adding the `depth_limit` field in `QueryVTable` may be more elegant and more scalable.
2022-08-25 21:27:38 +00:00
Ellen Arteca
258d3672f0 Adding support for rustc_serialize encode and decode for Box and Vec that use a custom allocator 2022-08-25 20:19:49 +00:00
Michael Goulet
c3f568b331 Do not report too many expr field candidates 2022-08-25 18:59:48 +00:00
Nathan Stocks
82d609c8df have LangItemError derive everything LangItem does 2022-08-25 11:06:45 -06:00
Nathan Stocks
6cdfdd02f6 adjust to new error value 2022-08-25 11:06:45 -06:00
Nathan Stocks
30c7506655 allow non-monomorphize modules to access hard-coded error message through new struct, use fluent message in monomorphize 2022-08-25 11:06:45 -06:00
Nathan Stocks
33cbbc2789 remove stray comment 2022-08-25 11:06:45 -06:00
Nathan Stocks
40f44736e8 replace some usages of [Span]FatalError with error-specific types 2022-08-25 11:06:45 -06:00
Nathan Stocks
137f20c112 rebased: convert rustc_monomorphize errors to SessionDiagnostic 2022-08-25 11:06:32 -06:00
Adrian Tombu
d0401f7f47
Code cleaning 2022-08-25 19:04:00 +02:00
Adrian Tombu
bf7ce6a1a6
Replace spaghetti with a simple errors enum 2022-08-25 18:06:12 +02:00
Adrian Tombu
3f883b850d
Start adding enum errors for deserialize_rlink 2022-08-25 18:06:12 +02:00
Adrian Tombu
1c575c5fe0
Use std::io::Error and remove useless to_string 2022-08-25 18:06:12 +02:00
Adrian Tombu
e7ded9246c
Fixes fmt & SessionDiagnostic structs 2022-08-25 18:06:12 +02:00
Adrian Tombu
dbe39d835e
Start moving rustc_driver to SessionDiagnostic 2022-08-25 18:06:11 +02:00
Esteban Küber
752902957b Provide structured suggestion for hashmap[idx] = val 2022-08-25 08:44:36 -07:00
Mara Bos
1b044da5bb Separate CountIsStar from CountIsParam in rustc_parse_format. 2022-08-25 14:49:09 +02:00
lcnr
ef7bda3b62 no unnormalized types for implied bounds 2022-08-25 11:12:04 +02:00
Tomasz Miąsko
4394ea8b82 Inline trivial From<Local> for Place<'_> impl 2022-08-25 10:38:00 +02:00
Tomasz Miąsko
58eabb291d Add method that applies DefUse effect 2022-08-25 10:38:00 +02:00
Tomasz Miąsko
4462b4af52 Elaborate all box dereferences in ElaborateBoxDerefs
so that it is the only pass responsible for elaboration, instead of
splitting this responsibility between the `StateTransform` and
`ElaborateBoxDerefs`.
2022-08-25 10:38:00 +02:00
bors
4d45b0745a Auto merge of #100571 - cjgillot:mir-cost-visit, r=compiler-errors
Check projection types before inlining MIR

Fixes https://github.com/rust-lang/rust/issues/100550

I'm very unhappy with this solution, having to duplicate MIR validation code, but at least it removes the ICE.

r? `@compiler-errors`
2022-08-25 08:16:43 +00:00
bors
76531befc4 Auto merge of #100436 - jyn514:macro-query-system, r=cjgillot
try and simplify some things in the query system
2022-08-25 05:35:27 +00:00
Tomasz Miąsko
31d892a942 Fix liveness analysis for yield terminators
A resume place is evaluated and assigned to only after a yield
terminator resumes. Ensure that locals used when evaluating the
resume place are live across the yield.
2022-08-25 07:12:16 +02:00
bors
9b9bc63599 Auto merge of #100977 - JohnTitor:rollup-8hc7rxh, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #99332 (Stabilize `#![feature(label_break_value)]`)
 - #99954 (let-else: break out to one scope higher for let-else)
 - #100188 (Parser will not suggest invalid expression when use public)
 - #100780 (save_analysis: Migrate diagnostic)
 - #100808 (Migrate `rustc_interface` diagnostics )
 - #100921 (Add a warning about `Option/Result::and()` being eagerly evaluated)
 - #100960 (rustdoc: ayu code color selector more specific)
 - #100964 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-25 02:32:11 +00:00
Nicholas Nethercote
b997af95fc Handle Err in ast::LitKind::to_token_lit.
Fixes #100948.
2022-08-25 10:50:39 +10:00
bors
5462da52ba Auto merge of #99946 - tmiasko:elide-storage-makers, r=oli-obk
Elide superfluous storage markers

Follow the existing strategy of omitting the storage markers for temporaries
introduced for internal usage when elaborating derefs and deref projections.

Those temporaries are simple scalars which are used immediately after being
defined and never have their address taken. There is no benefit from storage
markers from either liveness analysis or code generation perspective.
2022-08-24 23:51:06 +00:00
Yuki Okushi
f2878a656b
Rollup merge of #100964 - bjorn3:sync_cg_clif-2022-08-24, r=bjorn3
Sync rustc_codegen_cranelift

The main highlights this time are support for parallel compilation of codegen units (by me) and improved windows support (by ``@afonso360)`` In addition ``@afonso360`` added abi-checker to cg_clif's CI. This has already catched an abi compatibility issue with AArch64. The fix has landed on Cranelift's main branch, but doesn't yet have a release. ``@uweigand`` also submitted a couple of PR's that will are prerequisites for supporting IBM's s390x architecture.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler
2022-08-25 08:51:01 +09:00
Yuki Okushi
0fd4a74139
Rollup merge of #100808 - SkiFire13:migrate_diagnostics_rustc_interface, r=davidtwco
Migrate `rustc_interface` diagnostics

``@rustbot`` label +A-translation

r? rust-lang/diagnostics
cc #100717
2022-08-25 08:50:58 +09:00
Yuki Okushi
2e4760c7e7
Rollup merge of #100780 - wonchulee:translation_save_analysis, r=davidtwco
save_analysis: Migrate diagnostic

* Migrate the `rustc_save_analysis` crate's diagnostic to translatable diagnostic structs.

Depends on https://github.com/rust-lang/rust/pull/100694 and https://github.com/rust-lang/rust/pull/100754 for #[fatal(..)] support, then aa68eb4179, f5219a3960, 7da52f694a can be removed. (I copied commits from https://github.com/rust-lang/rust/pull/100754)
2022-08-25 08:50:57 +09:00
Yuki Okushi
ed8cfc86a2
Rollup merge of #100188 - chenyukang:fix-issue-100165, r=estebank
Parser will not suggest invalid expression when use public

Fixes #100165
2022-08-25 08:50:56 +09:00
Yuki Okushi
b3f178350a
Rollup merge of #99954 - dingxiangfei2009:break-out-let-else-higher-up, r=oli-obk
let-else: break out to one scope higher for let-else

```@est31``` This PR follows up with #99518 which is to break out to the last remainder scope. It breaks to the out-most `region_scope` of the block if the first statement is a `let-else`.
2022-08-25 08:50:55 +09:00
Yuki Okushi
f4550a6edf
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov
Stabilize `#![feature(label_break_value)]`

See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.
2022-08-25 08:50:54 +09:00
bors
addacb5878 Auto merge of #100963 - matthiaskrgr:rollup-pjr0lb3, r=matthiaskrgr
Rollup of 15 pull requests

Successful merges:

 - #99993 (linker: Update some outdated comments)
 - #100220 (Properly forward `ByRefSized::fold` to the inner iterator)
 - #100826 (sugg: take into count the debug formatting)
 - #100855 (Extra documentation for new formatting feature)
 - #100888 (Coherence negative impls implied bounds)
 - #100901 (Make some methods private)
 - #100906 (Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing)
 - #100912 (Diagnose missing includes in run-make tests)
 - #100919 (Use par_body_owners for liveness)
 - #100922 (Rewrite error index generator to greatly reduce the size of the pages)
 - #100926 (Update README.md)
 - #100930 (Use `--userns=keep-id` when "docker" is really podman)
 - #100938 (rustdoc: remove unused CSS rule)
 - #100940 (Do not suggest adding a bound to a opaque type)
 - #100945 (Add a missing test case for impl generic mismatch)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-24 19:54:22 +00:00
Michael Goulet
8189a4536b Use ExprItemObligation and ExprBindingObligation too 2022-08-24 17:53:35 +00:00
Michael Goulet
4ff587263e Note binding obligation causes for const equate errors 2022-08-24 17:53:35 +00:00
Michael Goulet
4e976262a1 Call them constants instead of types 2022-08-24 17:53:35 +00:00
Luis Cardoso
b508b50617 translations: rename warn_ to warning
The macro warn_ was named like that because it the
keyword warn is a built-in attribute and at the time
this macro was created the word 'warning' was also
taken.

However it is no longer the case and we can rename
warn_ to warning.
2022-08-24 19:12:36 +02:00
bjorn3
e62e1d4347 Rustfmt 2022-08-24 17:06:47 +00:00
bors
ebfc7aa531 Auto merge of #100803 - klensy:do-not-encode-preinterned-symbols, r=bjorn3
Symbols: do not write string values of preinterned symbols into compiled artifacts

r? `@bjorn3`

Followup for #98851

https://github.com/rust-lang/rust/pull/98851#issuecomment-1215606291
2022-08-24 16:56:32 +00:00
bjorn3
7b9c8c8781 Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24 2022-08-24 18:40:58 +02:00
Michael Benfield
12a9914a86 Remove LLVM ARM bug workaround
This memset was inserted as a workaround to Rust issue #34427, which was
an LLVM bug that apparently no longer manifests.
2022-08-24 16:34:33 +00:00
Matthias Krüger
75b1b69171
Rollup merge of #100940 - TaKO8Ki:do-not-suggest-adding-bound-to-opaque-type, r=fee1-dead
Do not suggest adding a bound to a opaque type

fixes #100442
2022-08-24 18:20:20 +02:00
Matthias Krüger
8cdf4080c1
Rollup merge of #100919 - sanxiyn:parallel-liveness, r=oli-obk
Use par_body_owners for liveness

I did this refactoring while working on something else. Liveness is about bodies, there is no reason to use par_for_each_module here.

Tests are updated because things are visited in a different order. I checked diagnostics are same, just in a different (and IMO, better) order.
2022-08-24 18:20:15 +02:00
Matthias Krüger
95135bed61
Rollup merge of #100906 - ChayimFriedman2:map-index-mut, r=davidtwco
Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing

The error can be quite confusing to newcomers.

Fixes #100873.

I'm not so sure about the message, open to wording suggestions.
2022-08-24 18:20:13 +02:00
Matthias Krüger
1c0f60f904
Rollup merge of #100901 - TaKO8Ki:make-some-methods-private, r=sanxiyn
Make some methods private
2022-08-24 18:20:12 +02:00
Matthias Krüger
0fcabec620
Rollup merge of #100888 - spastorino:coherence-negative-impls-implied-bounds, r=lcnr
Coherence negative impls implied bounds

Fixes #93875

This PR is rebased on top of #100789 and it would need to include that one which is already r+ed.

r? ``@nikomatsakis``

cc ``@lcnr`` (which I've talked about 3222f420d9, I guess after you finish your reordering of modules and work with OutlivesEnvironmentEnv this commit can just be reverted).
2022-08-24 18:20:11 +02:00
Matthias Krüger
f8e128f8ad
Rollup merge of #100826 - vincenzopalazzo:macros/wrong_sugg_with_positional_arg, r=TaKO8Ki
sugg: take into count the debug formatting

Closes https://github.com/rust-lang/rust/issues/100648

This PR will fix a suggestion error by taking into consideration also the `:?` symbol and act in a different way

``@rustbot`` r? ``@compiler-errors``

N.B: I did not find a full way to test the change, any idea?
2022-08-24 18:20:09 +02:00
Matthias Krüger
bc05045a01
Rollup merge of #99993 - petrochenkov:linkdated, r=bjorn3
linker: Update some outdated comments

r? ``@bjorn3``
2022-08-24 18:20:07 +02:00
IQuant
e1765a9c56
Remove commented lines 2022-08-24 17:09:07 +03:00
Nikita Tomashevich
3fae3904b1
Use IntoDiagnosticArg where it makes sense 2022-08-24 15:46:29 +03:00
Joshua Nelson
b061550ed3 Remove the $tcx:tt parameter from rustc_query_description
It's unnecessary.
2022-08-24 00:37:49 -05:00
Joshua Nelson
7b8e2a52ff Simplify the syntax for macros generated by rustc_queries
- Disallow multiple macros callbacks in the same invocation. In practice, this was never used.
- Remove the `[]` brackets around the macro name
- Require an `ident`, not an arbitrary `tt`
2022-08-24 00:37:49 -05:00
Nicholas Nethercote
5a41eb81ca Add some more THIR size assertions. 2022-08-24 15:06:50 +10:00
Nicholas Nethercote
e3755c1d54 Rename thir::Adt as thir::AdtExpr.
This matches the naming scheme used elsewhere, e.g. in the AST, and
avoids name clashes with the `ExprKind::Closure` variant.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
e57ac764b8 Box thir::ExprKind::InlineAsm.
This shrinks `thir::Expr`.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
b3245a8dff Box thir::ExprKind::Closure.
This shrinks `thir::Expr`.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
2df805fc7a Store blocks in Thir.
Like expressions, statements, and match arms. This shrinks `thir::Stmt`
and is a precursor to further shrinking `thir::Expr`.
2022-08-24 15:06:44 +10:00
Nicholas Nethercote
e7c25c3a97 Box user_ty fields in thir::ExprKind.
This shrinks several large variants of `ExprKind`.
2022-08-24 14:16:09 +10:00
Joshua Nelson
e188868014 get rid of another unnecessary lifetime macro argument 2022-08-23 21:52:29 -05:00
Joshua Nelson
0bedd354ca Move most of make_query into a generic function, away from the macro
This should both make the code easier to read and also greatly reduce the amount of codegen
the compiler has to do, since it only needs to monomorphize `create_query_frame` for each
new key and not for each query.
2022-08-23 21:52:29 -05:00
Takayuki Maeda
3855e039a2 do not suggest adding a bound to a opaque type 2022-08-24 11:34:14 +09:00
Joshua Nelson
1de08b19d1 Get rid of some usages of query_keys
Rustdoc documents these with the name of the type alias instead of normalizing them to the underlying type.
Use associated types instead so that the generated docs for nightly-rustc are easier to read.
2022-08-23 21:33:52 -05:00
Joshua Nelson
b53761969f Remove $tcx metavariable from rustc_query_append
It's not actually necessary and it makes the code harder to read.
2022-08-23 21:33:19 -05:00
Joshua Nelson
31e39446ec Stabilize #![feature(label_break_value)]
# Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - d695a497bb/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - 6b2d3d5f3c/compiler/rustc_parse/src/parser/diagnostics.rs (L2629)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L749)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L1001)
    - 111df9e6ed/compiler/rustc_passes/src/loops.rs (L254)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L2079)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L1569)
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23 21:14:12 -05:00
SparrowLii
cbc6bd2019 add depth_limit in QueryVTable 2022-08-24 09:42:12 +08:00
Nicholas Nethercote
c9429b1cec Define index types within thir_with_elements.
The macro already generates other stuff, might as well generate these
index types as well.
2022-08-24 11:37:56 +10:00
bors
87991d5f5d Auto merge of #100675 - Xiretza:fluent-mandate-crate-prefix, r=davidtwco
fluent: mandate slug names to be prefixed by crate name

This is currently only convention, but not actively checked for.

Additionally, improve error messages to highlight the path of the offending fluent file rather than the identifier preceding it.

This will conflict with #100671, so I'll leave it as draft until that's merged.
2022-08-23 22:30:07 +00:00