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

rustdoc: synthetic auto: filter out clauses from the implementor's ParamEnv #123638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn clean_param_env<'tcx>(

// FIXME(#111101): Incorporate the explicit predicates of the item here...
let item_predicates: FxIndexSet<_> =
tcx.predicates_of(item_def_id).predicates.iter().map(|(pred, _)| pred).collect();
tcx.param_env(item_def_id).caller_bounds().iter().collect();
Copy link
Member Author

@fmease fmease Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a smol revert. Before my refactoring PR it looked very similar:

let orig_bounds: FxHashSet<_> = tcx.param_env(item_def_id).caller_bounds().iter().collect();

let where_predicates = param_env
.caller_bounds()
.iter()
Expand Down
14 changes: 14 additions & 0 deletions tests/rustdoc/synthetic_auto/supertrait-bounds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Check that we don't add bounds to synthetic auto trait impls that are
// already implied by the item (like supertrait bounds).

// In this case we don't want to add the bounds `T: Copy` and `T: 'static`
// to the auto trait impl because they're implied by the bound `T: Bound`
// on the implementor `Type`.

pub struct Type<T: Bound>(T);

// @has supertrait_bounds/struct.Type.html
// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \
// "impl<T> Send for Type<T>where T: Send,"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On master, this gets rendered as:

impl<T> Send for Type<T>where T: Copy + Clone + 'static + Send,

Once/if I fix #111101 (might need an FCP, not sure), this will get rendered as:

impl<T> Send for Type<T>where T: Bound + Send,


pub trait Bound: Copy + 'static {}
Loading