Commit Graph

32358 Commits

Author SHA1 Message Date
Matthew Jasper 69fc6d8c5c Fix NLL compare mode tests 2020-10-06 11:19:33 +01:00
Matthew Jasper 022c148fcd Fix tests from rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper e42c97919c Don't require lifetime super-bounds on traits apply to trait objects of that trait 2020-10-06 11:19:32 +01:00
Matthew Jasper e674cf0200 Normalize super trait bounds when confirming object candidates 2020-10-06 11:19:32 +01:00
Matthew Jasper d08ab945de Fix rebase 2020-10-06 11:19:32 +01:00
Matthew Jasper e29765250b Don't immediately error for recursive projections 2020-10-06 11:19:32 +01:00
Matthew Jasper 6c4feb681f Fix bootstrap 2020-10-06 11:19:32 +01:00
Matthew Jasper ed32482534 Handle multiple trait-def projection candidates 2020-10-06 11:19:32 +01:00
Matthew Jasper 0dfa6ff3be Avoid cycles from projection bounds
Only check the own predicates of associated types when confirming
projection candidates.
Also consider implied bounds when comparing trait and impl methods.
2020-10-06 11:19:32 +01:00
Matthew Jasper 596d6c4b3b Avoid cycle with projections from object types
Normalizing `<dyn Iterator<Item = ()> as Iterator>::Item` no longer
requires selecting `dyn Iterator<Item = ()>: Iterator`. This was
previously worked around by using a special type-folder to normalize
things.
2020-10-06 11:19:31 +01:00
Matthew Jasper 34e5a4992c Normalize projection bounds when considering candidates
This unfortunately requires some winnowing hacks to avoid
now ambiguous candidates.
2020-10-06 11:19:31 +01:00
Matthew Jasper cfee49593d Handle multiple applicable projection candidates 2020-10-06 11:19:31 +01:00
Matthew Jasper bc08b791bc Fix bugs in evaluating WellFormed predicates
- List the nestsed obligations in an order that works with the
  single pass used by evaluation
- Propagate recursion depth correctly
2020-10-06 11:19:31 +01:00
Matthew Jasper f52b2d8890 Avoid cycle in nested obligations for object candidate
Bounds of the form `type Future: Future<Result=Self::Result>` exist in
some ecosystem crates. To validate these bounds for trait objects we
need to normalize `Self::Result` in a way that doesn't cause a cycle.
2020-10-06 11:19:31 +01:00
Matthew Jasper 582ccec1c5 Remove predicates on associated types from traits
These need to only be bounds to avoid cycle errors in trait checking.
2020-10-06 11:19:31 +01:00
Matthew Jasper 042464f75a Fix tests and bootstrap 2020-10-06 11:19:30 +01:00
Matthew Jasper 2bdf723da7 Ensure that associated types for trait objects satisfy their bounds 2020-10-06 11:19:30 +01:00
Matthew Jasper 1b07991574 Check associated type bounds for object safety violations 2020-10-06 11:19:30 +01:00
Matthew Jasper 5b279c8016 Check opaque types satisfy their bounds 2020-10-06 11:19:30 +01:00
Matthew Jasper b3057f4d5f Check projections are well-formed when using projection candidates 2020-10-06 11:19:29 +01:00
Matthew Jasper f958e6c246 Separate bounds and predicates for associated/opaque types 2020-10-06 11:19:29 +01:00
Yuki Okushi 552933b79d
Rollup merge of #77591 - Aaron1011:fix/hygiene-def-scope, r=estebank
Record `expansion_that_defined` into crate metadata

Fixes #77523

Now that hygiene serialization is implemented, we also need to record
`expansion_that_defined` so that we properly handle a foreign
`SyntaxContext`.
2020-10-06 16:26:16 +09:00
Yuki Okushi cc908f3b70
Rollup merge of #77587 - ehuss:unicode-escape-span, r=ecstatic-morse
Fix span for unicode escape suggestion.

If a unicode escape is missing the curly braces, the suggested fix is to add the curly braces, but the span for the fix was incorrect. It was not covering the `\u`, but the suggested text includes the `\u`, causing the resulting fix to be `"\u\u{1234}"`. This changes it so that the span includes the `\u`. An alternate fix would be to remove `\u` from the suggested fix, but I think the error message reads better if the entire escape is included.
2020-10-06 16:26:14 +09:00
Yuki Okushi bc600c3905
Rollup merge of #77534 - Mark-Simulacrum:issue-70819-disallow-override-forbid-in-same-scope, r=petrochenkov
Disallow overriding forbid in same scope

Rebased #73379.

Fixes #70819.
2020-10-06 16:26:04 +09:00
Aaron Hill 8d11f90a16
Record `expansion_that_defined` into crate metadata
Fixes #77523

Now that hygiene serialization is implemented, we also need to record
`expansion_that_defined` so that we properly handle a foreign
`SyntaxContext`.
2020-10-05 16:01:19 -04:00
Eric Huss 35192ff574 Fix span for unicode escape suggestion. 2020-10-05 11:19:08 -07:00
Rich Kadel 6f627663a7 Renamed tests to avoid exceeding Windows max path limit 2020-10-05 09:40:25 -07:00
Rich Kadel f5aebad28f Updates to experimental coverage counter injection
This is a combination of 18 commits.

Commit #2:

Additional examples and some small improvements.

Commit #3:

fixed mir-opt non-mir extensions and spanview title elements

Corrected a fairly recent assumption in runtest.rs that all MIR dump
files end in .mir. (It was appending .mir to the graphviz .dot and
spanview .html file names when generating blessed output files. That
also left outdated files in the baseline alongside the files with the
incorrect names, which I've now removed.)

Updated spanview HTML title elements to match their content, replacing a
hardcoded and incorrect name that was left in accidentally when
originally submitted.

Commit #4:

added more test examples

also improved Makefiles with support for non-zero exit status and to
force validation of tests unless a specific test overrides it with a
specific comment.

Commit #5:

Fixed rare issues after testing on real-world crate

Commit #6:

Addressed PR feedback, and removed temporary -Zexperimental-coverage

-Zinstrument-coverage once again supports the latest capabilities of
LLVM instrprof coverage instrumentation.

Also fixed a bug in spanview.

Commit #7:

Fix closure handling, add tests for closures and inner items

And cleaned up other tests for consistency, and to make it more clear
where spans start/end by breaking up lines.

Commit #8:

renamed "typical" test results "expected"

Now that the `llvm-cov show` tests are improved to normally expect
matching actuals, and to allow individual tests to override that
expectation.

Commit #9:

test coverage of inline generic struct function

Commit #10:

Addressed review feedback

* Removed unnecessary Unreachable filter.
* Replaced a match wildcard with remining variants.
* Added more comments to help clarify the role of successors() in the
CFG traversal

Commit #11:

refactoring based on feedback

* refactored `fn coverage_spans()`.
* changed the way I expand an empty coverage span to improve performance
* fixed a typo that I had accidently left in, in visit.rs

Commit #12:

Optimized use of SourceMap and SourceFile

Commit #13:

Fixed a regression, and synched with upstream

Some generated test file names changed due to some new change upstream.

Commit #14:

Stripping out crate disambiguators from demangled names

These can vary depending on the test platform.

Commit #15:

Ignore llvm-cov show diff on test with generics, expand IO error message

Tests with generics produce llvm-cov show results with demangled names
that can include an unstable "crate disambiguator" (hex value). The
value changes when run in the Rust CI Windows environment. I added a sed
filter to strip them out (in a prior commit), but sed also appears to
fail in the same environment. Until I can figure out a workaround, I'm
just going to ignore this specific test result. I added a FIXME to
follow up later, but it's not that critical.

I also saw an error with Windows GNU, but the IO error did not
specify a path for the directory or file that triggered the error. I
updated the error messages to provide more info for next, time but also
noticed some other tests with similar steps did not fail. Looks
spurious.

Commit #16:

Modify rust-demangler to strip disambiguators by default

Commit #17:

Remove std::process::exit from coverage tests

Due to Issue #77553, programs that call std::process::exit() do not
generate coverage results on Windows MSVC.

Commit #18:

fix: test file paths exceeding Windows max path len
2020-10-05 08:02:58 -07:00
bors d890e64dff Auto merge of #77549 - tmiasko:simplify-branch-same-fix, r=oli-obk
Fix miscompile in SimplifyBranchSame

Cherry-picked from #77486, but with a different test case that used to be compiled incorrectly on both master & beta branches.
2020-10-05 11:41:59 +00:00
bors efbaa41306 Auto merge of #77557 - Dylan-DPC:rollup-aib9ptp, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #75853 (Use more intra-doc-links in `core::fmt`)
 - #75928 (Remove trait_selection error message in specific case)
 - #76329 (Add check for doc alias attribute at crate level)
 - #77219 (core::global_allocator docs link to std::alloc::GlobalAlloc)
 - #77395 (BTreeMap: admit the existence of leaf edges in comments)
 - #77407 (Improve build-manifest to work with the improved promote-release)
 - #77426 (Include scope id in SocketAddrV6::Display)
 - #77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`)
 - #77471 (BTreeMap: refactoring around edges, missed spots)
 - #77512 (Allow `Abort` terminators in all const-contexts)
 - #77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter)

Failed merges:

r? `@ghost`
2020-10-05 02:49:51 +00:00
bors ced813fec0 Auto merge of #77466 - Aaron1011:reland-drop-tree, r=matthewjasper
Re-land PR #71840 (Rework MIR drop tree lowering)

PR https://github.com/rust-lang/rust/pull/71840 was reverted in https://github.com/rust-lang/rust/pull/72989 to fix an LLVM error (https://github.com/rust-lang/rust/issues/72470). That LLVM error no longer occurs with the recent upgrade to LLVM 11 (https://github.com/rust-lang/rust/pull/73526), so let's try re-landing this PR.

I've cherry-picked the commits from the original PR (with the exception of the commit blessing test output), making as few modifications as possible. I addressed the rebase fallout in separate commits on top of those.

r? `@matthewjasper`
2020-10-05 00:35:58 +00:00
Dylan DPC 5fbb41108a
Rollup merge of #77512 - ecstatic-morse:const-checking-allow-abort, r=RalfJung
Allow `Abort` terminators in all const-contexts

We never unwind during const-eval, so we basically have these semantics already. Also I just figured out that these only appear along the cleanup path, which doesn't get const-checked. In other words, this doesn't actually change behavior: the `check-pass` test I added compiles just fine on nightly.

r? @RalfJung
cc @rust-lang/wg-const-eval
2020-10-05 02:29:40 +02:00
Dylan DPC e032bb7c65
Rollup merge of #77439 - varkor:min_const_generics-tests, r=lcnr,estebank
Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`

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

Adds `min_const_generics` tests for:
- https://github.com/rust-lang/rust/issues/73727
- https://github.com/rust-lang/rust/issues/72293
- https://github.com/rust-lang/rust/issues/67375
- https://github.com/rust-lang/rust/issues/75153
- https://github.com/rust-lang/rust/issues/71922
- https://github.com/rust-lang/rust/issues/69913
- https://github.com/rust-lang/rust/issues/67945
- https://github.com/rust-lang/rust/issues/69239

Adds `const_generics` tests for:
- https://github.com/rust-lang/rust/issues/67375
- https://github.com/rust-lang/rust/issues/75153
- https://github.com/rust-lang/rust/issues/71922
- https://github.com/rust-lang/rust/issues/69913
- https://github.com/rust-lang/rust/issues/67945
- https://github.com/rust-lang/rust/issues/69239

(I only added separate `min_const_generics` and `const_generics` tests if they were handled differently by the two features.)

We need to figure out how to deduplicate when `const_generics` is stabilised, but we can discuss that later. For now, we should be checking neither feature breaks, so require regression tests for both. I've given them identical names when I've added both, which should make it easier to spot them later.

r? @lcnr
2020-10-05 02:29:36 +02:00
Dylan DPC e6e7ccc28d
Rollup merge of #76329 - GuillaumeGomez:doc-alias-crate-level, r=matthewjasper
Add check for doc alias attribute at crate level

Fixes #76298, #64734, #69365.

r? @ollie27
2020-10-05 02:29:27 +02:00
Dylan DPC 5fa978fa1b
Rollup merge of #75928 - JulianKnodt:non_utf8, r=estebank
Remove trait_selection error message in specific case

In the case that a trait is not implemented for an ADT with type errors, cancel the error.

Fixes #75627
2020-10-05 02:29:25 +02:00
bors beb5ae474d Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrum
Hint the maximum length permitted by invariant of slices

One of the safety invariants of references, and in particular of references to slices, is that they may not cover more than `isize::MAX` bytes. The unsafe `from_raw_parts` constructors of slices explicitly requires the caller to guarantee this fact. Violating it would also be UB with regards to the semantics of generated llvm code.

This effectively bounds the length of a (non-ZST) slice from above by a compile time constant. But when the length is loaded from a function argument it appears llvm is not aware of this requirement. The additional value range assertions allow some further elision of code branches, including overflow checks, especially in the presence of artithmetic on the indices.

This may have a performance impact, adding more code to a common method but allowing more optimization. I'm not quite sure, is the Rust side of const-prop strong enough to elide the irrelevant match branches?

Fixes: #67186
2020-10-04 21:08:06 +00:00
ecstatic-morse 6ae1da3198
But whatever 2020-10-04 13:25:45 -07:00
Aaron Hill ce8d75714b
Bless more test output 2020-10-04 14:53:32 -04:00
Andreas Molzer e44784b875 Assume slice len is bounded by allocation size
Uses assume to check the length against a constant upper bound. The
inlined result then informs the optimizer of the sound value range.

This was tried with unreachable_unchecked before which introduces a
branch. This has the advantage of not being executed in sound code but
complicates basic blocks. It resulted in ~2% increased compile time in
some worst cases.

Add a codegen test for the assumption, testing the issue from #67186
2020-10-04 20:43:36 +02:00
Felix S. Klock II afa2a67545 Prevent forbid from being ignored if overriden at the same level.
That is, this changes `#[forbid(foo)] #[allow(foo)]` from allowing foo to
forbidding foo.
2020-10-04 13:14:01 -04:00
Felix S. Klock II b4e77d21bc rewrite old test so that its attributes are consistent with what we want in the language.
(Note that the fact this test existed is a slight sign that we may need a crater
run on this bugfix...)
2020-10-04 12:45:53 -04:00
Jonas Schievink 5bd9ce5cd4
Rollup merge of #77504 - Amanieu:select_simd_bitmask, r=ecstatic-morse
Support vectors with fewer than 8 elements for simd_select_bitmask

Resolves the issue raised here: https://github.com/rust-lang/stdarch/issues/310#issuecomment-693730094
2020-10-04 15:45:43 +02:00
Jonas Schievink 9ea462fd70
Rollup merge of #77368 - est31:apfloat_fix, r=varkor
Backport LLVM apfloat commit to rustc_apfloat

Backports LLVM commit: e34bd1e0b0

Fixes #69532
2020-10-04 15:45:39 +02:00
Aaron Hill eb94cdd85e
Apply suggestions from review
Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
2020-10-04 07:54:03 -04:00
Aaron Hill 33337bb855
Bless mir-opt tests 2020-10-04 07:54:02 -04:00
Aaron Hill f23e9a1adf
Add regression test for issue #72470
This was fixed with the upgrade to LLVM 11 in #73526.
It seems extremely unlikey that this exact issue will ever reoccur,
since slight modifications to the code caused the crash to stop
happening. However, it can't hurt to have a test for it.
2020-10-04 07:54:02 -04:00
Matthew Jasper fa3e2fcbe4
Defer creating drop trees in MIR lowering until leaving that scope 2020-10-04 07:54:01 -04:00
Guillaume Gomez 3641a37455 Enforce crate level attributes checks 2020-10-04 13:36:47 +02:00
bors 0d37dca25a Auto merge of #76448 - haraldh:default_alloc_error_handler_reduced, r=Amanieu
Implement Make `handle_alloc_error` default to panic (for no_std + liballoc)

Related: https://github.com/rust-lang/rust/issues/66741

Guarded with `#![feature(default_alloc_error_handler)]` a default
`alloc_error_handler` is called, if a custom allocator is used and no
other custom `#[alloc_error_handler]` is defined.
2020-10-04 08:56:05 +00:00
Yuki Okushi 0ed4849a3e
Rollup merge of #77469 - camelid:rustdoc-better-failed-res-error, r=jyn514
Improve rustdoc error for failed intra-doc link resolution

The previous error was confusing since it made it sound like you can't
link to items that are defined outside the current module.

Also suggested importing the item.

r? @jyn514
2020-10-04 11:45:08 +09:00