Skip to content

Commit

Permalink
Merge branch 'rust-lang:master' into bibliography.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbkhi authored Mar 9, 2024
2 parents 28b2823 + f863101 commit 126cdf6
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 223 deletions.
3 changes: 3 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
- [Interactions with turbofishing](./turbofishing-and-early-late-bound.md)
- [Higher-ranked trait bounds](./traits/hrtb.md)
- [Caching subtleties](./traits/caching.md)
- [Implied bounds](./traits/implied-bounds.md)
- [Specialization](./traits/specialization.md)
- [Chalk-based trait solving](./traits/chalk.md)
- [Lowering to logic](./traits/lowering-to-logic.md)
Expand All @@ -131,8 +132,10 @@
- [The solver](./solve/the-solver.md)
- [Canonicalization](./solve/canonicalization.md)
- [Coinduction](./solve/coinduction.md)
- [Caching](./solve/caching.md)
- [Proof trees](./solve/proof-trees.md)
- [Normalization](./solve/normalization.md)
- [Opaque types](./solve/opaque-types.md)
- [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md)
- [Type checking](./type-checking.md)
- [Method Lookup](./method-lookup.md)
Expand Down
81 changes: 24 additions & 57 deletions src/building/suggested.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,67 +276,34 @@ If you're using nix, you can use the following nix-shell to work on Rust:

```nix
{ pkgs ? import <nixpkgs> {} }:
# This file contains a development shell for working on rustc.
let
# Build configuration for rust-lang/rust. Based on `config.example.toml` (then called
# `config.toml.example`) from `1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5`
config = pkgs.writeText "rustc-config" ''
profile = "compiler" # you may want to choose a different profile, like `library` or `tools`
[build]
patch-binaries-for-nix = true
# The path to (or name of) the GDB executable to use. This is only used for
# executing the debuginfo test suite.
gdb = "${pkgs.gdb}/bin/gdb"
python = "${pkgs.python3Full}/bin/python"
[rust]
debug = true
incremental = true
deny-warnings = false
# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
# sysroot.
llvm-tools = true
# Print backtrace on internal compiler errors during bootstrap
backtrace-on-ice = true
'';
ripgrepConfig =
let
# Files that are ignored by ripgrep when searching.
ignoreFile = pkgs.writeText "rustc-rgignore" ''
configure
config.example.toml
x.py
LICENSE-MIT
LICENSE-APACHE
COPYRIGHT
**/*.txt
**/*.toml
**/*.yml
**/*.nix
*.md
src/ci
src/etc/
src/llvm-emscripten/
src/llvm-project/
src/rtstartup/
src/rustllvm/
src/stdsimd/
src/tools/rls/rls-analysis/test_data/
'';
in
pkgs.writeText "rustc-ripgreprc" "--ignore-file=${ignoreFile}";
in
pkgs.mkShell {
name = "rustc";
nativeBuildInputs = with pkgs; [
gcc_multi binutils cmake ninja openssl pkgconfig python39 git curl cacert patchelf nix psutils
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
];
buildInputs = with pkgs; [
openssl glibc.out glibc.static
];
RIPGREP_CONFIG_PATH = ripgrepConfig;
# Avoid creating text files for ICEs.
RUSTC_ICE = "0";
}
```

Note that when using nix on a not-NixOS distribution, it may be necessary to set
**`patch-binaries-for-nix = true` in `config.toml`**.
Bootstrap tries to detect whether it's running in nix and enable patching automatically,
but this detection can have false negatives.

You can also use your nix shell to manage `config.toml`:

```nix
let
config = pkgs.writeText "rustc-config" ''
# Your config.toml content goes here
''
pkgs.mkShell {
/* ... */
# This environment varaible tells bootstrap where our config.toml is.
RUST_BOOTSTRAP_CONFIG = config;
}
```
Expand Down
12 changes: 9 additions & 3 deletions src/implementing_new_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ a new unstable feature:

1. Add the feature name to `rustc_span/src/symbol.rs` in the `Symbols {...}` block.

Note that this block must be in alphbetical order.

1. Add a feature gate declaration to `rustc_feature/src/unstable.rs` in the unstable
`declare_features` block.

Expand Down Expand Up @@ -171,9 +173,13 @@ a new unstable feature:
For an example of adding an error, see [#81015].

For features introducing new syntax, pre-expansion gating should be used instead.
To do so, extend the [`GatedSpans`] struct, add spans to it during parsing,
and then finally feature-gate all the spans in
[`rustc_ast_passes::feature_gate::check_crate`].
During parsing, when the new syntax is parsed, the symbol must be inserted to the
current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`.

After being inserted to the gated spans, the span must be checked in the
[`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies
features. Exactly how it is gated depends on the exact type of feature, but most
likely will use the `gate_all!()` macro.

1. Add a test to ensure the feature cannot be used without
a feature gate, by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`.
Expand Down
Loading

0 comments on commit 126cdf6

Please sign in to comment.