Commit Graph

122316 Commits

Author SHA1 Message Date
Aaron Hill
3ed96a6d63
Point at the call spawn when overflow occurs during monomorphization
This improves the output for issue #72577, but there's still more work
to be done.

Currently, an overflow error during monomorphization results in an error
that points at the function we were unable to monomorphize. However, we
don't point at the call that caused the monomorphization to happen. In
the overflow occurs in a large recursive function, it may be difficult
to determine where the issue is.

This commit tracks and `Span` information during collection of
`MonoItem`s, which is used when emitting an overflow error. `MonoItem`
itself is unchanged, so this only affects
`src/librustc_mir/monomorphize/collector.rs`
2020-06-22 14:35:42 -04:00
Aaron Hill
e2ab98df08
Stop using old version of syn in rustc-workspace-hack
None of the tools seem to need syn 0.15.35, so we can just build syn
1.0.

This was causing an issue with clippy's `compile-test` program: since
multiple versions of `syn` would exist in the build directory, we would
non-deterministically pick one based on filesystem iteration order. If
the pre-1.0 version of `syn` was picked, a strange build error would
occur (see
https://github.com/rust-lang/rust/pull/73594#issuecomment-647671463)

To prevent this kind of issue from happening again, we now panic if we
find multiple versions of a crate in the build directly, instead of
silently picking the first version we find.
2020-06-22 13:29:39 -04:00
Aaron Hill
d3feb8baaf
Re-enable Clippy tests 2020-06-22 12:46:29 -04:00
Aaron Hill
ad9972a20d
Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis"
This reverts commit 372cb9b69c, reversing
changes made to 5c61a8dc34.
2020-06-22 12:46:29 -04:00
bors
6bb3dbfc6c Auto merge of #73415 - ehuss:update-cargo, r=ehuss
Update cargo

3 commits in 79c769c3d7b4c2cf6a93781575b7f592ef974255..089cbb80b73ba242efdcf5430e89f63fa3b5328d
2020-06-11 22:13:37 +0000 to 2020-06-15 14:38:34 +0000
- Support linker with -Zdoctest-xcompile. (rust-lang/cargo#8359)
- Fix doctests not running with --target=HOST. (rust-lang/cargo#8358)
- Allow passing a registry index url directly to `cargo install` (rust-lang/cargo#8344)
2020-06-22 16:38:21 +00:00
Niko Matsakis
1e00e1b6de upcasting traits requires only that things become more general
Revert the code that states that upcasting traits requires full
equality and change to require that the source type is a subtype of
the target type, as one would expect. As the comment states, this was
an old bug that we didn't want to fix yet as it interacted poorly with
the old leak-check. This fixes the old-lub-glb-object test, which was
previously reporting too many errors (i.e., in the previous commit).
2020-06-22 15:33:07 +00:00
Niko Matsakis
5a7a850753 move leak-check to during coherence, candidate eval
In particular, it no longer occurs during the subtyping check. This is
important for enabling lazy normalization, because the subtyping check
will be producing sub-obligations that could affect its results.

Consider an example like

    for<'a> fn(<&'a as Mirror>::Item) =
      fn(&'b u8)

where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a
new subobligation like

    <'!1 as Mirror>::Item = &'b u8

This will, after being solved, ultimately yield a constraint that `'!1
= 'b` which will fail. But with the leak-check being performed on
subtyping, there is no opportunity to normalize `<'!1 as
Mirror>::Item` (unless we invoke that normalization directly from
within subtyping, and I would prefer that subtyping and unification
are distinct operations rather than part of the trait solving stack).

The reason to keep the leak check during coherence and trait
evaluation is partly for backwards compatibility. The coherence change
permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait
evaluation change means that we can distinguish those two cases
without ambiguity errors. It also avoids recreating #57639, where we
were incorrectly choosing a where clause that would have failed the
leak check over the impl which succeeds.

The other reason to keep the leak check in those places is that I
think it is actually close to the model we want. To the point, I think
the trait solver ought to have the job of "breaking down"
higher-ranked region obligation like ``!1: '2` into into region
obligations that operate on things in the root universe, at which
point they should be handed off to polonius. The leak check isn't
*really* doing that -- these obligations are still handed to the
region solver to process -- but if/when we do adopt that model, the
decision to pass/fail would be happening in roughly this part of the
code.

This change had somewhat more side-effects than I anticipated. It
seems like there are cases where the leak-check was not being enforced
during method proving and trait selection. I haven't quite tracked
this down but I think it ought to be documented, so that we know what
precisely we are committing to.

One surprising test was `issue-30786.rs`. The behavior there seems a
bit "fishy" to me, but the problem is not related to the leak check
change as far as I can tell, but more to do with the closure signature
inference code and perhaps the associated type projection, which
together seem to be conspiring to produce an unexpected
signature. Nonetheless, it is an example of where changing the
leak-check can have some unexpected consequences: we're now failing to
resolve a method earlier than we were, which suggests we might change
some method resolutions that would have been ambiguous to be
successful.

TODO:

* figure out remainig test failures
* add new coherence tests for the patterns we ARE disallowing
2020-06-22 15:33:05 +00:00
Niko Matsakis
f2cf994483 rewrite leak check to be based on universes
In the new leak check, instead of getting a list of placeholders to
track, we look for any placeholder that is part of a universe which
was created during the snapshot.

We are looking for the following error patterns:

* P1: P2, where P1 != P2
* P1: R, where R is in some universe that cannot name P1

This new leak check is more precise than before, in that it accepts
this patterns:

* R: P1, even if R cannot name P1, because R = 'static is a valid
sol'n
* R: P1, R: P2, as above

Note that this leak check, when running during subtyping, is less
efficient than before in some sense because it is going to check and
re-check all the universes created since the snapshot. We're going to
move when the leak check runs to try and correct that.
2020-06-22 14:33:44 +00:00
Niko Matsakis
4199b3ae26 Revert "modify leak-check to track only outgoing edges from placeholders"
This reverts commit 2e01db4b396a1e161f7a73933fff34bc9421dba0.
2020-06-22 14:05:00 +00:00
Niko Matsakis
bcc0a9c8eb modify leak-check to track only outgoing edges from placeholders
Also, update the affected tests. This seems strictly better but it is
actually more permissive than I initially intended. In particular it
accepts this

```
forall<'a, 'b> {
  exists<'intersection> {
    'a: 'intersection,
    'b: 'intersection,
  }
}
```

and I'm not sure I want to accept that. It implies that we have a
`'empty` in the new universe intoduced by the `forall`.
2020-06-22 14:05:00 +00:00
bors
62878c20e9 Auto merge of #73617 - Dylan-DPC:rollup-zugh80o, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #71660 (impl PartialEq<Vec<B>> for &[A], &mut [A])
 - #72623 (Prefer accessible paths in 'use' suggestions)
 - #73502 (Add E0765)
 - #73580 (deprecate wrapping_offset_from)
 - #73582 (Miri: replace many bug! by span_bug!)
 - #73585 (Do not send a notification for P-high stable regressions)

Failed merges:

 - #73581 (Create 0766 error code)

r? @ghost
2020-06-22 12:59:57 +00:00
Dylan DPC
c5e6f48544
Rollup merge of #73585 - LeSeulArtichaut:patch-3, r=Mark-Simulacrum
Do not send a notification for P-high stable regressions

This is kind of a hack to only match nightly and beta regressions, but not stable regressions. See my tests [on the playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6ff8a809162118aa2951f2ff12400067).

r? @spastorino cc @Mark-Simulacrum
2020-06-22 14:53:56 +02:00
Dylan DPC
cb85f4bce0
Rollup merge of #73582 - RalfJung:miri-span-bug, r=oli-obk
Miri: replace many bug! by span_bug!

r? @oli-obk
2020-06-22 14:53:54 +02:00
Dylan DPC
35ecb26297
Rollup merge of #73580 - RalfJung:deprecate-wrapping-offset-from, r=Amanieu
deprecate wrapping_offset_from

As per https://github.com/rust-lang/rust/issues/41079#issuecomment-433140733 which seems like a consensus.

r? @Amanieu
2020-06-22 14:53:52 +02:00
Dylan DPC
d22b80dc0c
Rollup merge of #73502 - GuillaumeGomez:add-e0764, r=estebank
Add E0765
2020-06-22 14:53:50 +02:00
Dylan DPC
fdd241f5b3
Rollup merge of #72623 - da-x:use-suggest-public-path, r=petrochenkov
Prefer accessible paths in 'use' suggestions

This PR addresses issue https://github.com/rust-lang/rust/issues/26454, where `use` suggestions are made for paths that don't work. For example:

```rust
mod foo {
    mod bar {
        struct X;
    }
}

fn main() { X; } // suggests `use foo::bar::X;`
```
2020-06-22 14:53:48 +02:00
Dylan DPC
8da1dd0215
Rollup merge of #71660 - sollyucko:master, r=dtolnay
impl PartialEq<Vec<B>> for &[A], &mut [A]

https://github.com/rust-lang/rfcs/issues/2917
2020-06-22 14:53:46 +02:00
Bastian Kauschke
932237b101
fix intrinsics::needs_drop docs 2020-06-22 14:42:26 +02:00
Guillaume Gomez
c474317747 Clean up E0699 explanation 2020-06-22 11:50:55 +02:00
David Wood
b60ec47a06
bootstrap: no config.toml exists regression
This commit fixes a regression introduced in #73317 where an oversight
meant that `config.toml` was assumed to exist.

Signed-off-by: David Wood <david@davidtw.co>
2020-06-22 10:02:00 +01:00
Rich Kadel
933fe80577 num_counters to u32, after implementing TypeFoldable 2020-06-21 23:48:39 -07:00
Aaron Hill
953104e60c
Fix spurious 'value moved here in previous iteration of loop' messages
Fixes #46099

Previously, we would check the 'move' and 'use' spans to see if we
should emit this message. However, this can give false positives when
macros are involved, since two distinct expressions may end up with the
same span.

Instead, we check the actual MIR `Location`, which eliminates false
positives.
2020-06-21 21:27:34 -04:00
marmeladema
bd4f6f0b7d Move next_disambiguator to Resolver 2020-06-21 23:49:06 +01:00
marmeladema
1d3f49f536 Always create a root definition when creating a new Definitions object. 2020-06-21 23:13:31 +01:00
marmeladema
f60513ec8d Move remaining NodeId APIs from Definitions to Resolver 2020-06-21 23:13:31 +01:00
bors
1a4e2b6f9c Auto merge of #73180 - matthewjasper:predicate-cache, r=nikomatsakis
Cache flags and escaping vars for predicates

With predicates becoming interned (rust-lang/compiler-team#285) this is now possible and could be a perf win. It would become an even larger win once we have recursive predicates.

cc @lcnr @nikomatsakis

r? @ghost
2020-06-21 21:05:57 +00:00
LeSeulArtichaut
ae71e965dc Do not send a notification for P-high stable regressions
Add comment to clarify the pattern
2020-06-21 22:16:53 +02:00
Ralf Jung
7447bf2201 fmt 2020-06-21 19:35:57 +02:00
bors
a8cf399117 Auto merge of #72936 - jackh726:chalk-more, r=nikomatsakis
Upgrade Chalk

Things done in this PR:
- Upgrade Chalk to `0.11.0`
- Added compare-mode=chalk
- Bump rustc-hash in `librustc_data_structures` to `1.1.0` to match Chalk
- Removed `RustDefId` since the builtin type support is there
- Add a few more `FIXME(chalk)`s for problem spots I hit when running all tests with chalk
- Added some more implementation code for some newer builtin Chalk types (e.g. `FnDef`, `Array`)
- Lower `RegionOutlives` and `ObjectSafe` predicates
- Lower `Dyn` without the region
- Handle `Int`/`Float` `CanonicalVarKind`s
- Uncomment some Chalk tests that actually work now
- Remove the revisions in `src/test/ui/coherence/coherence-subtyping.rs` since they aren't doing anything different

r? @nikomatsakis
2020-06-21 17:10:09 +00:00
Ralf Jung
629722893c MIR validation: check switch_ty 2020-06-21 18:24:51 +02:00
Ralf Jung
3bfd0c9f07 remove switch_ty reliance in codegen 2020-06-21 18:22:30 +02:00
Dan Aloni
fea5ab12c2 Prefer accessible paths in 'use' suggestions
This fixes an issue with the following sample:

    mod foo {
	mod inaccessible {
	    pub struct X;
	}
	pub mod avail {
	    pub struct X;
	}
    }

    fn main() { X; }

Instead of suggesting both `use crate::foo::inaccessible::X;` and `use
crate::foo::avail::X;`, it should only suggest the latter.

It is done by trimming the list of suggestions from inaccessible paths
if accessible paths are present.

Visibility is checked with `is_accessible_from` now instead of being
hard-coded.

-

Some tests fixes are trivial, and others require a bit more explaining,
here are my comments:

src/test/ui/issues/issue-35675.stderr: Only needs to make the enum
public to have the suggestion make sense.

src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't
help because its constructor is not visible, so the attempted
constructor does not work. In that case, it's better not to suggest it.
The case where the constructor is public is covered in `issue-26545.rs`.
2020-06-21 18:49:39 +03:00
Youngsuk Kim
893077ca76
Update src/librustc_mir/monomorphize/collector.rs
typo fix

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-21 11:43:30 -04:00
Guillaume Gomez
c14d85fd33 Update UI tests 2020-06-21 16:40:36 +02:00
Ralf Jung
726b6f4a69 Miri: replace many bug! by span_bug! 2020-06-21 16:13:31 +02:00
bors
349f6bfb11 Auto merge of #72696 - jethrogb:jb/llvm-zlib, r=Mark-Simulacrum
Enable LLVM zlib

Compilers may generate ELF objects with compressed sections (although rustc currently doesn't do this). Currently, when linking these with `rust-lld`, you'll get this error:

`rust-lld: error: ...: contains a compressed section, but zlib is not available`

This enables zlib when building LLVM.
2020-06-21 13:18:00 +00:00
Guillaume Gomez
a657be42b1 Create E0765 error for unterminated double quote strings 2020-06-21 14:09:12 +02:00
Ralf Jung
467415d50c deprecate wrapping_offset_from 2020-06-21 13:50:06 +02:00
Oliver Scherer
e465b227d1 icmp can handle raw pointers just fine, there's no need to cast to int. 2020-06-21 13:17:05 +02:00
Ralf Jung
1c74ab4226 Make is_freeze and is_copy_modulo_regions take TyCtxtAt 2020-06-21 11:47:19 +02:00
bors
7adbc0dfef Auto merge of #73546 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/73405
Cc @rust-lang/miri r? @ghost
2020-06-21 09:28:26 +00:00
Matthew Jasper
6e12272af0 Replace is_global call on data with call on predicate 2020-06-21 10:22:21 +01:00
Matthew Jasper
f802ee1f59 Cache flags and escaping vars for predicates
Also hash predicates by address
2020-06-21 10:22:21 +01:00
Matthew Jasper
8ea55f1a99 Cache decoded predicate shorthands 2020-06-21 10:18:01 +01:00
Johannes Schilling
e3d735dcbf Fix typo in error_codes doc 2020-06-21 10:22:19 +02:00
bors
38bd83df88 Auto merge of #71911 - wesleywiser:const_prop_small_cleanups, r=oli-obk
[mir-opt] Small ConstProp cleanup
2020-06-21 05:56:26 +00:00
Youngsuk Kim
63740548aa
Fix typos in doc comments
This commit fixes typos in the doc comments of 'librustc_mir/monomorphize/collector.rs'
2020-06-20 22:53:51 -04:00
bors
228a0ed7b0 Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisa
Add a lint to catch clashing `extern` fn declarations.

Closes #69390.

Adds lint `clashing_extern_decl` to detect when, within a single crate, an extern function of the same name is declared with different types. Because two symbols of the same name cannot be resolved to two different functions at link time, and one function cannot possibly have two types, a clashing extern declaration is almost certainly a mistake.

This lint does not run between crates because a project may have dependencies which both rely on the same extern function, but declare it in a different (but valid) way. For example, they may both declare an opaque type for one or more of the arguments (which would end up distinct types), or use types that are valid conversions in the language the extern fn is defined in. In these cases, we can't say that the clashing declaration is incorrect.

r? @eddyb
2020-06-21 02:20:07 +00:00
Adrian Taylor
a63eb3c678 Clarify --extern documentation.
Fixes #64731, #73531.

See also #64402#issuecomment-530852886
2020-06-20 17:02:18 -07:00
David Tolnay
4896a06667
Update stability attribute of new Vec PartialEq impls 2020-06-20 16:02:21 -07:00