Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #132237

Merged
merged 51 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4ba20f6
Preparing for merge from rustc
Oct 17, 2024
fa1e265
Merge from rustc
Oct 17, 2024
8640c43
data-race test: disable address reuse that can incur accidental sync
RalfJung Oct 17, 2024
f7ccac9
Auto merge of #3975 - rust-lang:rustup-2024-10-17, r=RalfJung
bors Oct 17, 2024
d7e91ba
miri: improve support for `f16` and `f128`
eduardosm Oct 17, 2024
8bb356c
Auto merge of #3977 - eduardosm:f16-f128, r=RalfJung
bors Oct 17, 2024
5db0e40
pthread-threadname: ensure we can see the name set via the Rust API
RalfJung Oct 18, 2024
dd81b8c
Auto merge of #3978 - RalfJung:threadname, r=RalfJung
bors Oct 18, 2024
2775f39
tail_calls: add test ensuring local vars are indeed gone
RalfJung Oct 18, 2024
3386ae2
Auto merge of #3979 - RalfJung:tail-call-drops-locals, r=RalfJung
bors Oct 18, 2024
ea2ac89
Preparing for merge from rustc
Oct 20, 2024
19b0bb9
Merge from rustc
Oct 20, 2024
ccd680e
fmt
Oct 20, 2024
45a9a7c
Auto merge of #3980 - rust-lang:rustup-2024-10-20, r=RalfJung
bors Oct 20, 2024
2b11c70
Replace `set_last_error` with `set_last_error_and_return_i*`
noahmbright Oct 4, 2024
c2f43ba
Added support for prctl handling thread names
YohDeadfall Sep 20, 2024
13e5e4b
Auto merge of #3941 - noahmbright:unix_shims, r=oli-obk
bors Oct 21, 2024
695a1b6
Auto merge of #3899 - YohDeadfall:prctl-thread-name, r=RalfJung
bors Oct 21, 2024
e51eded
epoll_ctl: throw unsupported error on unsupported opcode
RalfJung Oct 21, 2024
499820a
Preparing for merge from rustc
Oct 22, 2024
865acc2
Merge from rustc
Oct 22, 2024
cd8c123
fmt
Oct 22, 2024
3d9d393
Auto merge of #3985 - rust-lang:rustup-2024-10-22, r=RalfJung
bors Oct 22, 2024
f8448f9
Auto merge of #3982 - RalfJung:epoll_ctl, r=RalfJung
bors Oct 22, 2024
615822d
Switch CI to merge queues
Kobzol Oct 21, 2024
340d2f7
Merge pull request #3981 from Kobzol/ci-merge-queue
marcoieni Oct 22, 2024
0b52ec3
Simplify confusing ResolvedArg constructors
compiler-errors Oct 22, 2024
1b7a91e
Deduplicate handling of early-bound params in RTN
compiler-errors Oct 22, 2024
c1004ff
Clear more `eval_libc` errors from unix shims
noahmbright Oct 21, 2024
a21369f
Merge pull request #3984 from noahmbright/unix_shims
RalfJung Oct 25, 2024
e5d32b6
CI workflow: tweak conclusion job
RalfJung Oct 25, 2024
82b041e
get rid of fd_not_found; improve error handling in FileMetadata
RalfJung Oct 25, 2024
2350ba7
some more opportunities for set_last_error_and_return
RalfJung Oct 25, 2024
cbf6c86
Merge pull request #3990 from RalfJung/errno-cleanup
RalfJung Oct 25, 2024
3432b91
Merge pull request #3989 from RalfJung/ci
RalfJung Oct 25, 2024
df9829c
indicate more explicitly where we close host file/dir handles
RalfJung Oct 25, 2024
3ff01dd
automatic PR: explain how to trigger CI
RalfJung Oct 26, 2024
d09fbe3
Merge pull request #3994 from RalfJung/auto-pr
saethlin Oct 26, 2024
d1530f0
Merge pull request #3993 from RalfJung/dir-entry-drop-explicit
RalfJung Oct 26, 2024
72664f7
fix error returned from readdir_r when isolation is enabled
RalfJung Oct 26, 2024
3f763c7
do not use host 'raw_os_error' to compute target error code
RalfJung Oct 26, 2024
4a34e27
do not set the file type to an error code
RalfJung Oct 26, 2024
ca0e5df
Merge pull request #3995 from RalfJung/readdir_r
oli-obk Oct 26, 2024
442f395
Move an impl-Trait check from AST validation to AST lowering
fmease Oct 27, 2024
924ded6
Clean up some comments on lint implementation
ehuss Oct 27, 2024
4ccaef1
Revert "ci update freebsd version proposal, freebsd 12 being eol."
devnexen Oct 27, 2024
60beb59
Rollup merge of #132043 - compiler-errors:simplify-rbv, r=cjgillot
matthiaskrgr Oct 27, 2024
574a8ba
Rollup merge of #132214 - fmease:mv-impl-trait-val-paths, r=compiler-…
matthiaskrgr Oct 27, 2024
4649a1b
Rollup merge of #132221 - ehuss:lint-docs, r=compiler-errors
matthiaskrgr Oct 27, 2024
afd8897
Rollup merge of #132228 - devnexen:ci_update_fbsd_revert, r=workingju…
matthiaskrgr Oct 27, 2024
0cace65
Rollup merge of #132234 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
modifiers: Option<ast::TraitBoundModifiers>,
) -> hir::QPath<'hir> {
let qself_position = qself.as_ref().map(|q| q.position);
let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx));
let qself = qself
.as_ref()
// Reject cases like `<impl Trait>::Assoc` and `<impl Trait as Trait>::Assoc`.
.map(|q| self.lower_ty(&q.ty, ImplTraitContext::Disallowed(ImplTraitPosition::Path)));

let partial_res =
self.resolver.get_partial_res(id).unwrap_or_else(|| PartialRes::new(Res::Err));
Expand Down Expand Up @@ -75,6 +78,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
None
};

// Only permit `impl Trait` in the final segment. E.g., we permit `Option<impl Trait>`,
// `option::Option<T>::Xyz<impl Trait>` and reject `option::Option<impl Trait>::Xyz`.
let itctx = |i| {
if i + 1 == p.segments.len() {
itctx
} else {
ImplTraitContext::Disallowed(ImplTraitPosition::Path)
}
};

let path_span_lo = p.span.shrink_to_lo();
let proj_start = p.segments.len() - unresolved_segments;
let path = self.arena.alloc(hir::Path {
Expand Down Expand Up @@ -121,7 +134,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
segment,
param_mode,
generic_args_mode,
itctx,
itctx(i),
bound_modifier_allowed_features.clone(),
)
},
Expand Down Expand Up @@ -185,7 +198,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
segment,
param_mode,
generic_args_mode,
itctx,
itctx(i),
None,
));
let qpath = hir::QPath::TypeRelative(ty, hir_segment);
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ ast_passes_generic_before_constraints = generic arguments must come before the f

ast_passes_generic_default_trailing = generic parameters with a default must be trailing

ast_passes_impl_trait_path = `impl Trait` is not allowed in path parameters

ast_passes_incompatible_features = `{$f1}` and `{$f2}` are incompatible, using them at the same time is not allowed
.help = remove one of these features

Expand Down
46 changes: 0 additions & 46 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ struct AstValidator<'a> {

disallow_tilde_const: Option<TildeConstReason>,

/// Used to ban `impl Trait` in path projections like `<impl Iterator>::Item`
/// or `Foo::Bar<impl Trait>`
is_impl_trait_banned: bool,

/// Used to ban explicit safety on foreign items when the extern block is not marked as unsafe.
extern_mod_safety: Option<Safety>,

Expand Down Expand Up @@ -123,12 +119,6 @@ impl<'a> AstValidator<'a> {
self.extern_mod_safety = old;
}

fn with_banned_impl_trait(&mut self, f: impl FnOnce(&mut Self)) {
let old = mem::replace(&mut self.is_impl_trait_banned, true);
f(self);
self.is_impl_trait_banned = old;
}

fn with_tilde_const(
&mut self,
disallowed: Option<TildeConstReason>,
Expand Down Expand Up @@ -213,37 +203,6 @@ impl<'a> AstValidator<'a> {
.with_tilde_const(Some(TildeConstReason::TraitObject), |this| {
visit::walk_ty(this, t)
}),
TyKind::Path(qself, path) => {
// We allow these:
// - `Option<impl Trait>`
// - `option::Option<impl Trait>`
// - `option::Option<T>::Foo<impl Trait>`
//
// But not these:
// - `<impl Trait>::Foo`
// - `option::Option<impl Trait>::Foo`.
//
// To implement this, we disallow `impl Trait` from `qself`
// (for cases like `<impl Trait>::Foo>`)
// but we allow `impl Trait` in `GenericArgs`
// iff there are no more PathSegments.
if let Some(qself) = qself {
// `impl Trait` in `qself` is always illegal
self.with_banned_impl_trait(|this| this.visit_ty(&qself.ty));
}

// Note that there should be a call to visit_path here,
// so if any logic is added to process `Path`s a call to it should be
// added both in visit_path and here. This code mirrors visit::walk_path.
for (i, segment) in path.segments.iter().enumerate() {
// Allow `impl Trait` iff we're on the final path segment
if i == path.segments.len() - 1 {
self.visit_path_segment(segment);
} else {
self.with_banned_impl_trait(|this| this.visit_path_segment(segment));
}
}
}
_ => visit::walk_ty(self, t),
}
}
Expand Down Expand Up @@ -737,10 +696,6 @@ impl<'a> AstValidator<'a> {
}
}
TyKind::ImplTrait(_, bounds) => {
if self.is_impl_trait_banned {
self.dcx().emit_err(errors::ImplTraitPath { span: ty.span });
}

if let Some(outer_impl_trait_sp) = self.outer_impl_trait {
self.dcx().emit_err(errors::NestedImplTrait {
span: ty.span,
Expand Down Expand Up @@ -1729,7 +1684,6 @@ pub fn check_crate(
has_proc_macro_decls: false,
outer_impl_trait: None,
disallow_tilde_const: Some(TildeConstReason::Item),
is_impl_trait_banned: false,
extern_mod_safety: None,
lint_buffer: lints,
};
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,6 @@ pub(crate) struct TraitObjectBound {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_passes_impl_trait_path, code = E0667)]
pub(crate) struct ImplTraitPath {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_passes_nested_impl_trait, code = E0666)]
pub(crate) struct NestedImplTrait {
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0667.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#### Note: this error code is no longer emitted by the compiler.

`impl Trait` is not allowed in path parameters.

Erroneous code example:

```compile_fail,E0667
```ignore (removed error code)
fn some_fn(mut x: impl Iterator) -> <impl Iterator>::Item { // error!
x.next().unwrap()
}
Expand All @@ -11,7 +13,7 @@ fn some_fn(mut x: impl Iterator) -> <impl Iterator>::Item { // error!
You cannot use `impl Trait` in path parameters. If you want something
equivalent, you can do this instead:

```
```ignore (removed error code)
fn some_fn<T: Iterator>(mut x: T) -> T::Item { // ok!
x.next().unwrap()
}
Expand Down
Loading
Loading