Commit graph

993 commits

Author SHA1 Message Date
bors
301ad8a4fa Auto merge of #80891 - cjgillot:noq, r=Mark-Simulacrum
Make the `Query` enum a simple struct.

A lot of code in `rustc_query_system` is generic over it, only to encode an exceptional error case: query cycles.
The delayed computations are now done at cycle detection.
2021-02-24 03:29:00 +00:00
Ellen
42cbfd6346 yeet 2021-02-23 23:35:59 +00:00
kadmin
899f27d272 Small optimizations to obligation forest 2021-02-23 07:16:42 +00:00
Dylan DPC
cc07061190
Rollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJung
use PlaceRef abstractions more consistently

Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715)
Associated issue: #80647

r? ```@RalfJung```
2021-02-23 02:51:50 +01:00
Simon Vandel Sillesen
a6dccfeb23 New mir-opt pass to simplify gotos with const values
Fixes #77355
2021-02-22 21:03:57 +01:00
bors
15598a83db Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obk
MIR-OPT: Pass to deduplicate blocks

This pass finds basic blocks that are completely equal,
and replaces all uses with just one of them.

```bash
$ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log
...
$ cat log | wc -l
23875
```
2021-02-22 12:14:23 +00:00
Yuki Okushi
50a2de233a
Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank
Fix sizes of repr(C) enums on hexagon

Enums on hexagon use a smallest size (but at least 1 byte) that fits all
the enumeration values. This is unlike many other ABIs where enums are
at least 32 bits.

Fixes #82100
2021-02-22 18:26:13 +09:00
Simonas Kazlauskas
7130e462ee Fix sizes of repr(C) enums on hexagon
Enums on hexagon use a smallest size (but at least 1 byte) that fits all
the enumeration values. This is unlike many other ABIs where enums are
at least 32 bits.
2021-02-22 01:05:17 +02:00
Simon Vandel Sillesen
2d1e0adfe9 New pass to deduplicate blocks 2021-02-21 21:51:54 +01:00
Matthias Krüger
393878b15b remove redundant return value Ok(()) of clear_relocations() 2021-02-21 13:25:28 +01:00
Camille GILLOT
f96e960ccf Access the session directly from DepContext. 2021-02-20 22:53:46 +01:00
bors
d2b38d6b3c Auto merge of #82341 - GuillaumeGomez:rollup-t7y7tyg, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #80595 (`impl PartialEq<Punct> for char`; symmetry for #78636)
 - #81991 (Fix panic in 'remove semicolon' when types are not local)
 - #82176 (fix MIR fn-ptr pretty-printing)
 - #82244 (Keep consistency in example for Stdin StdinLock)
 - #82260 (rustc: Show ``@path`` usage in stable)
 - #82316 (Fix minor mistake in LTO docs.)
 - #82332 (Don't generate src link on dummy spans)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-20 21:38:53 +00:00
Guillaume Gomez
2d39300e2f
Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk
fix MIR fn-ptr pretty-printing

An uninitialized function pointer would get printed as `{{uninit  fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that.

However, I have no idea how to add tests for this.

Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^

r? ``@oli-obk``
2021-02-20 20:37:00 +01:00
Ralf Jung
d496bfc161 all InterpError allocate now, so adjust alloc-error-check 2021-02-20 19:01:25 +01:00
Henry Boisdequin
a9c6188889 make super_projection take a PlaceRef 2021-02-20 16:56:08 +05:30
Ralf Jung
e90674574d fn ptr pretty printing: fall back to raw ptr printing 2021-02-20 11:34:35 +01:00
Camille GILLOT
9823c2cc70 Workaround rustdoc not honouring cfg(parallel_compiler). 2021-02-19 22:05:27 +01:00
Camille GILLOT
4581d16bcb Move the query system to rustc_query_impl. 2021-02-19 17:51:58 +01:00
Camille GILLOT
71f749a683 Introduce a QueryEngine trait object. 2021-02-19 17:51:57 +01:00
Camille GILLOT
23f9d10ea7 Make encode_query_results more generic. 2021-02-19 17:51:57 +01:00
Camille GILLOT
24dbb61e58 Move query names and Providers to parent module. 2021-02-19 17:51:57 +01:00
Camille GILLOT
8e5d613a11 Wrap QueryDescription into a macro. 2021-02-19 17:51:57 +01:00
Camille GILLOT
cdc0b199a9 Split DepKindStruct in two. 2021-02-19 17:51:56 +01:00
Camille GILLOT
1ac21e4571 Use QueryCtxt in DepKindStruct. 2021-02-19 17:51:56 +01:00
Camille GILLOT
b27266fdb2 Use a QueryContext for try_mark_green. 2021-02-19 17:51:56 +01:00
Camille GILLOT
3bd14c7bbe Select caching strategy per query.
The per-Key choice was not used.
2021-02-19 17:51:56 +01:00
Camille GILLOT
6e4af4a2d1 Move definition of callbacks to parent module. 2021-02-19 17:51:56 +01:00
Camille GILLOT
a4b1158f78 Move handle_deadlock where it is used. 2021-02-19 17:51:55 +01:00
Camille GILLOT
ea3d465c95 Move try_load_from_on_disk_cache to the QueryContext. 2021-02-19 17:51:55 +01:00
Camille GILLOT
4dbf83a209 Move try_print_query_stack to rustc_interface. 2021-02-19 17:51:55 +01:00
Camille GILLOT
0e9cac40a6 Make alloc_self_profile_query_strings a standalone function. 2021-02-19 17:51:55 +01:00
Camille GILLOT
5d71b99690 Make QueryEngine opaque to TyCtxt. 2021-02-19 17:51:54 +01:00
Camille GILLOT
3f868b1791 Opacify query invocation. 2021-02-19 17:51:50 +01:00
Camille GILLOT
2db2776589 Wrap TyCtxt inside a QueryCtxt for queries. 2021-02-19 17:51:50 +01:00
Camille GILLOT
dab9b89221 Decouple the on-disk cache from the query engine. 2021-02-19 17:51:50 +01:00
Camille GILLOT
49c1b07a9e Decouple QueryContext from DepContext. 2021-02-19 17:51:49 +01:00
Camille GILLOT
211b05aef3 Don't require a QueryContext to access the DepGraph. 2021-02-19 17:51:49 +01:00
Camille GILLOT
7794fbb478 Group logic about the Providers struct. 2021-02-19 17:51:48 +01: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
LeSeulArtichaut
ec20993c4d Stabilize unsafe_op_in_unsafe_fn lint 2021-02-18 17:12:15 +01:00
Dylan DPC
efdcb4301b
Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkor
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.

I've tried not to change anything that looked similar to `rustc --print`, where people might use automation, and/or any "bulk" prints, such as dumping an entire Graphviz (`dot`) graph on stdout.

The reason I want `-Ztime-passes` to be on stderr like debug logging is I can get a complete (and correctly interleaved) view just by looking at stderr, which is merely a convenience when running `rustc`/Cargo directly, but even more important when it's nested in a build script, as Cargo will split the build script output into stdout (named `output`) and `stderr`.
2021-02-18 16:57:43 +01:00
Dylan DPC
f01b339dae
Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkov
In some limited cases, suggest `where` bounds for non-type params

Partially address #81971.
2021-02-18 16:57:36 +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
Eduard-Mihai Burtescu
6165d1cc72 Print -Ztime-passes (and misc stats/logs) on stderr, not stdout. 2021-02-18 14:13:38 +02:00
bors
25a2c13e9d Auto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #82055 (Add diagnostics for specific cases for const/type mismatch err)
 - #82155 (Use !Sync std::lazy::OnceCell in usefulness checking)
 - #82202 (add specs for riscv32/riscv64 musl targets)
 - #82203 (Move some tests to more reasonable directories - 4)
 - #82211 (make `suggest_setup` help messages better)
 - #82212 (Remove redundant rustc_data_structures path component)
 - #82240 (remove useless ?s (clippy::needless_question_marks))
 - #82243 (Add more intra-doc links to std::io)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-18 07:22:30 +00:00
bors
d1462d8558 Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obk
Implement RFC 2580: Pointer metadata & VTable

RFC: https://github.com/rust-lang/rfcs/pull/2580

~~Before merging this PR:~~

* [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278).
* [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513
* [x] Update `#[unstable]` attributes in the PR with the tracking issue number

----

This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound.

For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated.

This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`:

```rust
pub trait Pointee {
    /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>`
    type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
}

pub trait Thin = Pointee<Metadata = ()>;

pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {}

pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {}
pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {}

impl<T: ?Sized> NonNull<T> {
    pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {}

    /// Convenience for `(ptr.cast(), metadata(ptr))`
    pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *const T {
    pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *mut T {
    pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {}
}

/// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>`
pub struct DynMetadata<Dyn: ?Sized> {
    // Private pointer to vtable
}

impl<Dyn: ?Sized> DynMetadata<Dyn> {
    pub fn size_of(self) -> usize {}
    pub fn align_of(self) -> usize {}
    pub fn layout(self) -> crate::alloc::Layout {}
}

unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {}
unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {}
```

API differences from the RFC, in areas noted as unresolved questions in the RFC:

* Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc.
* Added `to_raw_parts`
2021-02-18 04:22:16 +00:00
Matthias Krüger
f7b834831f remove useless ?s (clippy::needless_question_marks)
Example code:
```
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```
2021-02-17 23:23:57 +01:00
Esteban Küber
32c97da0f4 In some limited cases, suggest where bounds for non-type params
Partially address #81971.
2021-02-17 09:26:40 -08:00
Tomasz Miąsko
e190f0d974 Reduce size of InterpErrorInfo to 8 bytes 2021-02-17 08:57:06 +01:00
bors
8fe989dd76 Auto merge of #81611 - cjgillot:meowner, r=estebank
Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16 22:14:32 +00:00
Guillaume Gomez
46b93b2e44
Rollup merge of #82163 - matthiaskrgr:slice, r=jyn514
avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing
2021-02-16 19:21:20 +01:00
Ralf Jung
b08bc7836b fix MIR fn-ptr pretty-printing 2021-02-16 09:59:38 +01:00
Henry Boisdequin
5ec4b060a7 make visit_projection take a PlaceRef 2021-02-16 14:20:36 +05:30
bors
42a4673fbd Auto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink
Rollup of 19 pull requests

Successful merges:

 - #81503 (Suggest to create a new `const` item if the `fn` in the array is a `const fn`)
 - #81897 (Add match pattern diagnostics regression test)
 - #81975 (Seal the CommandExt, OsStrExt and OsStringExt traits)
 - #82009 (const_generics: Dont evaluate array length const when handling errors)
 - #82060 (Fix typos in BTreeSet::{first, last} docs)
 - #82061 (CTFE validation: catch ReadPointerAsBytes and better error)
 - #82063 (Fixed minor typo in catch_unwind docs)
 - #82067 (const_generics: Fix incorrect ty::ParamEnv::empty() usage)
 - #82077 (Edit `rustc_arena::DropArena` docs)
 - #82096 (Fix a typo)
 - #82106 (Remove unnecessary `Option` in `default_doc`)
 - #82107 (expand: Some cleanup)
 - #82118 (Add missing env!-decl variant)
 - #82119 (Fix typo in link to CreateSymbolicLinkW documentation.)
 - #82120 (Stabilize Arguments::as_str)
 - #82129 (Remove redundant bool_to_option feature gate)
 - #82133 (Update link for extern prelude.)
 - #82141 (32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.)
 - #82147 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-16 02:14:13 +00:00
Henry Boisdequin
30c5125fbe update formating 2021-02-16 07:07:42 +05:30
Matthias Krüger
4390a61b64 avoid full-slicing slices
If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing
2021-02-16 00:31:11 +01:00
Camille GILLOT
91d8e59cca Remove HirItemLike. 2021-02-15 19:36:13 +01:00
Camille GILLOT
7dd1e8cfdf Trait impls are Items, therefore HIR owners. 2021-02-15 19:36:13 +01:00
Camille GILLOT
c4e7427081 Only store a LocalDefId in hir::MacroDef. 2021-02-15 19:35:55 +01:00
Camille GILLOT
ff14cac621 Index Modules using their LocalDefId. 2021-02-15 19:32:30 +01:00
Camille GILLOT
996dc8d5c5 Only store a LocalDefId in hir::ForeignItem. 2021-02-15 19:32:29 +01:00
Camille GILLOT
786a80e9ea Only store a LocalDefId in hir::ImplItem. 2021-02-15 19:32:29 +01:00
Camille GILLOT
a871a0f111 Only store a LocalDefId in hir::TraitItem. 2021-02-15 19:32:28 +01:00
Camille GILLOT
cebbba081e Only store a LocalDefId in hir::Item.
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
Camille GILLOT
bd3cd5dbed Use an ItemId inside mir::GlobalAsm. 2021-02-15 19:24:58 +01:00
Camille GILLOT
c676e358a5 Use ItemId as a strongly typed index. 2021-02-15 19:24:58 +01:00
Camille GILLOT
21b0cdc9c0 Remove useless Named trait. 2021-02-15 19:24:57 +01:00
Gus Wynn
c28d86c53b name async generators something more human friendly in type error diagnostics 2021-02-15 08:51:08 -08:00
Jonas Schievink
665bf9e35f
Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk
const_generics: Fix incorrect ty::ParamEnv::empty() usage

Fixes #80561

Not sure if I should keep the `debug!(..)`s or not but its the second time I've needed them so they sure seem useful lol

cc ``@lcnr``
r? ``@oli-obk``
2021-02-15 16:06:59 +01:00
Jonas Schievink
6fde3c5438
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
const_generics: Dont evaluate array length const when handling errors

Fixes #79518
Fixes #78246

cc ````@lcnr````

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? ````@varkor````
2021-02-15 16:06:55 +01:00
Jonas Schievink
f02f7b05b2
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
Suggest to create a new `const` item if the `fn` in the array is a `const fn`

Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary.

Example:

```rust
fn main() {
    // Should not compile but hint to create a new const item (stable) or an inline const block (nightly)
    let strings: [String; 5] = [String::new(); 5];
    println!("{:?}", strings);
}

```

Gives this error:

```
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
 --> $DIR/const-fn-in-vec.rs:3:32
  |
2 |     let strings: [String; 5] = [String::new(); 5];
  |                             ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String`
  |
  = note: the `Copy` trait is required because the repeated element will be copied
```

With this change, this is the error message:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:3:32
   |
LL |     let strings: [String; 5] = [String::new(); 5];
   |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
   = help: moving the function call to a new `const` item will resolve the error
```
2021-02-15 16:06:47 +01:00
Simon Sapin
b1e15fa8a2 Parameterize DynMetadata over its dyn SomeTrait type 2021-02-15 14:27:16 +01:00
Simon Sapin
696b239f72 Add ptr::Pointee trait (for all types) and ptr::metadata function
RFC: https://github.com/rust-lang/rfcs/pull/2580
2021-02-15 14:27:12 +01:00
bors
d1206f950f Auto merge of #81855 - cjgillot:ensure-cache, r=oli-obk
Check the result cache before the DepGraph when ensuring queries

Split out of https://github.com/rust-lang/rust/pull/70951

Calling `ensure` on already forced queries is a common operation.
Looking at the results cache first is faster than checking the DepGraph for a green node.
2021-02-15 12:11:59 +00:00
klensy
93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
Ellen
7bd71262f8 param_env debugs are instrumental to rustc's success 2021-02-14 11:18:40 +00:00
Henry Boisdequin
eace240ebe use option<PlaceRef<'tcx>> to clean up mir code a little 2021-02-14 14:39:24 +05:30
Camille GILLOT
3fc8ed68e9 Check query cache before calling into the query engine. 2021-02-13 21:14:58 +01:00
Camille GILLOT
15b0bc6b83 Separate the query cache from the query state. 2021-02-13 21:14:58 +01:00
Camille GILLOT
f8ab649dfd Introduce query_storage. 2021-02-13 21:14:58 +01:00
Camille GILLOT
4b42a6d90b Introduce query_stored module. 2021-02-13 21:14:57 +01:00
Camille GILLOT
8684e9e47d Merge {get,ensure}_query. 2021-02-13 21:14:57 +01:00
Matthew Jasper
dfee89f755 Make ProjectionTy::trait_ref truncate substs again
Also make sure that type arguments of associated types are printed in
some error messages.
2021-02-13 19:30:07 +00:00
Matthew Jasper
9526c0c6e8 Avoid trait_ref when lowering ExistentialProjections 2021-02-13 19:30:07 +00:00
Matthew Jasper
9bbd3e0f8e Remove ProjectionTy::from_ref_and_name 2021-02-13 19:29:55 +00:00
Ellen
68405fdc2e debug!("paramenv={}paramenv={}paramenv={}paramenv={}") 2021-02-13 19:10:08 +00:00
Ellen
a3e079534d Heat up the ICE-y error reporting
rest in peace match bool <3
2021-02-13 14:42:30 +00:00
bors
3f5aee2d52 Auto merge of #81744 - rylev:overlapping-early-exit2, r=lcnr
Try fast_reject::simplify_type in coherence before doing full check

This is a reattempt at landing #69010 (by `@jonas-schievink).` The change adds a fast path for coherence checking to see if there's no way for types to unify since full coherence checking can be somewhat expensive.

This has big effects on code generated by the [`windows`](https://github.com/microsoft/windows-rs) which in some cases spends as much as 20% of compilation time in the `specialization_graph_of` query. In local benchmarks this took a compilation that previously took ~500 seconds down to ~380 seconds.

This is surely not going to make a difference on much smaller crates, so the question is whether it will have a negative impact. #69010 was closed because some of the perf suite crates did show small regressions.

Additional discussion of this issue is happening [here](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/windows-rs.20perf).
2021-02-12 17:38:15 +00:00
Ryan Levick
8ea0973725 Short circuit full corherence check when dealing with types with different reference mutability 2021-02-12 14:04:09 +01:00
Ikko Ashimine
c8eeb340bc
Fix typo in mod.rs
insted -> instead
2021-02-12 13:47:21 +09:00
Yuki Okushi
a58feb9282
Rollup merge of #81913 - osa1:rename_unop_variants, r=matthewjasper
Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like `&*` instead of just `*`.
2021-02-10 12:24:28 +09:00
Ömer Sinan Ağacan
c4e3558b8c Rename HIR UnOp variants
This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".
2021-02-09 11:39:20 +03:00
bors
f4008fe949 Auto merge of #81905 - Dylan-DPC:rollup-mxpz1j7, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #72209 (Add checking for no_mangle to unsafe_code lint)
 - #80732 (Allow Trait inheritance with cycles on associated types take 2)
 - #81697 (Add "every" as a doc alias for "all".)
 - #81826 (Prefer match over combinators to make some Box methods inlineable)
 - #81834 (Resolve typedef in HashMap lldb pretty-printer only if possible)
 - #81841 ([rustbuild] Output rustdoc-json-types docs )
 - #81849 (Expand the docs for ops::ControlFlow a bit)
 - #81876 (parser: Fix panic in 'const impl' recovery)
 - #81882 (⬆️ rust-analyzer)
 - #81888 (Fix pretty printer macro_rules with semicolon.)
 - #81896 (Remove outdated comment in windows' mutex.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-09 05:57:18 +00:00
Dylan DPC
44e526b2c3
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis
Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved.

This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`
2021-02-09 02:39:50 +01:00
Mark Rousskov
f564d7abba Switch query descriptions to just String
In practice we never used the borrowed variant anyway.
2021-02-08 17:20:41 -05:00
bors
bb587b1a17 Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa
Improve SIMD type element count validation

Resolves rust-lang/stdsimd#53.

These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.:
```rust
#[repr(simd)]
struct SimdF32<const N: usize>([f32; N]);
```

This makes a few changes:
* Establishes a maximum SIMD lane count of 2^16 (65536).  This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend.  It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least.
* Expands some SIMD intrinsics to support arbitrary lane counts.  This resolves the ICE in the linked issue.
* Attempts to catch invalid-sized vectors during typeck when possible.

Unresolved questions:
* Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout.  This "works", but the errors simply bail out with no context beyond the name of the type.  Should these errors instead return `LayoutError` or otherwise provide context in some way?  As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors.

cc `@bjorn3`
2021-02-07 22:25:14 +00:00
Dan Aloni
eaefe4a230 path trimming: ignore type aliases 2021-02-06 12:03:48 +02:00
Santiago Pastorino
fd092557ce
Adapt to latest master changes by using PredicateKind 2021-02-05 18:56:57 -03:00
Santiago Pastorino
7aa602b84c
Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum"
This reverts commit b4def89d76, reversing
changes made to 7dc1e852d4.
2021-02-05 18:56:56 -03:00
Mara Bos
deec6a96d4
Rollup merge of #79554 - b-naber:generic-associated-types-in-trait-paths, r=jackh726
Generic associated types in trait paths

This is the second part of https://github.com/rust-lang/rust/pull/78978

This should fix:

Fixes #67510
Fixes #68648
Fixes #68649
Fixes #68650
Fixes #68652
Fixes #74684
Fixes #76535
Fixes #79422
Fixes #80433

and implement the remaining functionality needed for https://github.com/rust-lang/rust/issues/44265

r? ``@matthewjasper``
2021-02-05 12:25:50 +01:00
b-naber
6a68966663 use generic arguments of associated item in trait_ref method 2021-02-04 21:37:14 +01:00
Mara Bos
87b269ab66
Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995
Add lint for `panic!(123)` which is not accepted in Rust 2021.

This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021.

It suggests to add `"{}",` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming guidelines.

![image](https://user-images.githubusercontent.com/783247/106520928-675ea680-64d5-11eb-81f7-d8fa48b93a0b.png)

This is part of #80162.

r? ```@estebank```
2021-02-04 21:10:36 +01:00
Mara Bos
c5990dd8ad
Rollup merge of #81556 - nikomatsakis:forbidden-lint-groups-lint, r=pnkfelix
introduce future-compatibility warning for forbidden lint groups

We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect.

r? ``@Mark-Simulacrum``
2021-02-04 21:10:34 +01:00
Mara Bos
34d5ac25c5 Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
bors
b593389edb Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievink
Add a new ABI to support cmse_nonsecure_call

This adds support for the `cmse_nonsecure_call` feature to be able to perform non-secure function call.

See the discussion on Zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Support.20for.20callsite.20attributes/near/223054928).

This is a followup to #75810 which added `cmse_nonsecure_entry`. As for that PR, I assume that the changes are small enough to not have to go through a RFC but I don't mind doing one if needed 😃
I did not yet create a tracking issue, but if most of it is fine, I can create one and update the various files accordingly (they refer to the other tracking issue now).

On the Zulip chat, I believe `@jonas-schievink` volunteered to be a reviewer 💯
2021-02-03 06:00:43 +00:00
Henry Boisdequin
c2e849c022 added a suggestion to create a const item if the fn in the array repeat expression is a const fn 2021-02-03 10:18:08 +05:30
Niko Matsakis
b6b897b02c introduce future-compatibility warning for forbidden lint groups
We used to ignore `forbid(group)` scenarios completely. This changed
in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where
a group is forbidden but then an individual lint within that group
is allowed. We now issue a FCW when we see the "allow", but permit
it to take effect.
2021-02-02 18:21:37 -05:00
Jack Huey
70d16d506c
Rollup merge of #81665 - jacob-hughes:mir_doc_fix, r=estebank
Fix out of date `Scalar` documentation

Scalars can represent integers up to `u128`, but the docs state otherwise.
2021-02-02 16:01:49 -05:00
Jack Huey
c1623a2ee7
Rollup merge of #80593 - jackh726:chalk-upgrade, r=nikomatsakis
Upgrade Chalk

~~Blocked on rust-lang/chalk#670~~
~~Now blocked on rust-lang/chalk#680 and release~~

In addition to the straight upgrade, I also tried to fix some tests by properly returning variables and max universes in the solution. Unfortunately, this actually triggers the same perf problem that rustc traits code runs into in `canonicalizer`. Not sure what the root cause of this problem is, or why it's supposed to be solved in chalk.

r? ```@nikomatsakis```
2021-02-02 16:01:32 -05:00
Jack Huey
a0622d60e0 Update Chalk 2021-02-02 12:37:22 -05:00
Jake Hughes
07c4eeb836 Fix out of date Scalar documentation
Scalars can represent integers up to u128, but the docs state otherwise.
2021-02-02 16:15:32 +00:00
bors
b81f5811f9 Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
2021-02-02 14:52:53 +00:00
Mark Rousskov
d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Hugues de Valon
ce9818f2b7 Add a new ABI to support cmse_nonsecure_call
This commit adds a new ABI to be selected via `extern
"C-cmse-nonsecure-call"` on function pointers in order for the compiler to
apply the corresponding cmse_nonsecure_call callsite attribute.
For Armv8-M targets supporting TrustZone-M, this will perform a
non-secure function call by saving, clearing and calling a non-secure
function pointer using the BLXNS instruction.

See the page on the unstable book for details.

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2021-02-02 13:04:31 +00:00
Jonas Schievink
285524f8da
Rollup merge of #81609 - Julian-Wollersberger:no-query-categories, r=davidtwco
Remove the remains of query categories

Back in October 2020 in #77830 ``@cjgillot`` removed the query categories information from the profiler, but the actual definitions which query was in which category remained, although unused.
Here I clean that up, to simplify the query definitions even further.

It's unfortunate that this loses all the context for `git blame`, ~~but I'm working on moving those query definitions into `rustc_query_system`, which will lose that context anyway.~~ EDIT: Might not work out.

The functional changes are in the first commit. The second one only changes the indentation.
2021-02-02 12:15:04 +01:00
Jack Huey
4b64bc1fc9 Upgrade Chalk 2021-02-01 10:37:45 -05:00
Danuel
8bbb2d057d Fixed #[inline] to be warned in fields, arms, macro defs
Add visitors for checking #[inline]

Add visitors for checking #[inline] with struct field

Fix test for #[inline]

Add visitors for checking #[inline] with #[macro_export] macro

Add visitors for checking #[inline] without #[macro_export] macro

Add use alias with Visitor

Fix lint error

Reduce unnecessary variable

Co-authored-by: LingMan <LingMan@users.noreply.github.com>

Change error to warning

Add warning for checking field, arm with #[allow_internal_unstable]

Add name resolver

Formatting

Formatting

Fix error fixture

Add checking field, arm, macro def
2021-02-01 23:36:19 +09:00
Julian Wollersberger
988d93c8a0 Indent the code correctly again after removing the query categories. 2021-01-31 21:40:03 +01:00
Julian Wollersberger
7bc09f78af Remove the remains of the query categories. 2021-01-31 21:37:17 +01:00
Jonas Schievink
99f2f5a830
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
Remove const_in_array_repeat

Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682.

I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-31 16:36:42 +01:00
Jonas Schievink
7e3a8ec688
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
2229: Fix issues with move closures and mutability

This PR fixes two issues when feature `capture_disjoint_fields` is used.

1. Can't mutate using a mutable reference
2. Move closures try to move value out through a reference.

To do so, we
1. Compute the mutability of the capture and store it as part of the `CapturedPlace`  that is written in TypeckResults
2. Restrict capture precision. Note this is temporary for now, to allow the feature to be used with move closures and ByValue captures and might change depending on discussions with the lang team.
    - No Derefs are captured for ByValue captures, since that will result in value behind a reference getting moved.
    - No projections are applied to raw pointers since these require unsafe blocks. We capture
    them completely.

r? `````@nikomatsakis`````
2021-01-31 16:36:41 +01:00
kadmin
6946534d84 Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
Yuki Okushi
91ea1cbc17
Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se
Stabilize `unsigned_abs`

Resolves #74913.

This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`.

I have gone ahead and used this in a couple locations throughout the repository.
2021-01-30 13:36:44 +09:00
Aman Arora
fadf03ee1b Fix typos 2021-01-29 16:01:27 -05:00
Aman Arora
c748f32ee4 Fix incorrect use mut diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora
3488082582 Compute mutability of closure captures
When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.

However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-29 15:37:40 -05:00
bors
b05fd2a15d Auto merge of #81388 - bjorn3:wasm_bindgen_fix, r=nikomatsakis
Fix abi for wasm-bindgen

Hopefully fixes https://github.com/rust-lang/rust/issues/81386. `@alexcrichton` can you confirm this fixes wasm-bindgen?

r? `@alexcrichton`
2021-01-28 22:01:42 +00:00
Yuki Okushi
84ad95be70
Rollup merge of #81062 - sexxi-goose:precise_capture_diagnostics, r=nikomatsakis
Improve diagnostics for Precise Capture

This is just the capture analysis part and borrow checker logging will updated as part of rust-lang/project-rfc-2229#8

Closes rust-lang/project-rfc-2229#22
2021-01-28 15:09:06 +09:00
Yuki Okushi
446edd1e1a
Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
Refractor a few more types to `rustc_type_ir`

In the continuation of #79169, ~~blocked on that PR~~.

This PR:
 - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance`
 - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler.

~~I will split up that commit to make this easier to review and to have a better commit history.~~
EDIT: done, I split the PR in commits of 200-ish lines each

r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-28 15:09:02 +09:00
Yuki Okushi
71f13fb434
Rollup merge of #81325 - osa1:issue81293, r=estebank
typeck: Don't suggest converting LHS exprs

Converting LHS of an assignment does not work, so avoid suggesting that.

Fixes #81293
2021-01-27 04:43:24 +09:00
bjorn3
c1c06f3e3f Use PassMode::Direct for Abi::Aggregate by default 2021-01-26 14:49:35 +01:00
bjorn3
eb99ea5142 Revert "Wasm-bindgen abi compat using cast_to"
This reverts commit 903c553f4a.
2021-01-26 13:38:59 +01:00
bjorn3
903c553f4a Wasm-bindgen abi compat using cast_to 2021-01-26 11:31:37 +01:00
bjorn3
ecbc661030 Revert "Fix abi for wasm-bindgen"
This reverts commit 4d2766e352.
2021-01-26 11:09:09 +01:00
bjorn3
36df9c55e5 Revert "Share wasm-bindgen compat abi selection code"
This reverts commit e7a056fe20.
2021-01-26 11:09:06 +01:00
Ömer Sinan Ağacan
d035be8e6f typeck: Don't suggest converting LHS exprs
Converting LHS of an assignment does not work, so avoid suggesting that.

Fixes #81293
2021-01-26 09:09:15 +03:00
bors
a8f7075532 Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebank
Enforce that query results implement Debug

Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk.

This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
2021-01-26 05:47:23 +00:00
bjorn3
e7a056fe20 Share wasm-bindgen compat abi selection code 2021-01-25 21:32:57 +01:00
bors
f4eb5d9f71 Auto merge of #68828 - oli-obk:inline_cycle, r=wesleywiser
Prevent query cycles in the MIR inliner

r? `@eddyb` `@wesleywiser`

cc `@rust-lang/wg-mir-opt`

The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR.

The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles.

This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
2021-01-25 19:03:37 +00:00
bjorn3
4d2766e352 Fix abi for wasm-bindgen 2021-01-25 18:48:49 +01:00
bors
85e355ea9b Auto merge of #80919 - cjgillot:defkey-span, r=oli-obk
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N

Sample from #80347.
2021-01-24 06:51:17 +00:00
bors
446cbc9db0 Auto merge of #80594 - bjorn3:abi_refactor3, r=petrochenkov
Various ABI refactorings

This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.

r? `@ghost`
2021-01-24 02:59:14 +00:00
bors
26c2d1f408 Auto merge of #79811 - Aaron1011:expn-data-disambig, r=petrochenkov
Add disambiugator to ExpnData

I still need to write a bunch of comments. Opening to see how bad the perf impact is.

cc https://github.com/rust-lang/rust/issues/79560
2021-01-24 00:10:20 +00:00
Caleb Zulawski
8451656fe7 Fix maximum SIMD lane count, and expose it to other crates. Disallow SIMD vectors with non-power-of-two lengths. 2021-01-23 16:33:19 -05:00
Bastian Kauschke
5fe84c8958 always eagerly eval consts in Relate 2021-01-23 22:10:09 +01:00
Aaron Hill
3540f9396a
Add disambiugator to ExpnData
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.

This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
2021-01-23 15:41:17 -05:00
Jonas Schievink
3a3470bf04
Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJung
mir: Improve size_of handling when arg is unsized

As discussed on Zulip with `@RalfJung.`
2021-01-23 20:16:04 +01:00
Jonas Schievink
57d655368b
Rollup merge of #81130 - pierwill:edit-depnode, r=jyn514
Edit rustc_middle::dep_graph module documentation

This is similar to work approved and then closed in https://github.com/rust-lang/rust/pull/80325 due to a bad rebase.
2021-01-23 20:16:00 +01:00
bjorn3
fa12fdbc29 Fix review comments 2021-01-23 17:55:39 +01:00
oli
b8727e2d60 Prevent query cycles during inlining 2021-01-23 16:51:22 +00:00
Camille GILLOT
97ee7c7e5a Allow to query the HIR crate node. 2021-01-23 13:58:09 +01:00
Camille GILLOT
a185cdbc59 Iterate to encode def_kind. 2021-01-23 13:51:00 +01:00
Camille GILLOT
c58a6fa422 Iterate DefId to encode spans. 2021-01-23 13:44:02 +01:00
Camille GILLOT
064a351953 Infallible version of def_span. 2021-01-23 13:35:22 +01:00
bjorn3
a93dace55c Never create an temporary PassMode::Direct when it is not a valid pass mode for a type 2021-01-23 10:30:39 +01:00
bjorn3
ba484de538 Move some code around 2021-01-23 10:30:39 +01:00
bjorn3
da0309c711 Use PassMode::Pair by default for Abi::ScalarPair for all abi's and in return position
Abi::ScalarPair is only ever used for types that don't have a stable
layout anyway so this doesn't break any FFI. It does however reduce the
amount of special casing on the abi outside of the code responsible for
abi specific adjustments to the pass mode.
2021-01-23 10:30:38 +01:00
pierwill
b29353af09 Edit rustc_middle::dep_graph module documentation
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
Co-authored-by: Camelid <camelidcamel@gmail.com>
2021-01-22 15:15:05 -08:00
bors
f2de221b00 Auto merge of #81101 - tmiasko:combine-now, r=nagisa
Combine instructions immediately
2021-01-22 13:10:48 +00:00
Ömer Sinan Ağacan
e3faeb486a mir: Improve size_of handling when arg is unsized 2021-01-21 22:17:05 +03:00
LeSeulArtichaut
933bb18956 Use rustc_type_ir::{IntTy,UintTy,FloatTy} instead of the rustc_ast` ones in types 2021-01-18 21:09:23 +01:00
LeSeulArtichaut
0724573448 Move a few more types to rustc_type_ir 2021-01-18 21:06:12 +01:00
Tomasz Miąsko
508eec49e9 Combine instructions immediately
No functional changes intended
2021-01-18 13:15:27 +01:00
Ashley Mannix
d3cc598a02
Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.
2021-01-18 21:53:40 +10:00
Ashley Mannix
d3ff9ac8e8
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
prevent potential bug in `encode_with_shorthand`.

see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169
2021-01-18 21:53:26 +10:00
bors
4253153db2 Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`
2021-01-17 20:49:11 +00:00
pierwill
34debb640b Edit rustc_middle::ty::cast docs
Link to RFC 401 and add missing punctuation.
2021-01-17 11:30:18 -08:00
Jack Huey
c4376ba24a
Whitespace and typo 2021-01-17 12:50:04 -05:00
Jack Huey
d797a85491 Add comment about Encodable/Decodable impl 2021-01-17 12:32:05 -05:00
Mara Bos
8f2ee87965
Rollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa
Remove is_dllimport_foreign_item definition from cg_ssa

It overwrites the definition from rustc_metadata.

cc https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/query.20provided.20twice/near/218927806

Marked as draft to test if this breaks anything.
2021-01-17 12:24:51 +00:00
Mara Bos
19f97802ca
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```
2021-01-17 12:24:44 +00:00
Jack Huey
c76f47832a Don't derive TyEncodable/TyDecodable for Binder 2021-01-17 04:13:51 -05:00
Jack Huey
674735b109 Impl EncodableWithShorthand for PredicateKind 2021-01-17 02:49:30 -05:00
Jack Huey
f2ed9a3a8c Can't use EncodableWithShorthand for Predicate 2021-01-16 19:17:59 -05:00
Jack Huey
dcad9f1893 More review comments 2021-01-16 18:56:37 -05:00
Jack Huey
3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey
476bd53058 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey
e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey
876192e8cd fold_with not super_fold_with in TypeFoldable impl for Predicate 2021-01-16 18:40:47 -05:00
Jack Huey
4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey
4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey
8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
Bastian Kauschke
84b056d597 prevent potential bug in encode_with_shorthand. 2021-01-17 00:34:54 +01:00
Aaron Hill
02952372c4
Implement Debug for DefIdForest 2021-01-16 17:56:32 -05:00
Aaron Hill
7afb32557d
Enforce that query results implement Debug 2021-01-16 17:53:02 -05:00
Bastian Kauschke
15f0921d0c correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
Chris Pardy
2624b3e443 Improve diagnostics for Precise Capture 2021-01-15 19:39:24 -05:00
bors
fcbd305ee9 Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, r=michaelwoerister
Remove DepKind::CrateMetadata and pre-allocation of DepNodes

Remove much of the special-case handling around crate metadata
dependency tracking by replacing `DepKind::CrateMetadata` and the
pre-allocation of corresponding `DepNodes` with on-demand invocation
of the `crate_hash` query.
2021-01-15 21:13:35 +00:00
Yuki Okushi
ce06df2e4a
Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandry
Don't ICE when computing a layout of a generator tainted by errors

Fixes #80998.
2021-01-15 18:26:16 +09:00
Yuki Okushi
a584d87417
Rollup merge of #80944 - LingMan:map_or, r=nagisa
Use Option::map_or instead of `.map(..).unwrap_or(..)`

``@rustbot`` modify labels +C-cleanup +T-compiler
2021-01-15 18:26:14 +09:00
LingMan
a56bffb4f9 Use Option::map_or instead of .map(..).unwrap_or(..) 2021-01-14 19:23:59 +01:00
Mara Bos
9e9aba87af
Rollup merge of #80829 - jyn514:dep-constructor, r=michaelwoerister
Get rid of `DepConstructor`

This removes fully 235 unused functions.

Follow-up to https://github.com/rust-lang/rust/pull/80325#discussion_r548491999.

r? ``@michaelwoerister``
cc ``@cjgillot``
2021-01-14 18:00:09 +00:00
bors
d03fe84169 Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If

Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.

The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.

- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051)
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d)
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5)
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691)
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95)
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-14 14:41:58 +00:00
Tomasz Miąsko
5ea1d0e865 Don't ICE when computing a layout of a generator tainted by errors 2021-01-14 13:13:13 +01:00
bors
180fdffa17 Auto merge of #80654 - Aaron1011:fix/dummy-span-ctxt, r=wesleywiser
Properly handle `SyntaxContext` of dummy spans in incr comp

Fixes #80336

Due to macro expansion, we may end up with spans with an invalid
location and non-root `SyntaxContext`. This commits preserves the
`SyntaxContext` of such spans in the incremental cache, and ensures
that we always hash the `SyntaxContext` when computing the `Fingerprint`
of a `Span`

Previously, we would discard the `SyntaxContext` during serialization to
the incremental cache, causing the span's `Fingerprint` to change across
compilation sessions.
2021-01-13 23:24:31 +00:00
Jacob Pratt
edf2e3725e
Use unsigned_abs throughout repository 2021-01-13 17:58:08 -05:00
bors
a62a76047e Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924)

This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13 20:35:58 +00:00
Aaron Hill
482a67d20f
Properly handle SyntaxContext of dummy spans in incr comp
Fixes #80336

Due to macro expansion, we may end up with spans with an invalid
location and non-root `SyntaxContext`. This commits preserves the
`SyntaxContext` of such spans in the incremental cache, and ensures
that we always hash the `SyntaxContext` when computing the `Fingerprint`
of a `Span`

Previously, we would discard the `SyntaxContext` during serialization to
the incremental cache, causing the span's `Fingerprint` to change across
compilation sessions.
2021-01-13 15:20:29 -05:00
bjorn3
7aca2fa7c6 Remove is_dllimport_foreign_item def from cg_ssa
It overwrites the definition from rustc_metadata
2021-01-13 18:47:26 +01:00
bors
fc93e4719c Auto merge of #80960 - Dylan-DPC:rollup-89tri8x, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #78901 (diagnostics: Note capturing closures can't be coerced to fns)
 - #79588 (Provide more information for HRTB lifetime errors involving closures)
 - #80232 (Remove redundant def_id lookups)
 - #80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu)
 - #80736 (use Once instead of Mutex to manage capture resolution)
 - #80796 (Update to LLVM 11.0.1)
 - #80859 (Fix --pretty=expanded with --remap-path-prefix)
 - #80922 (Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2)
 - #80924 (Fix rustdoc --test-builder argument parsing)
 - #80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-13 04:29:45 +00:00