Skip to content

Commit a926696

Browse files
committed
Auto merge of rust-lang#101805 - Dylan-DPC:rollup-mpdlbin, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#101433 (Emit a note that static bounds from HRTBs are a bug) - rust-lang#101684 (smol grammar changes to README.md) - rust-lang#101769 (rustdoc: remove redundant CSS `.out-of-band > span.since { position }`) - rust-lang#101772 (Also replace the placeholder for the stable_features lint) - rust-lang#101773 (rustdoc: remove outdated CSS `.content table` etc) - rust-lang#101779 (Update test output for drop tracking) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c97922d + 15a5bc9 commit a926696

File tree

59 files changed

+947
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+947
-276
lines changed

README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Read ["Installation"] from [The Book].
2222
## Installing from Source
2323

2424
The Rust build system uses a Python script called `x.py` to build the compiler,
25-
which manages the bootstrapping process. It lives in the root of the project.
25+
which manages the bootstrapping process. It lives at the root of the project.
2626

2727
The `x.py` command can be run directly on most systems in the following format:
2828

@@ -32,7 +32,7 @@ The `x.py` command can be run directly on most systems in the following format:
3232

3333
This is how the documentation and examples assume you are running `x.py`.
3434

35-
Systems such as Ubuntu 20.04 LTS do not create the necessary `python` command by default when Python is installed that allows `x.py` to be run directly. In that case you can either create a symlink for `python` (Ubuntu provides the `python-is-python3` package for this), or run `x.py` using Python itself:
35+
Systems such as Ubuntu 20.04 LTS do not create the necessary `python` command by default when Python is installed that allows `x.py` to be run directly. In that case, you can either create a symlink for `python` (Ubuntu provides the `python-is-python3` package for this), or run `x.py` using Python itself:
3636

3737
```sh
3838
# Python 3
@@ -103,22 +103,21 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
103103
### Building on Windows
104104
105105
There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
106-
Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust
107-
you need depends largely on what C/C++ libraries you want to interoperate with:
108-
for interop with software produced by Visual Studio use the MSVC build of Rust;
109-
for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
110-
build.
106+
Visual Studio and the GNU ABI used by the GCC toolchain. Which version of Rust
107+
you need depends largely on what C/C++ libraries you want to interoperate with.
108+
Use the MSVC build of Rust to interop with software produced by Visual Studio and
109+
the GNU build to interop with GNU software built using the MinGW/MSYS2 toolchain.
111110
112111
#### MinGW
113112
114113
[MSYS2][msys2] can be used to easily build Rust on Windows:
115114
116115
[msys2]: https://www.msys2.org/
117116
118-
1. Grab the latest [MSYS2 installer][msys2] and go through the installer.
117+
1. Download the latest [MSYS2 installer][msys2] and go through the installer.
119118
120-
2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
121-
MSYS2 (i.e. `C:\msys64`), depending on whether you want 32-bit or 64-bit
119+
2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation
120+
directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit
122121
Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
123122
-mingw32` or `msys2_shell.cmd -mingw64` from the command line instead)
124123
@@ -168,7 +167,7 @@ shell with:
168167
python x.py build
169168
```
170169
171-
Currently, building Rust only works with some known versions of Visual Studio. If
170+
Right now, building Rust only works with some known versions of Visual Studio. If
172171
you have a more recent version installed and the build system doesn't understand,
173172
you may need to force rustbuild to use an older version. This can be done
174173
by manually calling the appropriate vcvars file before running the bootstrap.
@@ -225,7 +224,7 @@ the ABI used. I.e., if the ABI was `x86_64-pc-windows-msvc`, the directory will
225224
226225
Since the Rust compiler is written in Rust, it must be built by a
227226
precompiled "snapshot" version of itself (made in an earlier stage of
228-
development). As such, source builds require a connection to the Internet, to
227+
development). As such, source builds require an Internet connection to
229228
fetch snapshots, and an OS that can execute the available snapshot binaries.
230229
231230
Snapshot binaries are currently built and tested on several platforms:

compiler/rustc_attr/src/builtin.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2121
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
2222
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
2323

24+
pub fn rust_version_symbol() -> Symbol {
25+
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
26+
let version = version.split(' ').next().unwrap();
27+
Symbol::intern(&version)
28+
}
29+
2430
pub fn is_builtin_attr(attr: &Attribute) -> bool {
2531
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
2632
}
@@ -495,9 +501,7 @@ where
495501
}
496502

497503
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
498-
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
499-
let version = version.split(' ').next().unwrap();
500-
since = Some(Symbol::intern(&version));
504+
since = Some(rust_version_symbol());
501505
}
502506

503507
match (feature, since) {

compiler/rustc_borrowck/src/constraints/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ pub(crate) struct OutlivesConstraintSet<'tcx> {
2121

2222
impl<'tcx> OutlivesConstraintSet<'tcx> {
2323
pub(crate) fn push(&mut self, constraint: OutlivesConstraint<'tcx>) {
24-
debug!(
25-
"OutlivesConstraintSet::push({:?}: {:?} @ {:?}",
26-
constraint.sup, constraint.sub, constraint.locations
27-
);
24+
debug!("OutlivesConstraintSet::push({:?})", constraint);
2825
if constraint.sup == constraint.sub {
2926
// 'a: 'a is pretty uninteresting
3027
return;
@@ -73,7 +70,7 @@ impl<'tcx> Index<OutlivesConstraintIndex> for OutlivesConstraintSet<'tcx> {
7370
}
7471
}
7572

76-
#[derive(Clone, PartialEq, Eq)]
73+
#[derive(Copy, Clone, PartialEq, Eq)]
7774
pub struct OutlivesConstraint<'tcx> {
7875
// NB. The ordering here is not significant for correctness, but
7976
// it is for convenience. Before we dump the constraints in the

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty::{self, RegionVid, TyCtxt};
1515
use rustc_span::symbol::{kw, Symbol};
1616
use rustc_span::{sym, DesugaringKind, Span};
1717

18-
use crate::region_infer::BlameConstraint;
18+
use crate::region_infer::{BlameConstraint, ExtraConstraintInfo};
1919
use crate::{
2020
borrow_set::BorrowData, nll::ConstraintDescription, region_infer::Cause, MirBorrowckCtxt,
2121
WriteKind,
@@ -38,6 +38,7 @@ pub(crate) enum BorrowExplanation<'tcx> {
3838
span: Span,
3939
region_name: RegionName,
4040
opt_place_desc: Option<String>,
41+
extra_info: Vec<ExtraConstraintInfo>,
4142
},
4243
Unexplained,
4344
}
@@ -243,6 +244,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
243244
ref region_name,
244245
ref opt_place_desc,
245246
from_closure: _,
247+
ref extra_info,
246248
} => {
247249
region_name.highlight_region_name(err);
248250

@@ -268,6 +270,14 @@ impl<'tcx> BorrowExplanation<'tcx> {
268270
);
269271
};
270272

273+
for extra in extra_info {
274+
match extra {
275+
ExtraConstraintInfo::PlaceholderFromPredicate(span) => {
276+
err.span_note(*span, format!("due to current limitations in the borrow checker, this implies a `'static` lifetime"));
277+
}
278+
}
279+
}
280+
271281
self.add_lifetime_bound_suggestion_to_diagnostic(err, &category, span, region_name);
272282
}
273283
_ => {}
@@ -309,18 +319,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
309319
&self,
310320
borrow_region: RegionVid,
311321
outlived_region: RegionVid,
312-
) -> (ConstraintCategory<'tcx>, bool, Span, Option<RegionName>) {
313-
let BlameConstraint { category, from_closure, cause, variance_info: _ } =
314-
self.regioncx.best_blame_constraint(
315-
&self.body,
316-
borrow_region,
317-
NllRegionVariableOrigin::FreeRegion,
318-
|r| self.regioncx.provides_universal_region(r, borrow_region, outlived_region),
319-
);
322+
) -> (ConstraintCategory<'tcx>, bool, Span, Option<RegionName>, Vec<ExtraConstraintInfo>) {
323+
let (blame_constraint, extra_info) = self.regioncx.best_blame_constraint(
324+
borrow_region,
325+
NllRegionVariableOrigin::FreeRegion,
326+
|r| self.regioncx.provides_universal_region(r, borrow_region, outlived_region),
327+
);
328+
let BlameConstraint { category, from_closure, cause, .. } = blame_constraint;
320329

321330
let outlived_fr_name = self.give_region_a_name(outlived_region);
322331

323-
(category, from_closure, cause.span, outlived_fr_name)
332+
(category, from_closure, cause.span, outlived_fr_name, extra_info)
324333
}
325334

326335
/// Returns structured explanation for *why* the borrow contains the
@@ -392,7 +401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
392401

393402
None => {
394403
if let Some(region) = self.to_error_region_vid(borrow_region_vid) {
395-
let (category, from_closure, span, region_name) =
404+
let (category, from_closure, span, region_name, extra_info) =
396405
self.free_region_constraint_info(borrow_region_vid, region);
397406
if let Some(region_name) = region_name {
398407
let opt_place_desc = self.describe_place(borrow.borrowed_place.as_ref());
@@ -402,6 +411,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
402411
span,
403412
region_name,
404413
opt_place_desc,
414+
extra_info,
405415
}
406416
} else {
407417
debug!("Could not generate a region name");

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::session_diagnostics::{
3131
};
3232

3333
use super::{OutlivesSuggestionBuilder, RegionName};
34-
use crate::region_infer::BlameConstraint;
34+
use crate::region_infer::{BlameConstraint, ExtraConstraintInfo};
3535
use crate::{
3636
nll::ConstraintDescription,
3737
region_infer::{values::RegionElement, TypeTest},
@@ -234,7 +234,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
234234

235235
// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
236236
let (_, cause) = self.regioncx.find_outlives_blame_span(
237-
&self.body,
238237
longer_fr,
239238
NllRegionVariableOrigin::Placeholder(placeholder),
240239
error_vid,
@@ -355,10 +354,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
355354
) {
356355
debug!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
357356

358-
let BlameConstraint { category, cause, variance_info, from_closure: _ } =
359-
self.regioncx.best_blame_constraint(&self.body, fr, fr_origin, |r| {
357+
let (blame_constraint, extra_info) =
358+
self.regioncx.best_blame_constraint(fr, fr_origin, |r| {
360359
self.regioncx.provides_universal_region(r, fr, outlived_fr)
361360
});
361+
let BlameConstraint { category, cause, variance_info, .. } = blame_constraint;
362362

363363
debug!("report_region_error: category={:?} {:?} {:?}", category, cause, variance_info);
364364

@@ -467,6 +467,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
467467
}
468468
}
469469

470+
for extra in extra_info {
471+
match extra {
472+
ExtraConstraintInfo::PlaceholderFromPredicate(span) => {
473+
diag.span_note(span, format!("due to current limitations in the borrow checker, this implies a `'static` lifetime"));
474+
}
475+
}
476+
}
477+
470478
self.buffer_error(diag);
471479
}
472480

@@ -558,6 +566,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
558566
/// LL | ref_obj(x)
559567
/// | ^^^^^^^^^^ `x` escapes the function body here
560568
/// ```
569+
#[instrument(level = "debug", skip(self))]
561570
fn report_escaping_data_error(
562571
&self,
563572
errci: &ErrorConstraintInfo<'tcx>,

0 commit comments

Comments
 (0)