Commit Graph

218429 Commits

Author SHA1 Message Date
Oli Scherer
60b0da1541 Test rustdoc encountering proc_macro_derive in a non-proc-macro crate 2023-02-23 09:00:33 +00:00
Scott McMurray
5c7ae251b1 Require literals for some (u)int_impl! parameters
The point of these is to be seen lexically in the docs, so they should always be passed as the correct literal, not as an expression.

(Otherwise we could just compute `Min`/`Max` from `BITS`, for example.)
2023-02-22 23:26:22 -08:00
bors
eb909d8146 Auto merge of #108386 - matthiaskrgr:rollup-nojivk9, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108063 (Ban associated type bounds in bad positions)
 - #108208 (Correctly handle aggregates in DataflowConstProp)
 - #108218 (Windows: Quote more batch file arguments)
 - #108349 (rustdoc: Prevent duplicated imports)
 - #108350 (Use associated type bounds in some places in the compiler)
 - #108358 (Add git config command to `.git-blame-ignore-revs`)
 - #108373 (hir-analysis: make where-clause-on-main diagnostic translatable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-23 06:28:41 +00:00
Matthias Krüger
60014e4848
Rollup merge of #108373 - tshepang:where-clause-on-main, r=compiler-errors
hir-analysis: make where-clause-on-main diagnostic translatable
2023-02-23 06:18:08 +01:00
Matthias Krüger
f4fa0458a9
Rollup merge of #108358 - Nilstrieb:git-blame-ignore-my-bad-commits, r=compiler-errors
Add git config command to `.git-blame-ignore-revs`

I always have to look at the git blame for that file to find the git command in the commit message (luckily that commit isn't in the file :D), putting it directly in the file makes it easier to find. Maybe we should mention the config in some other place as well.
2023-02-23 06:18:08 +01:00
Matthias Krüger
d6077f895a
Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obk
Use associated type bounds in some places in the compiler

Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think?

Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-23 06:18:07 +01:00
Matthias Krüger
2011ced333
Rollup merge of #108349 - GuillaumeGomez:fix-duplicated-imports2, r=notriddle
rustdoc: Prevent duplicated imports

Fixes #108163.

Interestingly enough, the AST is providing us an import for each corresponding item, even though the `Res` links to multiple ones each time, which leaded to the same import being duplicated.

So in this PR, I decided to prevent the add of the import before the clean pass. However, I originally took a different path by instead filtering after cleaning the path. You can see it [here](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rust:fix-duplicated-imports?expand=1). Only the second commit differs.

I think this approach is better though, but at least we can compare both if we want.

The first commit adds the check for duplicated items in the rustdoc-json output as asked in #108163.

cc `@aDotInTheVoid`
r? `@notriddle`
2023-02-23 06:18:07 +01:00
Matthias Krüger
c4a4bce695
Rollup merge of #108218 - ChrisDenton:cmd-escape, r=cuviper
Windows: Quote more batch file arguments

Make sure to always quote batch file arguments that contain command prompt special characters.

Additionally add `/d` command line parameter to disable any autorun scripts that may change the way variable expansion works. This makes it more consistent across systems and may help avoid surprises.

## Background Info

[`CreateProcess`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw) with the `lpApplicationName` set can only be used to run `.exe` files and not script files such as `.bat`. However, for historical reasons, we do have special handling so that `.bat` files will be correctly run with `cmd.exe` as the application.

In Windows, command line arguments are passed as a single string (not an array). Applications can parse this string however they like but most follow the standard MSVC C/C++ convention. But `cmd.exe` uses different argument parsing rules to other Windows programs (because it emulates old DOS).  This PR aims to help smooth over some of the differences.

r? libs
2023-02-23 06:18:06 +01:00
Matthias Krüger
a423fa7b46
Rollup merge of #108208 - cjgillot:flood-enum, r=oli-obk
Correctly handle aggregates in DataflowConstProp

The previous implementation from https://github.com/rust-lang/rust/pull/107411 flooded target of an aggregate assignment with `Bottom`, corresponding to the `deinit` that the interpreter does.

As a consequence, when assigning `target = Enum::Variant#i(...)` all the `(target as Variant#j)` were at `Bottom` while they should have been `Top`.

This PR replaces that flooding with `Top`.

Aside, it corrects a second bug where the wrong place would be used to assign to enum variant fields, resulting to nothing happening.

Fixes https://github.com/rust-lang/rust/issues/108166
2023-02-23 06:18:06 +01:00
Matthias Krüger
ef27e43807
Rollup merge of #108063 - compiler-errors:associated-type-bounds-in-bad-position, r=cjgillot
Ban associated type bounds in bad positions

We should not try to lower associated type bounds into TAITs in positions where `impl Trait` is not allowed (except for in `where` clauses, like `where T: Trait<Assoc: Bound>`).

This is achieved by using the same `rustc_ast_lowering` machinery as impl-trait does to characterize positions as universal/existential/disallowed.

Fixes #106077

Split out the first commit into #108066, since it's not really related.
2023-02-23 06:18:05 +01:00
Michael Howell
49d995a4cf rustdoc: reduce allocations when generating tooltips
An attempt to reduce the perf regression in
https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-22 21:00:10 -07:00
bors
8b1dbf728a Auto merge of #108330 - weihanglo:update-cargo, r=weihanglo
Update cargo

15 commits in 17b3d0de0897e1c6b8ca347bd39f850bb0a5b9f6..9d5b32f503fc099c4064298465add14d4bce11e6
2023-02-17 19:45:09 +0000 to 2023-02-22 23:04:16 +0000

- refactor(job_queue): docs and move types around (rust-lang/cargo#11758)
- Scrub more of the test environment (rust-lang/cargo#11757)
- Make more reads of environment variables go through the `Config` (rust-lang/cargo#11754)
- Revert "Update curl-sys to use libcurl 7.88.1" (rust-lang/cargo#11755)
- use consistent case (rust-lang/cargo#11748)
- Switch some tests from `build` to `check` (rust-lang/cargo#11725)
- Fix typo in sparse-registry warning message (rust-lang/cargo#11753)
- reuse url encoding from `url` crate, don't use separate `percent-encoding` (rust-lang/cargo#11750)
- Read environment variables through `Config` instead of `std::env::var(_os)` (rust-lang/cargo#11727)
- Update curl-sys to use libcurl 7.88.1 (rust-lang/cargo#11749)
- mdman: update pretty_assertions to reduce deps (rust-lang/cargo#11747)
- Cleanup tests (rust-lang/cargo#11745)
- Enhance help texts of position args (rust-lang/cargo#11740)
- Fix typo (rust-lang/cargo#11741)
- Update comment about cargo-ok (rust-lang/cargo#11724)
2023-02-23 03:11:43 +00:00
Michael Goulet
9bf32c40b4 Don't project specializable RPITIT projection 2023-02-23 02:12:51 +00:00
Michael Goulet
02b3664766 Drive-by assertion in collect_return_position_impl_trait_in_trait_tys 2023-02-23 02:12:51 +00:00
mejrs
4c13a2157a Add stderr 2023-02-23 02:05:03 +01:00
Weihang Lo
80bea6cfce
Update cargo
15 commits in 17b3d0de0897e1c6b8ca347bd39f850bb0a5b9f6..9d5b32f503fc099c4064298465add14d4bce11e6
2023-02-17 19:45:09 +0000 to 2023-02-22 23:04:16 +0000

- refactor(job_queue): docs and move types around (rust-lang/cargo#11758)
- Scrub more of the test environment (rust-lang/cargo#11757)
- Make more reads of environment variables go through the `Config` (rust-lang/cargo#11754)
- Revert "Update curl-sys to use libcurl 7.88.1" (rust-lang/cargo#11755)
- use consistent case (rust-lang/cargo#11748)
- Switch some tests from `build` to `check` (rust-lang/cargo#11725)
- Fix typo in sparse-registry warning message (rust-lang/cargo#11753)
- reuse url encoding from `url` crate, don't use separate `percent-encoding` (rust-lang/cargo#11750)
- Read environment variables through `Config` instead of `std::env::var(_os)` (rust-lang/cargo#11727)
- Update curl-sys to use libcurl 7.88.1 (rust-lang/cargo#11749)
- mdman: update pretty_assertions to reduce deps (rust-lang/cargo#11747)
- Cleanup tests (rust-lang/cargo#11745)
- Enhance help texts of position args (rust-lang/cargo#11740)
- Fix typo (rust-lang/cargo#11741)
- Update comment about cargo-ok (rust-lang/cargo#11724)
2023-02-23 00:59:21 +00:00
bors
daa94d2583 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
bors
0978711950 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
mejrs
634d8cb757 Test that choosing the default bundle does not ice 2023-02-23 01:14:10 +01:00
mejrs
242daf86d9 Handle selecting the default locale better 2023-02-23 01:14:10 +01:00
mejrs
6f92031233 Restore behavior when primary bundle is missing 2023-02-23 01:14:10 +01:00
Tshepang Mbambo
ada4e9468e hir-analysis: make where-clause-on-main diagnostic translatable 2023-02-23 01:50:38 +02:00
Boqun Feng
b54a5fdca0 std: time: Avoid to use "was created" in elapsed() description
".. since this instant was created" is inaccurate and misleading,
consider the following case:

	let i1 = Instant::now(); // i1 is created at T1
	let i2 = i1 + Duration::from_nanos(0); // i2 is "created" at T2
	i2.elapsed(); // at T3

Per the current description, `elapsed()` at T3 should return T3 - T2?

Therefore removes the "was created" in the description of
{Instant,SystemTime}::elapsed(). And since these types represent times,
it's OK to use prepostions with them, e.g. "since this instant".
2023-02-22 14:40:43 -08:00
Michael Goulet
298ae8c721 Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_misc 2023-02-22 22:23:45 +00:00
Michael Goulet
1e7ef03b40 Use ty_error_with_guaranteed in many more places 2023-02-22 22:23:16 +00:00
blyxyas
e39fe374df Add check for invalid \#[macro_export]\ arguments 2023-02-22 21:53:16 +00:00
Michael Goulet
b14eb0c497 pluralize stuff 2023-02-22 21:52:26 +00:00
Michael Goulet
deb135748d Suppress duplicated errors for associated type bounds in object types 2023-02-22 21:52:26 +00:00
bors
da439d9874 Auto merge of #108357 - matthiaskrgr:rollup-ceo3q2s, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #107736 ( Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) )
 - #108176 (Don't delay `ReError` bug during lexical region resolve)
 - #108315 (Lint dead code in closures and generators)
 - #108342 (apply query response: actually define opaque types)
 - #108344 (Fix test filename for #105700)
 - #108353 (resolve: Remove `ImportResolver`)

Failed merges:

 - #107911 (Add check for invalid #[macro_export] arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-22 21:24:29 +00:00
Camille GILLOT
f38f3af22a Remove some resolver outputs. 2023-02-22 20:48:39 +00:00
Camille GILLOT
958419d354 Move the unused extern crate check back to the resolver. 2023-02-22 20:48:27 +00:00
Michael Goulet
e7c490892f Move associated type bounds check to ast lowering
This makes the check for when associated type bounds more accurate
2023-02-22 20:18:14 +00:00
Oli Scherer
5965948ba1 Remove a back compat warning 2023-02-22 19:39:03 +00:00
Nilstrieb
96ebb21b4a Add git config command to .git-blame-ignore-revs
I always have to look at the git blame for that file to find the git
command in the commit message (luckily that commit isn't in the file
:D), putting it directly in the file makes it easier to find. Maybe we
should mention the config in some other place as well.
2023-02-22 19:29:27 +00:00
Matthias Krüger
9f5c401f67
Rollup merge of #108353 - petrochenkov:rmir, r=cjgillot
resolve: Remove `ImportResolver`

It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22 20:06:00 +01:00
Matthias Krüger
baf6a72155
Rollup merge of #108344 - Alexendoo:test-105700, r=compiler-errors
Fix test filename for #105700

The test is for #105700 rather than #21102
2023-02-22 20:05:59 +01:00
Matthias Krüger
2ad6a39fea
Rollup merge of #108342 - lcnr:opaque-tys, r=oli-obk
apply query response: actually define opaque types

not sure whether this fixes any code considering that #107891 doesn't break anything, but this is currently wrong as the `eq` there should just always fail right now.

We can definitely hit this code if we remove the `replace_opaque_types_with_inference_vars` hack. Doing so without this PR causes a few tests to ICE, e.g.

bd4a96a12d/tests/ui/impl-trait/issue-99642.rs (L1-L7)

r? `@oli-obk`
2023-02-22 20:05:59 +01:00
Matthias Krüger
783617b5e4
Rollup merge of #108315 - clubby789:dead-code-in-closure, r=compiler-errors
Lint dead code in closures and generators

Fixes #108296

I think this might be a potentially breaking change, but restores the behaviour of pre-1.64.

`@rustbot` label +A-lint
2023-02-22 20:05:58 +01:00
Matthias Krüger
4d9effc65c
Rollup merge of #108176 - compiler-errors:bad-lexical-region-resolve-bug, r=oli-obk
Don't delay `ReError` bug during lexical region resolve

Lexical region resolution returns a list of `RegionResolutionError` which don't necessarily correspond to diagnostics being emitted. The compiler may, validly, throw away these resolution errors and do something else. Therefore it's not valid to use `ReError` during lifetime resolution, since we may actually be on a totally fine compilation path.

For example, the `implied_bounds_entailment` lint runs region resolution twice, and only emits an error if it fails both times. If we delay a bug and create a `ReError` during this first run, then we will ICE.

Fixes #108170

----

Side-note: this is conceptually equivalent to how we can't necessarily delay bugs or create `ty::Error` during trait solving/fulfillment, since the compiler is allowed to throw away these fulfillment errors to do other things. It's only once we actually emit an error (`report_region_errors` / `report_fulfillment_errors`)
2023-02-22 20:05:58 +01:00
Matthias Krüger
0982eab839
Rollup merge of #107736 - tgross35:atomic-as-ptr, r=m-ou-se
Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893)

Originally discussed in https://github.com/rust-lang/rust/issues/66893#issuecomment-1419198623

~~This uses #107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased

`@rustbot` label +T-libs-api
r? m-ou-se
2023-02-22 20:05:57 +01:00
Jeremy Fitzhardinge
fde2e40e43 link-directives: clarify usage message 2023-02-22 10:34:51 -08:00
bors
95cd5284d4 Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases

#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate.  As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value.

Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream).

This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope.  These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c62.

Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit.  Let me know if you'd like it broken up.

r? `@oli-obk`
2023-02-22 18:26:51 +00:00
bors
fdbc4329cb Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases

#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate.  As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value.

Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream).

This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope.  These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c62.

Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit.  Let me know if you'd like it broken up.

r? `@oli-obk`
2023-02-22 18:26:51 +00:00
Jeremy Fitzhardinge
fc5db2cd4f Implement -Zlink-directives=yes/no
`-Zlink-directives=no` will ignored `#[link]` directives while compiling a
crate, so nothing is emitted into the crate's metadata.  The assumption is
that the build system already knows about the crate's native dependencies
and can provide them at link time without these directives.

This is another way to address issue # #70093, which is currently addressed
by `-Zlink-native-libraries` (implemented in #70095). The latter is
implemented at link time, which has the effect of ignoring `#[link]`
in *every* crate. This makes it a very large hammer as it requires all
native dependencies to be known to the build system to be at all usable,
including those in sysroot libraries. I think this means its effectively
unused, and definitely under-used.

Being able to control this on a crate-by-crate basis should make it much
easier to apply when needed.

I'm not sure if we need both mechanisms, but we can decide that later.
2023-02-22 10:18:01 -08:00
Vadim Petrochenkov
d275114bda resolve: Remove ImportResolver
It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22 21:29:38 +04:00
Alan Egerton
a9b2354a1d
Normalize line+col in normalize-tait-in-const test 2023-02-22 17:05:04 +00:00
Alan Egerton
430c4ab7ff Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
Alan Egerton
695072daa6
Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
Guillaume Gomez
20dd1bd9a8 Add test to ensure there are no duplicated imports 2023-02-22 17:49:22 +01:00
Guillaume Gomez
4aa142ee2d Prevent duplicated imports 2023-02-22 17:49:06 +01:00