Commit graph

233 commits

Author SHA1 Message Date
Jack Huey c6e4284f8b Add comments to opportunistic resolve functions 2021-05-15 23:36:10 -04:00
Jack Huey 909d0e83d6 Missed a couple things 2021-05-15 12:26:50 -04:00
Jack Huey fb6cec440a Revert to only using opportunistic_resolve_vars for existing places 2021-05-15 12:10:56 -04:00
Jack Huey 61157b341e Store Option<Region> as value for RegionVid 2021-05-14 21:48:32 -04:00
Jack Huey e8c284ff28 Make the UnifyValue for RegionVid () 2021-05-14 18:17:13 -04:00
Aaron Hill bc6330d47a
Don't suggest adding 'static lifetime to arguments
Fixes #69350

This is almost always the wrong this to do
2021-05-12 21:43:09 -04:00
bors e1ff91f439 Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12 11:05:56 +00:00
lcnr 513c56a611 remove unused variant 2021-05-06 14:59:53 +02:00
Andy Wang 5417b45c26
Use local and remapped paths where appropriate 2021-05-05 15:31:28 +01:00
Jack Huey 5f82e22ba4 Don't rebind in transitive_bounds_that_define_assoc_type 2021-04-28 18:10:44 -04:00
bors b56b175c6c Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk
further split up const_fn feature flag

This continues the work on splitting up `const_fn` into separate feature flags:
* `const_fn_trait_bound` for `const fn` with trait bounds
* `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here)

I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more.

`@oli-obk` are you currently able to do reviews?
2021-04-24 23:16:03 +00:00
klensy f43ee8ebf6 fix few typos 2021-04-19 15:57:08 +03:00
Ralf Jung bd9556956a fix feature use in rustc libs 2021-04-18 22:05:45 +02:00
pierwill 0019ca9141 Fix outdated crate names in compiler docs
Changes `librustc_X` to `rustc_X`, only in documentation comments.
Plain code comments are left unchanged.

Also fix incorrect file paths.
2021-04-08 11:12:14 -05:00
bors 0978a9eb99 Auto merge of #83207 - oli-obk:valtree2, r=lcnr
normalize mir::Constant differently from ty::Const in preparation for valtrees

Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation.

In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system.

cc `@rust-lang/wg-const-eval`

r? `@lcnr`
2021-04-02 10:28:12 +00:00
Jack Huey 6d5efa9f04 Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
Jack Huey 666859a6f8 Make late and late_anon regions track the bound var position 2021-03-31 10:15:56 -04:00
Jack Huey 62a49c3bb8 Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
Jack Huey 4955d755d3 Some rebinds and dummys 2021-03-31 10:05:32 -04:00
Oli Scherer dbacfbc368 Add a new normalization query just for mir constants 2021-03-31 10:40:42 +00:00
Dylan DPC 7d888d100f
Rollup merge of #83654 - JohnTitor:issue-83606, r=estebank
Do not emit a suggestion that causes the E0632 error

Fixes #83606
2021-03-31 01:14:46 +02:00
JohnTitor 7e6fd40614 Do not emit a suggestion that causes the E0632 error 2021-03-30 03:00:25 +09:00
Joshua Nelson de0fda9558 Address review comments
- Add back `HirIdVec`, with a comment that it will soon be used.
- Add back `*_region` functions, with a comment they may soon be used.
- Remove `-Z borrowck_stats` completely. It didn't do anything.
- Remove `make_nop` completely.
- Add back `current_loc`, which is used by an out-of-tree tool.
- Fix style nits
- Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27 22:16:34 -04:00
Joshua Nelson 441dc3640a Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Dylan DPC b2e254318d
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27 20:37:07 +01:00
Bastian Kauschke 42150fb8a1 combine: stop eagerly evaluating consts 2021-03-27 16:38:23 +01:00
Josh Stone 72ebebe474 Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
kadmin 33370fd982 Update to not have extra match 2021-03-23 20:01:40 +00:00
kadmin 7116bb5c33 Update with comments 2021-03-23 17:16:20 +00:00
kadmin ea2af70466 Update with comments
A bunch of nits fixed, and a new test for pretty printing the AST.
2021-03-23 17:16:20 +00:00
varkor 8ef81388e2 Some refactoring 2021-03-23 17:16:20 +00:00
kadmin e4e5db4e42 Add has_default to GenericParamDefKind::Const
This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs
2021-03-23 17:16:20 +00:00
bors 5d04957a4b Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22 19:48:27 +00:00
lcnr 7c9b5b4ce0 update const_eval_resolve 2021-03-20 17:22:24 +01:00
mark db5629adcb stabilize or_patterns 2021-03-19 19:45:32 -05:00
Vadim Petrochenkov 38ed36bba4 hir: Preserve used syntax in TyKind::TraitObject 2021-03-18 03:02:32 +03:00
Vadim Petrochenkov 7e66e9d6b0 More precise spans for HIR paths 2021-03-15 22:13:45 +03:00
Harald van Dijk 95e096d623
Change x64 size checks to not apply to x32.
Rust contains various size checks conditional on target_arch = "x86_64",
but these checks were never intended to apply to
x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the
conditions.
2021-03-06 16:02:48 +00:00
Joshua Nelson 6873831139
Rollup merge of #82635 - pierwill:edit-infer, r=oli-obk
Fix typos in rustc_infer::infer::nll_relate
2021-03-01 11:25:10 -05:00
pierwill ebe798e31e Fix typos in rustc_infer::infer::nll_relate 2021-02-28 10:10:58 -08:00
Yuki Okushi 5091209750 Fix a typo in the find_anon_type doc 2021-02-28 23:10:55 +09:00
Dylan DPC f0c98b15cc
Rollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank
Improve anonymous lifetime note to indicate the target span

Improvement for  #81650
Cc #81995

Message after this improvement:
(Improve note in the middle)

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40...
  --> src/main.rs:24:40
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |                                        ^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```

r? ``````@estebank``````
2021-02-27 02:34:22 +01:00
Nell Shamrell 356beb3084 clarifies error when finding mismatched returned types for async functions
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2021-02-24 18:46:54 -08:00
0yoyoyo ce1a521012 Apply tidy check 2021-02-21 22:51:49 +09:00
0yoyoyo 17176ccd78 Add indication of anonymous lifetime position 2021-02-21 18:38:20 +09:00
0yoyoyo fece59b56c Change find_anon_type method to function 2021-02-21 18:29:14 +09:00
Dylan DPC f468fd1d23
Rollup merge of #81496 - guswynn:expected_async_block, r=oli-obk
name async generators something more human friendly in type error diagnostic

fixes #81457

Some details:

1. I opted to load the generator kind from the hir in TyCategory. I also use 1 impl in the hir for the descr
2. I named both the source of the future, in addition to the general type (`future`), not sure what is preferred
3. I am not sure what is required to make sure "generator" is not referred to anywhere. A brief `rg "\"generator\"" showed me that most diagnostics correctly distinguish from generators and async generator, but the `descr` of `DefKind` is pretty general (not sure how thats used)
4. should the descr impl of AsyncGeneratorKind use its display impl instead of copying the string?
2021-02-19 02:49:00 +01:00
Dylan DPC 66211f6657
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Ensure valid TraitRefs are created for GATs

This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`.

r? ````@jackh726````
2021-02-18 16:57:34 +01:00
Yuki Okushi ce6367f479
Rollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC
remove useless ?s (clippy::needless_question_marks)

Example code:
```rust
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```
2021-02-18 15:57:33 +09:00
Dylan DPC cdd93fd3e2
Rollup merge of #81972 - matthewjasper:hrtb-error-cleanup, r=nikomatsakis
Placeholder lifetime error cleanup

- Remove note of trait definition
- Avoid repeating the same self type
- Use original region names when possible
- Use this error kind more often
- Print closure signatures when they are suppose to implement `Fn*` traits

Works towards #57374

r? ```@nikomatsakis```
2021-02-17 23:51:18 +01:00