Commit Graph

9421 Commits

Author SHA1 Message Date
Yuki Okushi
48cad460bc Fix test not to depend on environment 2020-01-11 10:15:54 +09:00
varkor
799efd3615 Fix issue with using self module via indirection 2020-01-10 23:30:13 +00:00
bors
e621797264 Auto merge of #65241 - tmiasko:no-std-san, r=alexcrichton
build-std compatible sanitizer support

### Motivation

When using `-Z sanitizer=*` feature it is essential that both user code and
standard library is instrumented. Otherwise the utility of sanitizer will be
limited, or its use will be impractical like in the case of memory sanitizer.

The recently introduced cargo feature build-std makes it possible to rebuild
standard library with arbitrary rustc flags. Unfortunately, those changes alone
do not make it easy to rebuild standard library with sanitizers, since runtimes
are dependencies of std that have to be build in specific environment,
generally not available outside rustbuild process. Additionally rebuilding them
requires presence of llvm-config and compiler-rt sources.

The goal of changes proposed here is to make it possible to avoid rebuilding
sanitizer runtimes when rebuilding the std, thus making it possible to
instrument standard library for use with sanitizer with simple, although
verbose command:

```
env CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Zsanitizer=thread cargo test -Zbuild-std --target x86_64-unknown-linux-gnu
```

### Implementation

* Sanitizer runtimes are no long packed into crates. Instead, libraries build
  from compiler-rt are used as is, after renaming them into `librusc_rt.*`.
* rustc obtains runtimes from target libdir for default sysroot, so that
  they are not required in custom build sysroots created with build-std.
* The runtimes are only linked-in into executables to address issue #64629.
  (in previous design it was hard to avoid linking runtimes into static
  libraries produced by rustc as demonstrated by sanitizer-staticlib-link
  test, which still passes despite changes made in #64780).

cc @kennytm, @japaric, @firstyear, @choller
2020-01-10 23:26:21 +00:00
Yuki Okushi
a491100aa3 Rollup merge of #68014 - estebank:unify-e0599, r=cramertj
Unify output of "variant not found" errors

Fix #49566.
2020-01-11 04:50:48 +09:00
Esteban Küber
38a3506c45 Ignore platforms that can't point to std 2020-01-10 11:40:30 -08:00
Esteban Küber
8eb7ac561e Use def_span to minimize definition span to first line when possible 2020-01-10 11:40:29 -08:00
Esteban Küber
39c96a0f53 Point at the span for the definition of crate foreign ADTs 2020-01-10 11:40:29 -08:00
Esteban Küber
f6e9fd037a Add ICE regression tests 2020-01-10 11:24:05 -08:00
varkor
8ca55641fd Clarify suggestion for E0013 2020-01-10 13:31:36 +00:00
Oliver Scherer
ecd5852194 Errors in promoteds may only cause lints not hard errors 2020-01-10 09:08:25 +01:00
Oliver Scherer
6e1bbff2c6 Promoteds also need param envs.
This also allows us to use the `const_eval` query again without causing cycles
2020-01-10 09:08:25 +01:00
Santiago Pastorino
1688719214 Promote Refs to constants instead of static 2020-01-10 09:08:24 +01:00
Mazdak Farrokhzad
d5598aa7a0 Introduce #![feature(half_open_range_patterns)].
This feature adds `X..`, `..X`, and `..=X` patterns.
2020-01-10 07:29:04 +01:00
Esteban Küber
fcd850fc5d Do not ICE on unicode next point
Use `shrink_to_hi` instead of `next_point`
Fix #68000.
2020-01-09 22:10:18 -08:00
Mazdak Farrokhzad
6f3f1c537b Rollup merge of #68073 - Centril:fix-68062, r=estebank
expect `fn` after `const unsafe` / `const extern`

Fixes #68062

r? @estebank @petrochenkov
cc @Aaron1011
2020-01-10 02:47:36 +01:00
Mazdak Farrokhzad
2307f0c4ea Rollup merge of #68071 - estebank:ice-67995, r=Centril
Extend support of `_` in type parameters

 - Account for `impl Trait<_>`.
 - Provide a reasonable `Span` for empty `Generics` in `impl`s.
 - Account for `fn foo<_>(_: _) {}` to suggest `fn foo<T>(_: T) {}`.
 - Fix #67995. Follow up to #67597.
2020-01-10 02:47:34 +01:00
Mazdak Farrokhzad
f3963873aa Rollup merge of #67820 - ecstatic-morse:const-trait, r=oli-obk
Parse the syntax described in RFC 2632

This adds support for both `impl const Trait for Ty` and `?const Trait` bound syntax from rust-lang/rfcs#2632 to the parser. For now, both modifiers end up in a newly-added `constness` field on `ast::TraitRef`, although this may change once the implementation is fleshed out.

I was planning on using `delay_span_bug` when this syntax is encountered during lowering, but I can't write `should-ice` UI tests. I emit a normal error instead, which causes duplicates when the feature gate is not enabled (see the `.stderr` files for the feature gate tests). Not sure what the desired approach is; Maybe just do nothing when the syntax is encountered with the feature gate is enabled?

@oli-obk I went with `const_trait_impl` and `const_trait_bound_opt_out` for the names of these features. Are these to your liking?

cc #67792 #67794

r? @Centril
2020-01-10 02:47:32 +01:00
Mazdak Farrokhzad
aabb03763d Rollup merge of #66463 - estebank:point-at-closure-and-opaque-types, r=Centril
Point at opaque and closure type definitions in type errors

Fixes #57266, fixes #67117.
2020-01-10 02:47:29 +01:00
Dylan MacKenzie
fd1c00348b Add test for ?const in nested impl/dyn trait 2020-01-09 16:47:05 -08:00
Dylan MacKenzie
9950a1f3bd Add test for ?const and ? on the same bound 2020-01-09 16:47:05 -08:00
Dylan MacKenzie
343e1570a9 Add tests for RFC 2632 2020-01-09 16:47:05 -08:00
Esteban Küber
6e04cf062f review comments: more tests 2020-01-09 15:43:20 -08:00
Esteban Küber
c751961d29 Extend support of _ in type parameters
- Account for `impl Trait<_>`.
 - Provide a reasonable `Span` for empty `Generics` in `impl`s.
 - Account for `fn foo<_>(_: _) {}` to suggest `fn foo<T>(_: T) {}`.
 - Fix #67995.
2020-01-09 14:20:53 -08:00
Mazdak Farrokhzad
915db7ae64 expect fn after const unsafe / const extern 2020-01-09 23:02:34 +01:00
Yuki Okushi
54f860158b Fix ICE #68058 2020-01-10 06:52:22 +09:00
Yuki Okushi
08c5999dc4 Rollup merge of #67967 - JohnTitor:fix-ice-0107, r=matthewjasper
Delay bug to prevent ICE in MIR borrowck

Fixes #67947

r? @matthewjasper
2020-01-10 04:18:37 +09:00
Vadim Petrochenkov
b82cd9f639 Address review comments + Update NLL tests 2020-01-09 21:49:32 +03:00
Vadim Petrochenkov
642669c74d Update tests 2020-01-09 21:23:12 +03:00
Aaron Hill
4840cd8117 Don't discard marker trait impls when inference variables are present
Fixes #61651

Previously, we would unconditionally discard impl candidates for marker
traits during trait selection. However, if the predicate had inference
variables, this could have the effect of constrainting inference
variables (due to a successful trait selection) when we would have
otherwise failed due to mutliple applicable impls,

This commit prevents marker trait impls from being discarded while the
obligation predicate has any inference variables, ensuring that
discarding impls will never cause us to incorrectly constraint inference
variables.
2020-01-09 10:01:20 -05:00
Tomasz Miąsko
36d0812570 Remove sanitizer_runtime attribute 2020-01-09 07:54:02 +01:00
Felix S. Klock II
31938366d2 Keep plugging holes in the test to placate CI.
If this happens again, I'm going to change tack and make this
an `// only-linux` test or something along those lines.
2020-01-09 05:20:06 +01:00
Mazdak Farrokhzad
5e6eeb092d Rollup merge of #68024 - petrochenkov:recoverall, r=Centril
Remove `-Z continue-parse-after-error`

We are just always recovering and continuing now.

r? @estebank @Centril
2020-01-09 00:22:20 +01:00
Mazdak Farrokhzad
d2922e51a7 Rollup merge of #68023 - FSciammarella:master, r=Centril,varkor
Fix issue #68008

Correcting Typo on error message. From "substract" to "subtract".

Fixes #68008.
2020-01-09 00:22:18 +01:00
Mazdak Farrokhzad
916a7d3a2c Rollup merge of #67990 - Centril:slice-pats-move-tests-match, r=matthewjasper
slice patterns: harden match-based borrowck tests

This hardens some move-checking tests wrt. slice patterns and `match` expressions.

r? @matthewjasper
cc @pnkfelix
cc https://github.com/rust-lang/rust/pull/67712
cc https://github.com/rust-lang/rust/issues/53114
2020-01-09 00:22:14 +01:00
Mazdak Farrokhzad
1a0b2a5aaa Rollup merge of #67747 - estebank:bare-assoc-const, r=Centril
Explain that associated types and consts can't be accessed directly on the trait's path

Partially address #44539.
2020-01-09 00:22:07 +01:00
Felipe Sciammarella
7de174b86e Fix Typo on cannot "substract"
Fix Typo on hir::BinOpKind::Sub

"substract" to "subtract"

Fix Typo on "Error cannot substract"

Fix Typo on cannot "substract"
2020-01-08 19:25:38 -03:00
Yuki Okushi
4fce9c27fb Delay bug to prevent ICE in MIR borrowck 2020-01-09 05:57:28 +09:00
Vadim Petrochenkov
41a93cba38 Remove -Z continue-parse-after-error 2020-01-08 21:48:04 +03:00
Esteban Küber
ac3d4cccea Explain that associated types and consts can't be accessed directly on the trait's path 2020-01-08 09:41:51 -08:00
Esteban Küber
542be6fb6c review comment: wording 2020-01-08 09:30:27 -08:00
Esteban Küber
0dcdbaec0b Point at the def span of trait refs E0277 2020-01-08 09:30:27 -08:00
Esteban Küber
c55615155d review comments 2020-01-08 09:29:47 -08:00
Esteban Küber
9c0000caca Point at opaque and closure type definitions in type errors 2020-01-08 09:29:47 -08:00
Esteban Küber
2c5766f2d4 Unify output of "variant not found" errors 2020-01-08 08:05:31 -08:00
Yuki Okushi
1c9b8036bf Rollup merge of #67887 - anp:tracked-std-panics, r=nagisa
`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`

The annotated functions now produce panic messages pointing to the location where they were called, rather than `core`'s internals.
2020-01-09 00:29:15 +09:00
Yuki Okushi
429a7e7522 Rollup merge of #67849 - cjkenn:check-sorted-words, r=estebank
Add a check for swapped words when we can't find an identifier

Fixes #66968

Couple things here:
1. The matches take the precedence of case insensitive match, then levenshtein match, then swapped words match. Doing this allows us to not even check for swapped words unless the other checks return `None`.
2. I've assumed that the swapped words check is not held to the limits of the max levenshtein distance threshold (ie. we want to try and find a match even if the levenshtein distance is very high). This means that we cannot perform this check in the `fold` that occurs after the `filter_map` call, because the candidate will be filtered out. So, I've split this into two separate `fold` calls, and had to collect the original iterator into a vec so it can be copied (I don't think we want to change the function signature to take a vec or require the `Copy` trait). An alternative implemenation may be to remove the `filter_map`, `fold` over the entire iterator, and do a check against `max_dist` inside the relevant cases there.

r? @estebank
2020-01-09 00:29:12 +09:00
Mazdak Farrokhzad
2c3e5d3de0 - remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
2020-01-08 04:25:33 +01:00
Mazdak Farrokhzad
0a6cdc231e slice patterns: harden match-based borrowck tests 2020-01-08 00:42:53 +01:00
Adam Perry
3acd346594 Skip caller location test in wasm32. 2020-01-07 07:22:49 -08:00
Yuki Okushi
b065031096 Rollup merge of #67936 - euclio:assoc-type-bad-style, r=Centril
fire "non_camel_case_types" for associated types

Fixes #67920.
2020-01-07 13:46:13 +09:00