Commit Graph

123324 Commits

Author SHA1 Message Date
Manish Goregaokar
ca5b64d2d2
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]

Enclose unsafe operations in unsafe blocks for net/tcp.rs. Fixes part of #73904.
2020-07-06 17:45:24 -07:00
Manish Goregaokar
e74ab50d07
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Audit hidden/short code suggestions

Should fix #73641.
Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes.
r? @estebank
2020-07-06 17:45:22 -07:00
Manish Goregaokar
245b006a2e Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
typeck: adding type information to projection

This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-07-06 17:45:20 -07:00
Manish Goregaokar
7942d9a65a
Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
typeck: adding type information to projection

This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-07-06 17:45:20 -07:00
Manish Goregaokar
3f90287bb6
Rollup merge of #73856 - pierwill:pierwill-lexer-doc, r=jonas-schievink
Edit librustc_lexer top-level docs

Minor edit, and adds link to librustc_parse::lexer.
2020-07-06 17:45:17 -07:00
Manish Goregaokar
218d96ed6b
Rollup merge of #70563 - GuillaumeGomez:page-hash-handling, r=ollie27,kinnison
[rustdoc] Page hash handling

Fixes https://github.com/rust-lang/rust/issues/70476

A good example to see the change is to use this URL: https://doc.rust-lang.org/nightly/std/string/struct.String.html#from_iter.v-3

After the change, it actually goes to the target element (and change the page hash to something more clear for the users).

r? @kinnison

cc @ollie27
2020-07-06 17:45:15 -07:00
Andy Russell
792f2dedd7
libstd: remove some mutable statics in sys::unix 2020-07-06 20:13:54 -04:00
pierwill
36e50a0fb3 Edit librustc_lexer top-level docs
Add link to librustc_parse::lexer
2020-07-06 16:01:47 -07:00
pierwill
7610ab36f8
Expand abbreviation in core::ffi description 2020-07-06 14:30:37 -07:00
bors
4705037374 Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercote
Shrink ParamEnv to 16 bytes

r? @nnethercote

x.py check passes but I haven't tried running perf or tests
2020-07-06 20:44:16 +00:00
bors
8981dbbc36 Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercote
Shrink ParamEnv to 16 bytes

r? @nnethercote

x.py check passes but I haven't tried running perf or tests
2020-07-06 20:44:16 +00:00
Gary Guo
368aa6f1e2 Add test for issue 74083 2020-07-06 21:18:04 +01:00
Gary Guo
97867bbe5c Add UI test for issue 74082 2020-07-06 21:04:54 +01:00
Gary Guo
5702e0289f Only allow repr(i128/u128) on enum 2020-07-06 20:42:19 +01:00
Gary Guo
e0b69f207b Hide &mut self methods from Deref in sidebar
If there are no `DerefMut` impl for the type.
2020-07-06 20:32:26 +01:00
Thiago Arrais
3065201eb3 Includes TODO for constants equivalent to π/180 2020-07-06 13:45:43 -03:00
Thiago Arrais
6be9491eac Reclassify powi(2) lint under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
6dc066fdb9 Includes TODO comment for hypot lint 2020-07-06 13:45:43 -03:00
Thiago Arrais
db7bc6b3bd Place radian lints under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
f5596826fa Better copy for lint message
Since x.log(y) is actually implemented as x.ln() / y.ln()
2020-07-06 13:45:43 -03:00
Thiago Arrais
076ec872ce Lint for to_radians and to_degrees 2020-07-06 13:45:39 -03:00
robojumper
1740dda763 fix match_like_matches_macro in clippy 2020-07-06 18:35:58 +02:00
Thiago Arrais
0c8afa39ce Lint x.log(b) / y.log(b) => x.log(y) 2020-07-06 13:32:31 -03:00
robojumper
2e8a1be444 new lint: match_like_matches_macro 2020-07-06 18:25:20 +02:00
Thiago Arrais
f62798454c Lint (x * x + y * y).sqrt() => x.hypot(y) 2020-07-06 13:23:17 -03:00
Thiago Arrais
a6f1af75d7 Lint for x.powi(2) => x * x 2020-07-06 13:23:17 -03:00
bors
ac856922f8 Auto merge of #5301 - JarredAllen:option_if_let_else, r=flip1995
Suggest `Option::map_or`(_else) for `if let Some { y } else { x }`

Fixes #5203

There are two issues with this code that I have noticed:

- Use of `Option::map_or` causes it to always evaluate the code in the else block. If that block is computationally expensive or if it updates some state (such as getting the next value from an iterator), then this change would cause the code to behave differently. In either of those circumstances, it should suggest Option::map_or_else, which takes both cases as a closure and runs one. However, I don't know how to check if the expression would change some state, so I left the lint's applicability as MaybeIncorrect.

- There are lints which can trigger on specific sub-cases of this lint (`if_let_some_result`, `question_mark`, and `while_let_loop`) and suggest different changes (usually better ones because they're more specific). Is this acceptable for clippy to give multiple suggestions, or should I have the code check if those other lints trigger and then not trigger this lint if they do?

changelog: Add lint [`option_if_let_else`]
2020-07-06 15:56:52 +00:00
Jon Gjengset
8872ec3760
fixups 2020-07-06 11:52:20 -04:00
Seth Pellegrino
ee3a0f867e Add guard to check for local core crate 2020-07-06 08:46:44 -07:00
Thom Chiovoloni
a150dcc872 Remove pointless black_box call, add a comment about the unaligned_ benches, and clean up stray semicolon 2020-07-06 07:43:38 -07:00
Jon Gjengset
7fb26938b1
Add VecDeque::range* methods
This patch adds `VecDeque::range` and `VecDeque::range_mut` to provide
iterators over a sub-range of a `VecDeque`. This behavior can be
emulated with `skip` and `take`, but directly providing a `Range` is
more ergonomic. This also partially makes up for `VecDeque`'s lack of
`SliceIndex` support.
2020-07-06 10:35:33 -04:00
Aleksey Kladov
fdd39a343e Add rust-analyzer to the build manifest 2020-07-06 11:13:27 +02:00
Joshua Nelson
e46c18768e Always resolve type@primitive as a primitive, not a module
Previously, if there were a module in scope with the same name as the
primitive, that would take precedence. Coupled with
https://github.com/rust-lang/rust/issues/58699, this made it impossible
to link to the primitive when that module was in scope.

This approach could be extended so that `struct@foo` would no longer resolve
to any type, etc. However, it could not be used for glob imports:

```rust
pub mod foo {
  pub struct Bar;
}

pub enum Bar {}
use foo::*;

// This is expected to link to `inner::Bar`, but instead it will link to the enum.
/// Link to [struct@Bar]
pub struct MyDocs;
```

The reason for this is that this change does not affect the resolution
algorithm of rustc_resolve at all. The only reason we could special-case
primitives is because we have a list of all possible primitives ahead of time.
2020-07-05 21:40:02 -04:00
Seth Pellegrino
81fbfc4059 Use relative path for local links to primitives in libcore
Else, links to `char::foo` would point into `/path/to/src/libcore/std/primitive.char.html#method.foo`.

Split out from #73804.
2020-07-05 17:22:21 -07:00
bors
0c03aee8b8 Auto merge of #74073 - Manishearth:rollup-faqo9lx, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #72688 (added .collect() into String from Box<str>)
 - #73787 (Add unstable docs for rustc_attrs)
 - #73834 (Some refactoring around intrinsic type checking)
 - #73871 (Fix try_print_visible_def_path for Rust 2018)
 - #73937 (Explain exhaustive matching on {usize,isize} maximum values)
 - #73973 (Use `Span`s to identify unreachable subpatterns in or-patterns)
 - #74000 (add `lazy_normalization_consts` feature gate)
 - #74025 (Remove unnecessary release from Arc::try_unwrap)
 - #74027 (Convert more `DefId`s to `LocalDefId`s)
 - #74055 (Fix spacing in Iterator fold doc)
 - #74057 (expected_found `&T` -> `T`)
 - #74064 (variant_count: avoid incorrect dummy implementation)

Failed merges:

r? @ghost
2020-07-05 23:08:08 +00:00
Manish Goregaokar
e62436333e
Rollup merge of #74064 - RalfJung:variant-count-bootstrap, r=kennytm
variant_count: avoid incorrect dummy implementation

This also avoids a stage 0 doctest failure.
2020-07-05 16:07:39 -07:00
Manish Goregaokar
b4710bde3d
Rollup merge of #74057 - lcnr:expected_found, r=davidtwco
expected_found `&T` -> `T`
2020-07-05 16:07:37 -07:00
Manish Goregaokar
4591b0f40c
Rollup merge of #74055 - pickfire:patch-1, r=jonas-schievink
Fix spacing in Iterator fold doc
2020-07-05 16:07:35 -07:00
Manish Goregaokar
a1c076fa75
Rollup merge of #74027 - lcnr:ConstCx-local-def-id, r=varkor
Convert more `DefId`s to `LocalDefId`s
2020-07-05 16:07:34 -07:00
Manish Goregaokar
aef2ca6681
Rollup merge of #74025 - tmiasko:try-unwrap, r=Amanieu
Remove unnecessary release from Arc::try_unwrap

The thread that recovers the unique access to Arc inner value (e.g., drop
when ref-count strong reaches zero, successful try_unwrap), ensures that
other operations on Arc inner value happened before by synchronizing
with release operations performed when decrementing the reference counter.

When try_unwrap succeeds, the current thread recovers the unique access
to Arc inner value, so release is unnecessary.

r? @Amanieu
2020-07-05 16:07:32 -07:00
Manish Goregaokar
0eadeda945
Rollup merge of #74000 - lcnr:lazy_normalisation_consts, r=varkor
add `lazy_normalization_consts` feature gate

In #71973 I underestimated the amount of code which is influenced by lazy normalization of consts
and decided against having a separate feature flag for this.

Looking a bit more into this, the following issues are already working with lazy norm in its current state #47814 #57739 #73980

I therefore think it is worth it to enable lazy norm separately. Note that `#![feature(const_generics)]` still automatically activates
this feature, so using `#![feature(const_generics, lazy_normalization_consts)]` is redundant.

r? @varkor @nikomatsakis
2020-07-05 16:07:30 -07:00
Manish Goregaokar
e450646e97
Rollup merge of #73973 - Nadrieril:fix-71977, r=matthewjasper
Use `Span`s to identify unreachable subpatterns in or-patterns

Fixes #71977
2020-07-05 16:07:28 -07:00
Manish Goregaokar
a1ac4d66d3
Rollup merge of #73937 - JohnTitor:note-exhaustive-sized-int, r=varkor
Explain exhaustive matching on {usize,isize} maximum values

The wording is taken from https://github.com/rust-lang/rfcs/blob/master/text/2591-exhaustive-integer-pattern-matching.md#reference-level-explanation.
Fixes #73919

r? @varkor
2020-07-05 16:07:27 -07:00
Manish Goregaokar
3e78eac206
Rollup merge of #73871 - da-x:private-types-2018-no-extern, r=petrochenkov
Fix try_print_visible_def_path for Rust 2018

The recursive check of `try_print_visible_def_path` did not properly handle the Rust 2018 case of crate-paths without 'extern crate'. Instead, it returned a "not found" via (false, self).

 This fixes #56175.
2020-07-05 16:07:25 -07:00
Manish Goregaokar
fed20132a6
Rollup merge of #73834 - oli-obk:safe_intrinsics, r=ecstatic-morse
Some refactoring around intrinsic type checking

So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
2020-07-05 16:07:23 -07:00
Manish Goregaokar
e2ae88d4a6
Rollup merge of #73787 - pickfire:rustc-attrs, r=RalfJung
Add unstable docs for rustc_attrs

r? @RalfJung
2020-07-05 16:07:21 -07:00
Manish Goregaokar
5311daa136
Rollup merge of #72688 - djugei:master, r=Amanieu
added .collect() into String from Box<str>

I have not created an rfc, because i felt like this is a very minor change.

i have just set a random feature name and rust version as stability attribute, i expect to have to change that, i just don't know what the policy on that is. all guides i could find focused on contributing to the compiler, not contributing to the standard library.

drawbacks: more code in the standard library, could be replaced with specialization: base-implementation for AsRef\<str> and specialization for String and Cow. i can write that code if ppl want it.

advantages: using "real strings" i.e. Box\<str> is as ergonomic as string slices (&str) and string buffers (String) with iterators.
2020-07-05 16:07:19 -07:00
Dan Gohman
6196eaa0b1 Fix the return type of Windows' OpenOptionsExt::security_qos_flags.
This adjusts the return type of Windows' `OpenOptionsExt::security_qos_flags`
to be consistent with the other functions in the trait.
2020-07-05 16:04:27 -07:00
Thom Chiovoloni
dc4a644980 Add 'unrolled' is_ascii_align_to benchmark, and move is_ascii benchmarks into own file 2020-07-05 15:52:13 -07:00
Tomasz Miąsko
5fa19ad2bb Remove unused RUSTC_DEBUG_ASSERTIONS
Since #73374 the rustc wrapper no longer configures debug assertions
based on RUSTC_DEBUG_ASSERTIONS environment variable.
2020-07-06 00:16:12 +02:00