Skip to content

Commit ff4df04

Browse files
committed
Auto merge of #71866 - Dylan-DPC:rollup-g9xqc8k, r=Dylan-DPC
Rollup of 4 pull requests Successful merges: - #71645 (Direct contributors to try stage 0 rustdoc first) - #71801 (Correctly check comparison operator in MIR typeck) - #71844 (List Clippy as a subtree, instead of a submodule) - #71864 (Update link in contributing.md) Failed merges: r? @ghost
2 parents a0c61a9 + 53702a6 commit ff4df04

File tree

4 files changed

+65
-52
lines changed

4 files changed

+65
-52
lines changed

CONTRIBUTING.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ it can be found [here][rctd].
193193
As a developer to this repository, you don't have to treat the following external projects
194194
differently from other crates that are directly in this repo:
195195

196-
* none so far, see https://github.com/rust-lang/rust/issues/70651 for more info
196+
* Clippy
197197

198198
They are just regular files and directories. This is in contrast to `submodule` dependencies
199199
(see below for those). Only tool authors will actually use any operations here.
@@ -247,15 +247,14 @@ git subtree add -P src/tools/clippy https://github.com/rust-lang/rust-clippy.git
247247
This will create a new commit, which you may not rebase under any circumstances! Delete the commit
248248
and redo the operation if you need to rebase.
249249

250-
Now you're done, the `src/tools/clippy` directory behaves as if clippy were part of the rustc
250+
Now you're done, the `src/tools/clippy` directory behaves as if Clippy were part of the rustc
251251
monorepo, so no one but you (or others that synchronize subtrees) actually needs to use `git subtree`.
252252

253253

254254
### External Dependencies (submodules)
255255

256256
Currently building Rust will also build the following external projects:
257257

258-
* [clippy](https://github.com/rust-lang/rust-clippy)
259258
* [miri](https://github.com/rust-lang/miri)
260259
* [rustfmt](https://github.com/rust-lang/rustfmt)
261260
* [rls](https://github.com/rust-lang/rls/)
@@ -393,10 +392,18 @@ You can find documentation style guidelines in [RFC 1574][rfc1574].
393392

394393
[rfc1574]: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
395394

396-
In many cases, you don't need a full `./x.py doc`. You can use `rustdoc` directly
397-
to check small fixes. For example, `rustdoc src/doc/reference.md` will render
398-
reference to `doc/reference.html`. The CSS might be messed up, but you can
399-
verify that the HTML is right.
395+
In many cases, you don't need a full `./x.py doc`, which will build the entire
396+
stage 2 compiler and compile the various books published on
397+
[doc.rust-lang.org]. When updating documentation for the standard library,
398+
first try `./x.py doc --stage 0 src/libstd`. If that fails, or if you need to
399+
see the output from the latest version of `rustdoc`, use `--stage 1` instead of
400+
`--stage 0`. Results should appear in `build/$TARGET/crate-docs`.
401+
402+
[doc.rust-lang.org]: htts://doc.rust-lang.org
403+
404+
You can also use `rustdoc` directly to check small fixes. For example,
405+
`rustdoc src/doc/reference.md` will render reference to `doc/reference.html`.
406+
The CSS might be messed up, but you can verify that the HTML is right.
400407

401408
Additionally, contributions to the [rustc-dev-guide] are always welcome. Contributions
402409
can be made directly at [the
@@ -511,7 +518,7 @@ are:
511518
* Don't be afraid to ask! The Rust community is friendly and helpful.
512519

513520
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
514-
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
521+
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/
515522
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
516523
[rif]: http://internals.rust-lang.org
517524
[rr]: https://doc.rust-lang.org/book/README.html

src/librustc_mir/borrow_check/type_check/mod.rs

+45-27
Original file line numberDiff line numberDiff line change
@@ -2290,36 +2290,54 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22902290
right,
22912291
) => {
22922292
let ty_left = left.ty(body, tcx);
2293-
if let ty::RawPtr(_) | ty::FnPtr(_) = ty_left.kind {
2294-
let ty_right = right.ty(body, tcx);
2295-
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
2296-
kind: TypeVariableOriginKind::MiscVariable,
2297-
span: body.source_info(location).span,
2298-
});
2299-
self.sub_types(
2300-
common_ty,
2301-
ty_left,
2302-
location.to_locations(),
2303-
ConstraintCategory::Boring,
2304-
)
2305-
.unwrap_or_else(|err| {
2306-
bug!("Could not equate type variable with {:?}: {:?}", ty_left, err)
2307-
});
2308-
if let Err(terr) = self.sub_types(
2309-
common_ty,
2310-
ty_right,
2311-
location.to_locations(),
2312-
ConstraintCategory::Boring,
2313-
) {
2314-
span_mirbug!(
2315-
self,
2316-
rvalue,
2317-
"unexpected comparison types {:?} and {:?} yields {:?}",
2293+
match ty_left.kind {
2294+
// Types with regions are comparable if they have a common super-type.
2295+
ty::RawPtr(_) | ty::FnPtr(_) => {
2296+
let ty_right = right.ty(body, tcx);
2297+
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
2298+
kind: TypeVariableOriginKind::MiscVariable,
2299+
span: body.source_info(location).span,
2300+
});
2301+
self.relate_types(
2302+
common_ty,
2303+
ty::Variance::Contravariant,
23182304
ty_left,
2319-
ty_right,
2320-
terr
2305+
location.to_locations(),
2306+
ConstraintCategory::Boring,
23212307
)
2308+
.unwrap_or_else(|err| {
2309+
bug!("Could not equate type variable with {:?}: {:?}", ty_left, err)
2310+
});
2311+
if let Err(terr) = self.relate_types(
2312+
common_ty,
2313+
ty::Variance::Contravariant,
2314+
ty_right,
2315+
location.to_locations(),
2316+
ConstraintCategory::Boring,
2317+
) {
2318+
span_mirbug!(
2319+
self,
2320+
rvalue,
2321+
"unexpected comparison types {:?} and {:?} yields {:?}",
2322+
ty_left,
2323+
ty_right,
2324+
terr
2325+
)
2326+
}
23222327
}
2328+
// For types with no regions we can just check that the
2329+
// both operands have the same type.
2330+
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_)
2331+
if ty_left == right.ty(body, tcx) => {}
2332+
// Other types are compared by trait methods, not by
2333+
// `Rvalue::BinaryOp`.
2334+
_ => span_mirbug!(
2335+
self,
2336+
rvalue,
2337+
"unexpected comparison types {:?} and {:?}",
2338+
ty_left,
2339+
right.ty(body, tcx)
2340+
),
23232341
}
23242342
}
23252343

src/test/ui/nll/type-check-pointer-comparisons.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) {
2121
}
2222

2323
fn compare_hr_fn_ptr<'a>(f: fn(&'a i32), g: fn(&i32)) {
24-
f == g;
25-
//~^ ERROR higher-ranked subtype error
24+
// Ideally this should compile with the operands swapped as well, but HIR
25+
// type checking prevents it (and stops compilation) for now.
26+
f == g; // OK
2627
}
2728

2829
fn compare_const_fn_ptr<'a>(f: *const fn(&'a i32), g: *const fn(&i32)) {
29-
f == g;
30-
//~^ ERROR higher-ranked subtype error
30+
f == g; // OK
3131
}
3232

3333
fn main() {}

src/test/ui/nll/type-check-pointer-comparisons.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,5 @@ LL | f == g;
7676

7777
help: `'a` and `'b` must be the same: replace one with the other
7878

79-
error: higher-ranked subtype error
80-
--> $DIR/type-check-pointer-comparisons.rs:24:5
81-
|
82-
LL | f == g;
83-
| ^^^^^^
84-
85-
error: higher-ranked subtype error
86-
--> $DIR/type-check-pointer-comparisons.rs:29:5
87-
|
88-
LL | f == g;
89-
| ^^^^^^
90-
91-
error: aborting due to 8 previous errors
79+
error: aborting due to 6 previous errors
9280

0 commit comments

Comments
 (0)