Commit Graph

22672 Commits

Author SHA1 Message Date
Matthias Krüger
9c38ae5653
Rollup merge of #108542 - bwmf2:expanded, r=wesleywiser
Force parentheses around `match` expression in binary expression

This attempts to solve https://github.com/rust-lang/rust/issues/98790.
2023-03-11 15:43:13 +01:00
Matthias Krüger
244ec84a82
Rollup merge of #108071 - compiler-errors:new-solver-caching, r=lcnr
Implement goal caching with the new solver

Maybe it's wrong, idk. Opening mostly for first impressions before I go to sleep.

r? ``@lcnr,`` cc ``@cjgillot``
2023-03-11 15:43:13 +01:00
Matthias Krüger
d47d4ad4b2
Rollup merge of #106844 - Ezrashaw:concat-negative-int-lit, r=dtolnay
allow negative numeric literals in `concat!`

Fixes #106837

While *technically* negative numeric literals are implemented as unary operations, users can reasonably expect that negative literals are treated the same as positive literals.
2023-03-11 15:43:12 +01:00
Matthias Krüger
fbc121fdfd
Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=Nilstrieb
Make `unused_allocation` lint against `Box::new` too

Previously it only linted against `box` syntax, which likely won't ever be stabilized, which is pretty useless. Even now I'm not sure if it's a meaningful lint, but it's at least something 🤷

This means that code like the following will be linted against:
```rust
Box::new([1, 2, 3]).len();
f(&Box::new(1)); // where f : &i32 -> ()
```
The lint works by checking if a `Box::new` (or `box`) expression has an a borrow adjustment, meaning that the code that first stores the box in a variable won't be linted against:
```rust
let boxed = Box::new([1, 2, 3]); // no lint
boxed.len();
```
2023-03-11 15:43:11 +01:00
bors
e350fe4e60 Auto merge of #109001 - matthiaskrgr:rollup-a3agnwp, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #105798 (Relax ordering rules for `asm!` operands)
 - #105962 (Stabilize path_as_mut_os_str)
 - #106085 (use problem matchers for tidy CI)
 - #107711 (Stabilize movbe target feature)
 - #108017 (Add `--no-undefined-version` link flag and fix associated breakage)
 - #108891 (Remove an extraneous include)
 - #108902 (no more do while :<)
 - #108912 (Document tool lints)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-11 07:28:44 +00:00
bors
19c53768af Auto merge of #108998 - matthiaskrgr:rollup-sxbdulg, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #106921 (Add documentation about the memory layout of `Cell`)
 - #108828 (Emit alias-eq when equating numeric var and projection)
 - #108834 (Do not ICE when we have fn pointer `Fn` obligations with bound vars in the self type)
 - #108900 (fix(lexer): print whitespace warning for \x0c)
 - #108930 (feat: implement better error for manual impl of `Fn*` traits)
 - #108937 (improve readability of winnowing)
 - #108947 (Don't even try to combine consts with incompatible types)
 - #108976 (Update triagebot rust-analyzer team mention)
 - #108983 (Forbid `#[target_feature]` on safe default implementations)

Failed merges:

 - #108950 (Directly construct Inherited in typeck.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-11 04:17:59 +00:00
bors
6dfaa14366 Auto merge of #104527 - ferrocene:pa-more-licenses, r=pnkfelix
Add more license annotations

This PR updates the `.reuse/dep5` file to include more accurate licensing data for everything in the repository (*excluding* submodules and dependencies). Some decisions were made in this PR:

* The standard copyright attribution for files maintained by us is "The Rust Project Developers (see https://thanks.rust-lang.org)", to avoid having to maintain an in-tree `AUTHORS` file.
* For files that have specific licensing terms, we added the terms to the `.reuse/dep5` rather than adding SPDX comments in the files themselves.
* REUSE picks up any comment/text line with `Copyright` on it, so I had to sprinkle around `REUSE-IgnoreStart` and `REUSE-IgnoreEnd` comments.

The rendered `COPYRIGHT` file is available at https://gist.github.com/pietroalbini/efb81103f69596d39758114f3f6a8688.

r? `@pnkfelix`
2023-03-11 01:17:23 +00:00
Michael Goulet
d21e4d8411 Actually cache goals 2023-03-10 23:49:42 +00:00
Michael Goulet
67698aa6ad Move some solver stuff to middle 2023-03-10 23:46:38 +00:00
Matthias Krüger
030ea0578f
Rollup merge of #108912 - clubby789:doc-tool-lints, r=Nilstrieb
Document tool lints

Add brief doc comments for the internal tool lints so a summary can be seen without needing to open source code
2023-03-10 21:15:46 +01:00
Matthias Krüger
5e449b32b5
Rollup merge of #108902 - lcnr:do-while-sus, r=davidtwco,Nilstrieb
no more do while :<
2023-03-10 21:15:46 +01:00
Matthias Krüger
4b784e49a2
Rollup merge of #108891 - kazutakahirata:master, r=cuviper
Remove an extraneous include

SymbolWrapper.cpp doesn't use std::optional or llvm::Optional, so this patch removes the extraneous include.  Note that llvm/ADT/Optional.h has been deprecated upstream.  This patch ensures that SymbolWrapper.cpp continues to compile even after the upcoming removal of Optional.h.
2023-03-10 21:15:45 +01:00
Matthias Krüger
342ca46517
Rollup merge of #108017 - chbaker0:fix-105967, r=chbaker0
Add `--no-undefined-version` link flag and fix associated breakage

LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402.

Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See https://github.com/rust-lang/rust/issues/105967#issuecomment-1428671533 for details.

This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated.

Fixes #105967
2023-03-10 21:15:45 +01:00
Matthias Krüger
93316d7f28
Rollup merge of #107711 - calebzulawski:movbe, r=pnkfelix
Stabilize movbe target feature

Almost all "old" x86 target features are stable.  As far as I can tell, these are the last two unstable features in the `x86-64-v2` or `x86-64-v3` microarchitecture levels, so I'm not sure if it was an oversight or if they're still unstable for a reason (see #106323 for `f16c`).

Note that this only stabilizes the target features, and not the intrinsics.

cc ```@Amanieu```

r? ```@rust-lang/lang```
2023-03-10 21:15:44 +01:00
Matthias Krüger
cb0fb246d5
Rollup merge of #105798 - Amanieu:relax-asm, r=joshtriplett
Relax ordering rules for `asm!` operands

The `asm!` and `global_asm!` macros require their operands to appear strictly in the following order:
- Template strings
- Positional operands
- Named operands
- Explicit register operands
- `clobber_abi`
- `options`

This is overly strict and can be inconvienent when building complex `asm!` statements with macros. This PR relaxes the ordering requirements as follows:
- Template strings must still come before all other operands.
- Positional operands must still come before named and explicit register operands.
- Named and explicit register operands can be freely mixed.
- `options` and `clobber_abi` can appear in any position after the template strings.

r? ```````@joshtriplett```````
2023-03-10 21:15:42 +01:00
Matthias Krüger
f74bb35dad
Rollup merge of #108983 - LeSeulArtichaut:108646-target-feature-default-impl, r=cjgillot
Forbid `#[target_feature]` on safe default implementations

Fixes #108646.
2023-03-10 19:59:21 +01:00
Matthias Krüger
145e6204bc
Rollup merge of #108947 - compiler-errors:ct-infer-no-shapeshifting, r=BoxyUwU
Don't even try to combine consts with incompatible types

~I left a more detailed explanation for why this fixes this issue in the UI test, but in general, we should not try to unify const infer vars and rigid consts if they have incompatible types. That's because we don't want something like a `ConstArgHasType` predicate to suddenly go from passing to failing, or vice versa, due to a shallow resolve.~

1. Use the `type_of` for a parameter in `try_eval_lit_or_param`, instead of the "expected" type from a `WithOptConstParam` def id.
2. Don't combine consts that have incompatible types.

Fixes #108781
2023-03-10 19:59:20 +01:00
Matthias Krüger
772b1ce745
Rollup merge of #108937 - lcnr:winnowing-enum, r=WaffleLapkin
improve readability of winnowing
2023-03-10 19:59:20 +01:00
Matthias Krüger
76994625f8
Rollup merge of #108930 - Ezrashaw:better-error-for-manual-fn-impl, r=petrochenkov
feat: implement better error for manual impl of `Fn*` traits

Fixes #39259

cc `@estebank` (you gave me some advice in the linked issue, would you like to review?)
2023-03-10 19:59:19 +01:00
Matthias Krüger
4ad32304c7
Rollup merge of #108900 - bvanjoi:issue-108275, r=petrochenkov
fix(lexer): print whitespace warning for \x0c

- close https://github.com/rust-lang/rust/issues/108275
- discussion: https://github.com/rust-lang/rust/pull/108403
2023-03-10 19:59:19 +01:00
Matthias Krüger
bee84733ad
Rollup merge of #108834 - compiler-errors:fn-ptr-fn-obl, r=spastorino
Do not ICE when we have fn pointer `Fn` obligations with bound vars in the self type

We never supported solving `for<'a> fn(&'a ()): Fn(&'a ())` -- I tried to add that support in #104929, but iirc `@lcnr` wanted to support this more generally by eagerly instantiating trait predicate binders with placeholders. That never happened due to blockers in the old solver, but we probably shouldn't ICE in any case.

On the bright side, this passes on the new solver :^)
2023-03-10 19:59:18 +01:00
Matthias Krüger
233ed35e84
Rollup merge of #108828 - compiler-errors:new-solver-alias-eq-on-num-var, r=lcnr
Emit alias-eq when equating numeric var and projection

This doesn't fix everything having to do with projections and infer vars, but it does fix a common case I saw in HIR typeck.

r? `@lcnr`
2023-03-10 19:59:18 +01:00
bors
35a0961bbc Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108879 (Unconstrained terms should account for infer vars being equated)
 - #108936 (Rustdoc: don't hide anonymous reexport)
 - #108940 (Add myself to compiler reviewers list)
 - #108945 (Make some report and emit errors take DefIds instead of BodyIds)
 - #108946 (Document the resulting values produced when using `From<bool>` on floats)
 - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.)
 - #108960 (Remove `body_def_id` from `Inherited`)
 - #108963 (only call git on git checkouts during bootstrap)
 - #108964 (Fix the docs for pointer method with_metadata_of)

Failed merges:

 - #108950 (Directly construct Inherited in typeck.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-10 15:39:25 +00:00
Léo Lanteri Thauvin
ad2bcb5c0e Forbid #[target_feature] on safe default implementations 2023-03-10 13:50:51 +01:00
bors
d5833423a0 Auto merge of #102256 - cjgillot:let-under, r=lcnr
Introduce a no-op `PlaceMention` statement for `let _ =`.

Fixes https://github.com/rust-lang/rust/issues/54003
Fixes https://github.com/rust-lang/rust/issues/80059
Split from https://github.com/rust-lang/rust/pull/101500

This PR introduces a new `PlaceMention` statement dedicated to matches that neither introduce bindings nor ascribe types.  Without this, all traces of the match would vanish from MIR, making it impossible to diagnose unsafety or use in #101500.

This allows to mark `let _ = <unsafe union access or dereference>` as requiring an unsafe block.
Nominating for lang team, as this introduces an extra error.
2023-03-10 11:55:59 +00:00
Matthias Krüger
671339cdb0
Rollup merge of #108960 - compiler-errors:no-body-def-id, r=cjgillot
Remove `body_def_id` from `Inherited`

We can just use the body id from the obligation cause.

Follow-up to #108945, only my commit is relevant.

r? `@cjgillot` cc `@spastorino`
2023-03-10 12:32:01 +01:00
Matthias Krüger
afd8558d62
Rollup merge of #108945 - spastorino:pass-def-id-instead-of-using-hir-id, r=compiler-errors
Make some report and emit errors take DefIds instead of BodyIds

Breaking off from #108915

r? `@compiler-errors`
2023-03-10 12:31:59 +01:00
Matthias Krüger
4bd32ac31d
Rollup merge of #108879 - compiler-errors:constrained-root-var, r=lcnr
Unconstrained terms should account for infer vars being equated

Follow-up from the canonicalization PR, wanted to break this one out so I can approve the other PR.

r? `@lcnr`
2023-03-10 12:31:58 +01:00
lcnr
14818e28d1
updating comment
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2023-03-10 10:49:05 +01:00
Ezra Shaw
a30c2c26c0
feat: implement better error for manual impl of Fn* traits 2023-03-10 20:32:24 +13:00
Michael Goulet
a8f905cdd9 Unconstrained terms should account for infer vars being equated 2023-03-10 04:08:09 +00:00
Collin Baker
cb41803899 Don't export of __rust_* alloc symbols if not codegened 2023-03-09 19:21:44 -05:00
Collin Baker
9bb87eb681 Add soon-to-be-default --no-undefined-version flag 2023-03-09 19:21:43 -05:00
Michael Goulet
fd34549686 Remove body_def_id from Inherited 2023-03-09 23:25:23 +00:00
Santiago Pastorino
5b99723439
Make some report and emit errors take DefIds instead of BodyIds 2023-03-09 17:53:35 -03:00
Michael Goulet
f7146136d7 Bail in combine if consts have different types 2023-03-09 20:52:06 +00:00
Michael Goulet
9574f39c2d Use param's real type in try_eval_lit_or_param 2023-03-09 20:49:11 +00:00
Camille GILLOT
09dc10c9c2 Bug on PlaceMention in dest-prop. 2023-03-09 17:45:13 +00:00
Camille GILLOT
45f2a1af3b Document borrowck behaviour. 2023-03-09 17:45:13 +00:00
Camille GILLOT
b34a8a294d Pacify tidy. 2023-03-09 17:45:13 +00:00
Camille GILLOT
e107194b66 Ignore AscribeUserType in unsafeck to avoid duplicate diagnostics. 2023-03-09 17:45:13 +00:00
Camille GILLOT
4462bb54e3 Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
Michael Goulet
d4b59a0da2 Propagate expected return type instead of real return type in check_binop 2023-03-09 17:24:07 +00:00
Michael Goulet
1b6d6f92d1 Fix canonicalizer bug for int/float vars too 2023-03-09 17:24:07 +00:00
Michael Goulet
3aea46979a Emit alias-eq when equating numeric var and projection 2023-03-09 16:42:56 +00:00
bohan
d223c26bce fix(lexer): not skipped whitespace warning for '\x0c' 2023-03-09 22:44:58 +08:00
clubby789
3abcae2beb Document tool lints 2023-03-09 14:07:20 +00:00
lcnr
3097453f21 improve readability of winnowing 2023-03-09 14:36:54 +01:00
lcnr
a5258d1721 no more do while 2023-03-09 12:53:03 +01:00
Pietro Albini
b33172a2df
replace legacy copyright annotations in submodules 2023-03-09 12:24:47 +01:00