Commit graph

160 commits

Author SHA1 Message Date
bors
e0ef0fc392 Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Introduce `TypeVisitor::BreakTy`

Implements MCP rust-lang/compiler-team#383.
r? `@ghost`
cc `@lcnr` `@oli-obk`

~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17 12:24:34 +00:00
lcnr
a6cbd64dae words 2020-11-16 22:42:09 +01:00
Bastian Kauschke
2bf93bd852 compiler: fold by value 2020-11-16 22:34:57 +01:00
Jonas Schievink
8825942e86
Rollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakis
Allow making `RUSTC_BOOTSTRAP` conditional on the crate name

Motivation: This came up in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Require.20users.20to.20confirm.20they.20know.20RUSTC_.E2.80.A6.20compiler-team.23350/near/208403962) for https://github.com/rust-lang/compiler-team/issues/350.
See also https://github.com/rust-lang/cargo/pull/6608#issuecomment-458546258; this implements https://github.com/rust-lang/cargo/issues/6627.
The goal is for this to eventually allow prohibiting setting `RUSTC_BOOTSTRAP` in build.rs (https://github.com/rust-lang/cargo/issues/7088).

## User-facing changes

- `RUSTC_BOOTSTRAP=1` still works; there is no current plan to remove this.
- Things like `RUSTC_BOOTSTRAP=0` no longer activate nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway.
- `RUSTC_BOOTSTRAP=x` will enable nightly features only for crate `x`.
- `RUSTC_BOOTSTRAP=x,y` will enable nightly features only for crates `x` and `y`.

## Implementation changes

The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

I'm not sure whether this counts as T-compiler or T-lang; _technically_ RUSTC_BOOTSTRAP is an implementation detail, but it's been used so much it seems like this counts as a language change too.

r? `@joshtriplett`
cc `@Mark-Simulacrum` `@hsivonen`
2020-11-15 13:39:43 +01:00
LeSeulArtichaut
65cdc21f06 Set the default BreakTy to ! 2020-11-14 21:46:39 +01:00
LeSeulArtichaut
17b395d296 Use TypeVisitor::BreakTy in structural_match::Search 2020-11-14 21:15:32 +01:00
LeSeulArtichaut
e0f3119103 Introduce TypeVisitor::BreakTy 2020-11-14 20:25:27 +01:00
Dániel Buga
f0d0d87a20 Push to result vector instead of allocating
Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
2020-11-13 11:19:25 +01:00
Jonas Schievink
2e0a0b42ad
Rollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obk
look at assoc ct, check the type of nodes

an example where types matter are function objects, see the added test which previously passed.

Now does a shallow comparison of unevaluated constants.

r? ```@oli-obk```
2020-11-11 20:59:02 +01:00
Nicholas-Baron
261ca04c92 Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in
that applying it in all places would result in a reduction in
readability.

A few of the trivial functions (like `Path::new`) are fine to leave
outside of closures.

The general rule seems to be that anything that is obviously an
allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it
is a 0-sized allocation.
2020-11-10 20:07:47 -08:00
bors
87a0997ef9 Auto merge of #78410 - lcnr:revert75443, r=nikomatsakis
revert #75443, update mir validator

This PR reverts rust-lang#75443 to fix rust-lang#75992 and instead uses rust-lang#75419 to fix rust-lang#75313.

Adapts rust-lang#75419 to correctly deal with unevaluated constants as otherwise some `feature(const_evaluatable_checked)` tests would ICE.

Note that rust-lang#72793 was also fixed by rust-lang#75443, but as that issue only concerns `feature(type_alias_impl_trait)` I deleted that test case for now and would reopen that issue.

rust-lang#75443 may have also allowed some other code to now successfully compile which would make this revert a breaking change after 2 stable versions, but I hope that this is a purely theoretical concern.

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/generator.20upvars/near/214617274 for more reasoning about this.

r? `@nikomatsakis` `@eddyb` `@RalfJung`
2020-11-08 11:27:06 +00:00
Joshua Nelson
622c48e4f1 Allow making RUSTC_BOOTSTRAP conditional on the crate name
The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

  There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no
  longer active nightly features. In practice this shouldn't be a big
  deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone
  uses `RUSTC_BOOTSTRAP=1` anyway.

- Add tests

  Check against `Cheat`, not whether nightly features are allowed.
  Nightly features are always allowed on the nightly channel.

- Only call `is_nightly_build()` once within a function

- Use booleans consistently for rustc_incremental

  Sessions can't be passed through threads, so `read_file` couldn't take a
  session. To be consistent, also take a boolean in `write_file_header`.
2020-11-07 13:45:11 -05:00
Bastian Kauschke
439171e094 look at assoc ct, check the type of nodes 2020-11-07 12:39:52 +01:00
bors
f92b931045 Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint

Part of #77501.

r? `@jyn514`
2020-11-06 04:17:41 +00:00
Guillaume Gomez
99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
Matthias Krüger
bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
Bastian Kauschke
cc19df627e revert #75443 update mir validator 2020-11-02 23:57:03 +01:00
Yuki Okushi
8d651013e4 Fix format 2020-11-02 16:59:11 +09:00
Yuki Okushi
54d9ffc0b9 Only separate notes if span is multiline 2020-11-02 16:54:53 +09:00
Yuki Okushi
2da86a1bfd Add "this has type {} which {}" note 2020-11-02 15:53:59 +09:00
Yuki Okushi
66226ca157 Address some code reviews 2020-11-02 15:53:59 +09:00
Yuki Okushi
ad978e5572 Separate complex multispan into some notes 2020-11-02 15:53:59 +09:00
LeSeulArtichaut
9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut
24e1a7e656 Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut
4fe735b320 TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection} 2020-10-30 12:27:34 +01:00
Jonas Schievink
7fa9e39682
Rollup merge of #78422 - estebank:fix-78372, r=pnkfelix
Do not ICE on invalid input

Fix #78372.
2020-10-29 17:05:14 +01:00
Dylan DPC
1a64e570c6
Rollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk
check object safety of generic constants

As `Self` can only be effectively used in constants with `const_evaluatable_checked` this should not matter outside of it.

Implements the first item of #72219

> Object safety interactions with constants

r? @oli-obk for now cc @nikomatsakis
2020-10-28 01:21:21 +01:00
Santiago Pastorino
708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
Esteban Küber
cd259dbd19 Do not ICE on invalid input 2020-10-26 17:42:46 -07:00
Bastian Kauschke
60bcc58dce debug log AbstractConst::new 2020-10-26 14:56:58 +01:00
Dylan DPC
083a5cd9a2
Rollup merge of #78214 - estebank:match-semicolon, r=oli-obk
Tweak match arm semicolon removal suggestion to account for futures

* Tweak and extend "use `.await`" suggestions
* Suggest removal of semicolon on prior match arm
* Account for `impl Future` when suggesting semicolon removal
* Silence some errors when encountering `await foo()?` as can't be certain what the intent was

*Thanks to https://twitter.com/a_hoverbear/status/1318960787105353728 for pointing this out!*
2020-10-26 03:09:06 +01:00
Bastian Kauschke
0e419efb1c check for object safety violations in constants 2020-10-25 18:33:45 +01:00
Jonas Schievink
5ed8ac45d4
Rollup merge of #78272 - lcnr:abstract-const-unused-node, r=oli-obk
const_evaluatable_checked: deal with unused nodes + div

r? @oli-obk
2020-10-24 22:39:57 +02:00
Esteban Küber
f71e9ed7f1 review comments 2020-10-23 12:51:06 -07:00
Esteban Küber
b334eef162 Do not ICE with TraitPredicates containing [type error]
Fix #77919.
2020-10-23 12:21:47 -07:00
Esteban Küber
86df9039b2 Tweak "use .await" suggestion 2020-10-23 08:02:57 -07:00
Bastian Kauschke
47cb871f14 review 2020-10-23 15:04:12 +02:00
Bastian Kauschke
6ad140ca19 const_eval_checked: deal with unused nodes + div 2020-10-23 12:16:58 +02:00
Matthew Jasper
50dde2e4d8 Normalize when finding trait object candidates 2020-10-22 08:18:29 +01:00
Matthew Jasper
6c43a64931 Fix ICE from projection cycle
Cycles in normalization can cause evaluations to change from Unknown to
Err. This means that some selection that were applicable no longer are.

To avoid this:
* Selection candidates that are known to be applicable are prefered
  over candidates that are not.
* We don't ICE if a candidate is no longer applicable.
2020-10-21 19:43:20 +01:00
Yuki Okushi
9583029a2d
Rollup merge of #78002 - estebank:issue-77598, r=oli-obk
Tweak "object unsafe" errors

CC #77598.
2020-10-21 13:59:35 +09:00
Guillaume Gomez
01e6019448
Rollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum
Move orphan module-name/mod.rs files into module-name.rs files
2020-10-20 21:46:35 +02:00
Esteban Küber
88f5e110db review comments 2020-10-20 09:26:15 -07:00
Esteban Küber
ae0e3d0511 Tweak "object unsafe" errors
Fix #77598.
2020-10-20 09:26:14 -07:00
Yuki Okushi
3f1c637db4
Rollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr
Trait predicate ambiguities are not always in `Self`

When reporting ambiguities in trait predicates, the compiler incorrectly assumed the ambiguity was always in the type the trait should be implemented on, and never the generic parameters of the trait. This caused silly suggestions for predicates like `<KnownType as Trait<_>>`, such as giving explicit types to completely unrelated variables that happened to be of type `KnownType`.

This also reverts #73027, which worked around this issue in some cases and does not appear to be necessary any more.

fixes #77982
fixes #78055
2020-10-20 12:11:11 +09:00
SNCPlay42
71ca239f80 don't assume trait ambiguity happens in Self 2020-10-19 21:11:40 +01:00
bors
f90e617305 Auto merge of #77908 - bugadani:obl-forest, r=nnethercote
Try to make ObligationForest more efficient

This PR tries to decrease the number of allocations in ObligationForest, as well as moves some cold path code to an uninlined function.
2020-10-19 15:14:15 +00:00
est31
66c1fc4c87 Move orphan module-name/mod.rs files into module-name.rs files 2020-10-18 20:56:15 +02:00
bors
4d247ad7d3 Auto merge of #77306 - lcnr:inline-ok, r=eddyb
normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`
2020-10-18 16:10:00 +00:00
Jack Huey
f6a53b4c69 Review comments 2020-10-16 15:14:38 -04:00